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
44,700
Whitebolt/require-extra
src/eval.js
evaluate
function evaluate(config) { const _config = _parseConfig(config); const options = _createOptions(_config); return _runScript(_config, options); }
javascript
function evaluate(config) { const _config = _parseConfig(config); const options = _createOptions(_config); return _runScript(_config, options); }
[ "function", "evaluate", "(", "config", ")", "{", "const", "_config", "=", "_parseConfig", "(", "config", ")", ";", "const", "options", "=", "_createOptions", "(", "_config", ")", ";", "return", "_runScript", "(", "_config", ",", "options", ")", ";", "}" ]
Given a config object, evaluate the given content in a sandbox according to the config. Return the module. @param {Object} config Config to use. @returns {Module}
[ "Given", "a", "config", "object", "evaluate", "the", "given", "content", "in", "a", "sandbox", "according", "to", "the", "config", ".", "Return", "the", "module", "." ]
2a8f737aab67305c9fda3ee56aa7953e97cee859
https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/eval.js#L179-L183
44,701
jriecken/asset-smasher
lib/discovery/manifest.js
hasFileType
function hasFileType(file, fileExt) { file = path.basename(file); var ext = path.extname(file); do { if (ext === fileExt) { return true; } else { file = path.basename(file, ext); ext = path.extname(file); } } while (ext); return false; }
javascript
function hasFileType(file, fileExt) { file = path.basename(file); var ext = path.extname(file); do { if (ext === fileExt) { return true; } else { file = path.basename(file, ext); ext = path.extname(file); } } while (ext); return false; }
[ "function", "hasFileType", "(", "file", ",", "fileExt", ")", "{", "file", "=", "path", ".", "basename", "(", "file", ")", ";", "var", "ext", "=", "path", ".", "extname", "(", "file", ")", ";", "do", "{", "if", "(", "ext", "===", "fileExt", ")", "{", "return", "true", ";", "}", "else", "{", "file", "=", "path", ".", "basename", "(", "file", ",", "ext", ")", ";", "ext", "=", "path", ".", "extname", "(", "file", ")", ";", "}", "}", "while", "(", "ext", ")", ";", "return", "false", ";", "}" ]
Checks that the file has the specified type in one of its extensions E.g. hasFileType('foo.js.dust.ejs', '.js') => true hasFileType('foo.css.less', '.js') => false hasFileType('foo.css.less', '.css') => true
[ "Checks", "that", "the", "file", "has", "the", "specified", "type", "in", "one", "of", "its", "extensions" ]
c627449b01f5da892683895915f74baa9994a475
https://github.com/jriecken/asset-smasher/blob/c627449b01f5da892683895915f74baa9994a475/lib/discovery/manifest.js#L50-L62
44,702
jriecken/asset-smasher
lib/discovery/manifest.js
function (contents, wfCb) { async.eachSeries(contents.split('\n'), function (line, eachCb) { setImmediateCompat(function() { if (line && line.indexOf('#') !== 0) { var directive = line.match(DIRECTIVE_REGEX); if (!directive) { eachCb(new Error('Bad directive in manifest file: ' + line)); } else { var cmd = directive[1]; var file = directive[2]; if (self[cmd]) { self[cmd](manifest, assetBundle, file, eachCb); } else { eachCb(new Error('Bad directive in manifest file: ' + line)); } } } else { eachCb(); } }); }, wfCb); }
javascript
function (contents, wfCb) { async.eachSeries(contents.split('\n'), function (line, eachCb) { setImmediateCompat(function() { if (line && line.indexOf('#') !== 0) { var directive = line.match(DIRECTIVE_REGEX); if (!directive) { eachCb(new Error('Bad directive in manifest file: ' + line)); } else { var cmd = directive[1]; var file = directive[2]; if (self[cmd]) { self[cmd](manifest, assetBundle, file, eachCb); } else { eachCb(new Error('Bad directive in manifest file: ' + line)); } } } else { eachCb(); } }); }, wfCb); }
[ "function", "(", "contents", ",", "wfCb", ")", "{", "async", ".", "eachSeries", "(", "contents", ".", "split", "(", "'\\n'", ")", ",", "function", "(", "line", ",", "eachCb", ")", "{", "setImmediateCompat", "(", "function", "(", ")", "{", "if", "(", "line", "&&", "line", ".", "indexOf", "(", "'#'", ")", "!==", "0", ")", "{", "var", "directive", "=", "line", ".", "match", "(", "DIRECTIVE_REGEX", ")", ";", "if", "(", "!", "directive", ")", "{", "eachCb", "(", "new", "Error", "(", "'Bad directive in manifest file: '", "+", "line", ")", ")", ";", "}", "else", "{", "var", "cmd", "=", "directive", "[", "1", "]", ";", "var", "file", "=", "directive", "[", "2", "]", ";", "if", "(", "self", "[", "cmd", "]", ")", "{", "self", "[", "cmd", "]", "(", "manifest", ",", "assetBundle", ",", "file", ",", "eachCb", ")", ";", "}", "else", "{", "eachCb", "(", "new", "Error", "(", "'Bad directive in manifest file: '", "+", "line", ")", ")", ";", "}", "}", "}", "else", "{", "eachCb", "(", ")", ";", "}", "}", ")", ";", "}", ",", "wfCb", ")", ";", "}" ]
For each line, process the directive on that line
[ "For", "each", "line", "process", "the", "directive", "on", "that", "line" ]
c627449b01f5da892683895915f74baa9994a475
https://github.com/jriecken/asset-smasher/blob/c627449b01f5da892683895915f74baa9994a475/lib/discovery/manifest.js#L125-L146
44,703
IonicaBizau/namy
lib/index.js
Namy
function Namy(input, callback) { if (/package.json$/.test(input)) { return ReadJson(input, function (err, data) { if (err) { return callback(err); } if (!data.main) { return callback(new Error("Cannot find the main field in package.json")); } Namy(data.main, callback); }); } var path = null , isInCache = null , res = null , name = null ; try { path = require.resolve(input) isInCache = !!require.cache[path] // TODO Make this async res = require(input) } catch (err) { return callback(err); } if (typeof res === "function") { name = res.name || null; } else { return callback(new Error("The module does not export a function.")); } if (!isInCache) { delete require.cache[path]; } if (!name) { return callback(new Error("The function does not have a name.")); } callback(null, name); }
javascript
function Namy(input, callback) { if (/package.json$/.test(input)) { return ReadJson(input, function (err, data) { if (err) { return callback(err); } if (!data.main) { return callback(new Error("Cannot find the main field in package.json")); } Namy(data.main, callback); }); } var path = null , isInCache = null , res = null , name = null ; try { path = require.resolve(input) isInCache = !!require.cache[path] // TODO Make this async res = require(input) } catch (err) { return callback(err); } if (typeof res === "function") { name = res.name || null; } else { return callback(new Error("The module does not export a function.")); } if (!isInCache) { delete require.cache[path]; } if (!name) { return callback(new Error("The function does not have a name.")); } callback(null, name); }
[ "function", "Namy", "(", "input", ",", "callback", ")", "{", "if", "(", "/", "package.json$", "/", ".", "test", "(", "input", ")", ")", "{", "return", "ReadJson", "(", "input", ",", "function", "(", "err", ",", "data", ")", "{", "if", "(", "err", ")", "{", "return", "callback", "(", "err", ")", ";", "}", "if", "(", "!", "data", ".", "main", ")", "{", "return", "callback", "(", "new", "Error", "(", "\"Cannot find the main field in package.json\"", ")", ")", ";", "}", "Namy", "(", "data", ".", "main", ",", "callback", ")", ";", "}", ")", ";", "}", "var", "path", "=", "null", ",", "isInCache", "=", "null", ",", "res", "=", "null", ",", "name", "=", "null", ";", "try", "{", "path", "=", "require", ".", "resolve", "(", "input", ")", "isInCache", "=", "!", "!", "require", ".", "cache", "[", "path", "]", "// TODO Make this async", "res", "=", "require", "(", "input", ")", "}", "catch", "(", "err", ")", "{", "return", "callback", "(", "err", ")", ";", "}", "if", "(", "typeof", "res", "===", "\"function\"", ")", "{", "name", "=", "res", ".", "name", "||", "null", ";", "}", "else", "{", "return", "callback", "(", "new", "Error", "(", "\"The module does not export a function.\"", ")", ")", ";", "}", "if", "(", "!", "isInCache", ")", "{", "delete", "require", ".", "cache", "[", "path", "]", ";", "}", "if", "(", "!", "name", ")", "{", "return", "callback", "(", "new", "Error", "(", "\"The function does not have a name.\"", ")", ")", ";", "}", "callback", "(", "null", ",", "name", ")", ";", "}" ]
Namy Gets the name of the exported function. @name Namy @function @param {String} input The path to the package.json, directory or the file. @param {Function} callback The callback function.
[ "Namy", "Gets", "the", "name", "of", "the", "exported", "function", "." ]
0b3d44680d3fb1ae1cefe4339e7f96c6abfb014f
https://github.com/IonicaBizau/namy/blob/0b3d44680d3fb1ae1cefe4339e7f96c6abfb014f/lib/index.js#L13-L54
44,704
anseki/grunt-task-helper
tasks/task_helper.js
function(srcArray, dest, options) { if (!srcArray.length) { // both no data, don't add to filesArray. (Don't return undefined.) return typeof dest === 'string' && fileUpdates.isNew(dest, options); // But filesArray isn't usable for 'files', 'cause Grunt doesn't support empty src. } else if (!dest) { return srcArray.some(function(src) { return fileUpdates.isNew(src, options); }); } else if (srcArray.length === 1 && path.resolve(srcArray[0]) === path.resolve(dest)) { return fileUpdates.isNew(dest, options); } // both files if (srcArray.length === 1) { return fileUpdates.compare(srcArray[0], dest) === 1; } else { // New file exists. return srcArray.some(function(src) { return fileUpdates.compare(src, dest) === 1; }); } }
javascript
function(srcArray, dest, options) { if (!srcArray.length) { // both no data, don't add to filesArray. (Don't return undefined.) return typeof dest === 'string' && fileUpdates.isNew(dest, options); // But filesArray isn't usable for 'files', 'cause Grunt doesn't support empty src. } else if (!dest) { return srcArray.some(function(src) { return fileUpdates.isNew(src, options); }); } else if (srcArray.length === 1 && path.resolve(srcArray[0]) === path.resolve(dest)) { return fileUpdates.isNew(dest, options); } // both files if (srcArray.length === 1) { return fileUpdates.compare(srcArray[0], dest) === 1; } else { // New file exists. return srcArray.some(function(src) { return fileUpdates.compare(src, dest) === 1; }); } }
[ "function", "(", "srcArray", ",", "dest", ",", "options", ")", "{", "if", "(", "!", "srcArray", ".", "length", ")", "{", "// both no data, don't add to filesArray. (Don't return undefined.)", "return", "typeof", "dest", "===", "'string'", "&&", "fileUpdates", ".", "isNew", "(", "dest", ",", "options", ")", ";", "// But filesArray isn't usable for 'files', 'cause Grunt doesn't support empty src.", "}", "else", "if", "(", "!", "dest", ")", "{", "return", "srcArray", ".", "some", "(", "function", "(", "src", ")", "{", "return", "fileUpdates", ".", "isNew", "(", "src", ",", "options", ")", ";", "}", ")", ";", "}", "else", "if", "(", "srcArray", ".", "length", "===", "1", "&&", "path", ".", "resolve", "(", "srcArray", "[", "0", "]", ")", "===", "path", ".", "resolve", "(", "dest", ")", ")", "{", "return", "fileUpdates", ".", "isNew", "(", "dest", ",", "options", ")", ";", "}", "// both files", "if", "(", "srcArray", ".", "length", "===", "1", ")", "{", "return", "fileUpdates", ".", "compare", "(", "srcArray", "[", "0", "]", ",", "dest", ")", "===", "1", ";", "}", "else", "{", "// New file exists.", "return", "srcArray", ".", "some", "(", "function", "(", "src", ")", "{", "return", "fileUpdates", ".", "compare", "(", "src", ",", "dest", ")", "===", "1", ";", "}", ")", ";", "}", "}" ]
'new' is keyword of language.
[ "new", "is", "keyword", "of", "language", "." ]
2954fa23ed01942fc09a69c6d98d98fecf729562
https://github.com/anseki/grunt-task-helper/blob/2954fa23ed01942fc09a69c6d98d98fecf729562/tasks/task_helper.js#L30-L52
44,705
anseki/grunt-task-helper
tasks/task_helper.js
function(filepath) { return grunt.file.exists(filepath) ? Math.floor(fs.statSync(filepath).mtime.getTime() / 1000) : 0; // mtime before epochtime isn't supported. }
javascript
function(filepath) { return grunt.file.exists(filepath) ? Math.floor(fs.statSync(filepath).mtime.getTime() / 1000) : 0; // mtime before epochtime isn't supported. }
[ "function", "(", "filepath", ")", "{", "return", "grunt", ".", "file", ".", "exists", "(", "filepath", ")", "?", "Math", ".", "floor", "(", "fs", ".", "statSync", "(", "filepath", ")", ".", "mtime", ".", "getTime", "(", ")", "/", "1000", ")", ":", "0", ";", "// mtime before epochtime isn't supported.", "}" ]
retrieve mtime as seconds.
[ "retrieve", "mtime", "as", "seconds", "." ]
2954fa23ed01942fc09a69c6d98d98fecf729562
https://github.com/anseki/grunt-task-helper/blob/2954fa23ed01942fc09a69c6d98d98fecf729562/tasks/task_helper.js#L72-L76
44,706
anseki/grunt-task-helper
tasks/task_helper.js
function(filepath, options) { // options.mtimeOffset: 3 default if (!fileUpdates.offset) { fileUpdates.offset = options.mtimeOffset || 3; } if (!fileUpdates.storeData) { // Initialize data. if (grunt.file.exists(fileUpdates.storeDataPath)) { fileUpdates.storeData = grunt.file.readJSON(fileUpdates.storeDataPath); } if (!fileUpdates.storeData) { fileUpdates.storeData = {}; } // Run the task that finalize data. grunt.task.run('taskHelperFin'); // The task starts after current target. NOT task. // (i.e. every target, and before other tasks) // Can't specify time after all tasks? // Grunt 0.5 may support a event that all tasks finish. // https://github.com/gruntjs/grunt/wiki/Roadmap } filepath = path.resolve(filepath); // full-path if (!(filepath in fileUpdates.storeData)) { fileUpdates.storeData[filepath] = 0; } return fileUpdates.storeData[filepath]; }
javascript
function(filepath, options) { // options.mtimeOffset: 3 default if (!fileUpdates.offset) { fileUpdates.offset = options.mtimeOffset || 3; } if (!fileUpdates.storeData) { // Initialize data. if (grunt.file.exists(fileUpdates.storeDataPath)) { fileUpdates.storeData = grunt.file.readJSON(fileUpdates.storeDataPath); } if (!fileUpdates.storeData) { fileUpdates.storeData = {}; } // Run the task that finalize data. grunt.task.run('taskHelperFin'); // The task starts after current target. NOT task. // (i.e. every target, and before other tasks) // Can't specify time after all tasks? // Grunt 0.5 may support a event that all tasks finish. // https://github.com/gruntjs/grunt/wiki/Roadmap } filepath = path.resolve(filepath); // full-path if (!(filepath in fileUpdates.storeData)) { fileUpdates.storeData[filepath] = 0; } return fileUpdates.storeData[filepath]; }
[ "function", "(", "filepath", ",", "options", ")", "{", "// options.mtimeOffset: 3 default", "if", "(", "!", "fileUpdates", ".", "offset", ")", "{", "fileUpdates", ".", "offset", "=", "options", ".", "mtimeOffset", "||", "3", ";", "}", "if", "(", "!", "fileUpdates", ".", "storeData", ")", "{", "// Initialize data.", "if", "(", "grunt", ".", "file", ".", "exists", "(", "fileUpdates", ".", "storeDataPath", ")", ")", "{", "fileUpdates", ".", "storeData", "=", "grunt", ".", "file", ".", "readJSON", "(", "fileUpdates", ".", "storeDataPath", ")", ";", "}", "if", "(", "!", "fileUpdates", ".", "storeData", ")", "{", "fileUpdates", ".", "storeData", "=", "{", "}", ";", "}", "// Run the task that finalize data.", "grunt", ".", "task", ".", "run", "(", "'taskHelperFin'", ")", ";", "// The task starts after current target. NOT task.", "// (i.e. every target, and before other tasks)", "// Can't specify time after all tasks?", "// Grunt 0.5 may support a event that all tasks finish.", "// https://github.com/gruntjs/grunt/wiki/Roadmap", "}", "filepath", "=", "path", ".", "resolve", "(", "filepath", ")", ";", "// full-path", "if", "(", "!", "(", "filepath", "in", "fileUpdates", ".", "storeData", ")", ")", "{", "fileUpdates", ".", "storeData", "[", "filepath", "]", "=", "0", ";", "}", "return", "fileUpdates", ".", "storeData", "[", "filepath", "]", ";", "}" ]
retrieve last update of file.
[ "retrieve", "last", "update", "of", "file", "." ]
2954fa23ed01942fc09a69c6d98d98fecf729562
https://github.com/anseki/grunt-task-helper/blob/2954fa23ed01942fc09a69c6d98d98fecf729562/tasks/task_helper.js#L78-L99
44,707
angular-template/ng1-template-gulp
lib/tasks/setup.js
createSymlinks
function createSymlinks(symlinks) { let path = require('path'); let fs = require('fs'); let del = require('del'); del.sync(symlinks.map(sl => sl.dest)); try { symlinks.forEach(sl => { let src = path.resolve(sl.src); fs.symlinkSync(src, sl.dest); }); } catch (err) { console.error(err); if (err.code === 'EPERM' && err.errno === -4048) { console.error('***************************'); console.error('*** PLEASE RUN AS ADMIN ***'); console.error('***************************'); } } }
javascript
function createSymlinks(symlinks) { let path = require('path'); let fs = require('fs'); let del = require('del'); del.sync(symlinks.map(sl => sl.dest)); try { symlinks.forEach(sl => { let src = path.resolve(sl.src); fs.symlinkSync(src, sl.dest); }); } catch (err) { console.error(err); if (err.code === 'EPERM' && err.errno === -4048) { console.error('***************************'); console.error('*** PLEASE RUN AS ADMIN ***'); console.error('***************************'); } } }
[ "function", "createSymlinks", "(", "symlinks", ")", "{", "let", "path", "=", "require", "(", "'path'", ")", ";", "let", "fs", "=", "require", "(", "'fs'", ")", ";", "let", "del", "=", "require", "(", "'del'", ")", ";", "del", ".", "sync", "(", "symlinks", ".", "map", "(", "sl", "=>", "sl", ".", "dest", ")", ")", ";", "try", "{", "symlinks", ".", "forEach", "(", "sl", "=>", "{", "let", "src", "=", "path", ".", "resolve", "(", "sl", ".", "src", ")", ";", "fs", ".", "symlinkSync", "(", "src", ",", "sl", ".", "dest", ")", ";", "}", ")", ";", "}", "catch", "(", "err", ")", "{", "console", ".", "error", "(", "err", ")", ";", "if", "(", "err", ".", "code", "===", "'EPERM'", "&&", "err", ".", "errno", "===", "-", "4048", ")", "{", "console", ".", "error", "(", "'***************************'", ")", ";", "console", ".", "error", "(", "'*** PLEASE RUN AS ADMIN ***'", ")", ";", "console", ".", "error", "(", "'***************************'", ")", ";", "}", "}", "}" ]
Creates one or more symbolic links. @param {Object[]} symlinks - Symlink details @param {string} symlinks[].src - Source file path @param {string} symlinks[].dest - Symbolic link file path
[ "Creates", "one", "or", "more", "symbolic", "links", "." ]
ea3b85db2d2f184e56e4ba9cdbf30d286c3986b4
https://github.com/angular-template/ng1-template-gulp/blob/ea3b85db2d2f184e56e4ba9cdbf30d286c3986b4/lib/tasks/setup.js#L22-L41
44,708
Submersible/node-staticfile
index.js
crawlDirectoryWithFS
function crawlDirectoryWithFS(parent, sync) { return fsCmd('readdir', sync, parent).then(function (things) { return Q.all(things.map(function (file) { file = path.join(parent, file); return Q.all([file, fsCmd('stat', sync, file)]); })); }).then(function (stats) { return Q.all(stats.map(function (args) { var file = args[0], stat = args[1]; if (stat.isDirectory()) { return crawlDirectoryWithFS(file, sync); } return file; })); }).then(function (grouped) { return [].concat.apply([], grouped); }); }
javascript
function crawlDirectoryWithFS(parent, sync) { return fsCmd('readdir', sync, parent).then(function (things) { return Q.all(things.map(function (file) { file = path.join(parent, file); return Q.all([file, fsCmd('stat', sync, file)]); })); }).then(function (stats) { return Q.all(stats.map(function (args) { var file = args[0], stat = args[1]; if (stat.isDirectory()) { return crawlDirectoryWithFS(file, sync); } return file; })); }).then(function (grouped) { return [].concat.apply([], grouped); }); }
[ "function", "crawlDirectoryWithFS", "(", "parent", ",", "sync", ")", "{", "return", "fsCmd", "(", "'readdir'", ",", "sync", ",", "parent", ")", ".", "then", "(", "function", "(", "things", ")", "{", "return", "Q", ".", "all", "(", "things", ".", "map", "(", "function", "(", "file", ")", "{", "file", "=", "path", ".", "join", "(", "parent", ",", "file", ")", ";", "return", "Q", ".", "all", "(", "[", "file", ",", "fsCmd", "(", "'stat'", ",", "sync", ",", "file", ")", "]", ")", ";", "}", ")", ")", ";", "}", ")", ".", "then", "(", "function", "(", "stats", ")", "{", "return", "Q", ".", "all", "(", "stats", ".", "map", "(", "function", "(", "args", ")", "{", "var", "file", "=", "args", "[", "0", "]", ",", "stat", "=", "args", "[", "1", "]", ";", "if", "(", "stat", ".", "isDirectory", "(", ")", ")", "{", "return", "crawlDirectoryWithFS", "(", "file", ",", "sync", ")", ";", "}", "return", "file", ";", "}", ")", ")", ";", "}", ")", ".", "then", "(", "function", "(", "grouped", ")", "{", "return", "[", "]", ".", "concat", ".", "apply", "(", "[", "]", ",", "grouped", ")", ";", "}", ")", ";", "}" ]
Recursively crawl a directory for all of it's files.
[ "Recursively", "crawl", "a", "directory", "for", "all", "of", "it", "s", "files", "." ]
40a060488fff32dee6c655408ad3f84d076764e9
https://github.com/Submersible/node-staticfile/blob/40a060488fff32dee6c655408ad3f84d076764e9/index.js#L33-L50
44,709
Submersible/node-staticfile
index.js
crawlDirectory
function crawlDirectory(parent, sync) { if (sync) { return crawlDirectory(parent, sync); } /* Use `find` if available, because it's fast! */ return exec('find ' + parent + ' -not -type d').spread(function (stdin) { return stdin.split('\n').filter(function (file) { return !!file; }); }).fail(function () { return crawlDirectoryWithFS(parent, sync); }); }
javascript
function crawlDirectory(parent, sync) { if (sync) { return crawlDirectory(parent, sync); } /* Use `find` if available, because it's fast! */ return exec('find ' + parent + ' -not -type d').spread(function (stdin) { return stdin.split('\n').filter(function (file) { return !!file; }); }).fail(function () { return crawlDirectoryWithFS(parent, sync); }); }
[ "function", "crawlDirectory", "(", "parent", ",", "sync", ")", "{", "if", "(", "sync", ")", "{", "return", "crawlDirectory", "(", "parent", ",", "sync", ")", ";", "}", "/* Use `find` if available, because it's fast! */", "return", "exec", "(", "'find '", "+", "parent", "+", "' -not -type d'", ")", ".", "spread", "(", "function", "(", "stdin", ")", "{", "return", "stdin", ".", "split", "(", "'\\n'", ")", ".", "filter", "(", "function", "(", "file", ")", "{", "return", "!", "!", "file", ";", "}", ")", ";", "}", ")", ".", "fail", "(", "function", "(", ")", "{", "return", "crawlDirectoryWithFS", "(", "parent", ",", "sync", ")", ";", "}", ")", ";", "}" ]
Crawl a directory for all of it's files!
[ "Crawl", "a", "directory", "for", "all", "of", "it", "s", "files!" ]
40a060488fff32dee6c655408ad3f84d076764e9
https://github.com/Submersible/node-staticfile/blob/40a060488fff32dee6c655408ad3f84d076764e9/index.js#L55-L67
44,710
mesmotronic/conbo
src/conbo/binding/AttributeBindings.js
function(el, value) { !conbo.isEmpty(value) ? el.classList.add('cb-hide') : el.classList.remove('cb-hide'); }
javascript
function(el, value) { !conbo.isEmpty(value) ? el.classList.add('cb-hide') : el.classList.remove('cb-hide'); }
[ "function", "(", "el", ",", "value", ")", "{", "!", "conbo", ".", "isEmpty", "(", "value", ")", "?", "el", ".", "classList", ".", "add", "(", "'cb-hide'", ")", ":", "el", ".", "classList", ".", "remove", "(", "'cb-hide'", ")", ";", "}" ]
Hides an element by making it invisible, but does not remove if from the layout of the page, meaning a blank space will remain @param {HTMLElement} el - DOM element to which the attribute applies @param {*} value - The value referenced by the attribute @returns {void} @example <div cb-hide="propertyName"></div>
[ "Hides", "an", "element", "by", "making", "it", "invisible", "but", "does", "not", "remove", "if", "from", "the", "layout", "of", "the", "page", "meaning", "a", "blank", "space", "will", "remain" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/AttributeBindings.js#L70-L75
44,711
mesmotronic/conbo
src/conbo/binding/AttributeBindings.js
function(el, value, options, styleName) { if (!styleName) { conbo.warn('cb-style attributes must specify one or more styles in the format cb-style="myProperty:style-name"'); } styleName = conbo.toCamelCase(styleName); el.style[styleName] = value; }
javascript
function(el, value, options, styleName) { if (!styleName) { conbo.warn('cb-style attributes must specify one or more styles in the format cb-style="myProperty:style-name"'); } styleName = conbo.toCamelCase(styleName); el.style[styleName] = value; }
[ "function", "(", "el", ",", "value", ",", "options", ",", "styleName", ")", "{", "if", "(", "!", "styleName", ")", "{", "conbo", ".", "warn", "(", "'cb-style attributes must specify one or more styles in the format cb-style=\"myProperty:style-name\"'", ")", ";", "}", "styleName", "=", "conbo", ".", "toCamelCase", "(", "styleName", ")", ";", "el", ".", "style", "[", "styleName", "]", "=", "value", ";", "}" ]
Apply styles from a variable @param {HTMLElement} el - DOM element to which the attribute applies @param {*} value - The value referenced by the attribute @param {Object} options - Options relating to this binding @param {string} styleName - The name of the style to bind @returns {void} @example <div cb-="propertyName:font-weight"></div>
[ "Apply", "styles", "from", "a", "variable" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/AttributeBindings.js#L223-L232
44,712
mesmotronic/conbo
src/conbo/binding/AttributeBindings.js
function(el, value, options) { var view = options.view; var states = value.split(' '); var stateChangeHandler = (function() { this.cbInclude(el, states.indexOf(view.currentState) != -1); }).bind(this); view.addEventListener('change:currentState', stateChangeHandler, this); stateChangeHandler.call(this); }
javascript
function(el, value, options) { var view = options.view; var states = value.split(' '); var stateChangeHandler = (function() { this.cbInclude(el, states.indexOf(view.currentState) != -1); }).bind(this); view.addEventListener('change:currentState', stateChangeHandler, this); stateChangeHandler.call(this); }
[ "function", "(", "el", ",", "value", ",", "options", ")", "{", "var", "view", "=", "options", ".", "view", ";", "var", "states", "=", "value", ".", "split", "(", "' '", ")", ";", "var", "stateChangeHandler", "=", "(", "function", "(", ")", "{", "this", ".", "cbInclude", "(", "el", ",", "states", ".", "indexOf", "(", "view", ".", "currentState", ")", "!=", "-", "1", ")", ";", "}", ")", ".", "bind", "(", "this", ")", ";", "view", ".", "addEventListener", "(", "'change:currentState'", ",", "stateChangeHandler", ",", "this", ")", ";", "stateChangeHandler", ".", "call", "(", "this", ")", ";", "}" ]
Only includes the specified element in the layout when the View's `currentState` matches one of the states listed in the attribute's value; multiple states should be separated by spaces @param {HTMLElement} el - DOM element to which the attribute applies @param {*} value - The value referenced by the attribute @param {Object} options - Options relating to this binding @returns {void} @example <div cb-include-in="happy sad elated"></div>
[ "Only", "includes", "the", "specified", "element", "in", "the", "layout", "when", "the", "View", "s", "currentState", "matches", "one", "of", "the", "states", "listed", "in", "the", "attribute", "s", "value", ";", "multiple", "states", "should", "be", "separated", "by", "spaces" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/AttributeBindings.js#L437-L449
44,713
mesmotronic/conbo
src/conbo/binding/AttributeBindings.js
function(el, value, options) { var view = options.view; var states = value.split(' '); var stateChangeHandler = function() { this.cbExclude(el, states.indexOf(view.currentState) != -1); }; view.addEventListener('change:currentState', stateChangeHandler, this); stateChangeHandler.call(this); }
javascript
function(el, value, options) { var view = options.view; var states = value.split(' '); var stateChangeHandler = function() { this.cbExclude(el, states.indexOf(view.currentState) != -1); }; view.addEventListener('change:currentState', stateChangeHandler, this); stateChangeHandler.call(this); }
[ "function", "(", "el", ",", "value", ",", "options", ")", "{", "var", "view", "=", "options", ".", "view", ";", "var", "states", "=", "value", ".", "split", "(", "' '", ")", ";", "var", "stateChangeHandler", "=", "function", "(", ")", "{", "this", ".", "cbExclude", "(", "el", ",", "states", ".", "indexOf", "(", "view", ".", "currentState", ")", "!=", "-", "1", ")", ";", "}", ";", "view", ".", "addEventListener", "(", "'change:currentState'", ",", "stateChangeHandler", ",", "this", ")", ";", "stateChangeHandler", ".", "call", "(", "this", ")", ";", "}" ]
Removes the specified element from the layout when the View's `currentState` matches one of the states listed in the attribute's value; multiple states should be separated by spaces @param {HTMLElement} el - DOM element to which the attribute applies @param {*} value - The value referenced by the attribute @param {Object} options - Options relating to this binding @returns {void} @example <div cb-exclude-from="confused frightened"></div>
[ "Removes", "the", "specified", "element", "from", "the", "layout", "when", "the", "View", "s", "currentState", "matches", "one", "of", "the", "states", "listed", "in", "the", "attribute", "s", "value", ";", "multiple", "states", "should", "be", "separated", "by", "spaces" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/AttributeBindings.js#L464-L476
44,714
mesmotronic/conbo
src/conbo/binding/AttributeBindings.js
function(el) { if (el.tagName == 'A') { el.onclick = function(event) { window.location = el.href; event.preventDefault(); return false; }; } }
javascript
function(el) { if (el.tagName == 'A') { el.onclick = function(event) { window.location = el.href; event.preventDefault(); return false; }; } }
[ "function", "(", "el", ")", "{", "if", "(", "el", ".", "tagName", "==", "'A'", ")", "{", "el", ".", "onclick", "=", "function", "(", "event", ")", "{", "window", ".", "location", "=", "el", ".", "href", ";", "event", ".", "preventDefault", "(", ")", ";", "return", "false", ";", "}", ";", "}", "}" ]
Uses JavaScript to open an anchor's HREF so that the link will open in an iOS WebView instead of Safari @param {HTMLElement} el - DOM element to which the attribute applies @returns {void} @example <div cb-jshref="propertyName"></div>
[ "Uses", "JavaScript", "to", "open", "an", "anchor", "s", "HREF", "so", "that", "the", "link", "will", "open", "in", "an", "iOS", "WebView", "instead", "of", "Safari" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/AttributeBindings.js#L542-L553
44,715
mesmotronic/conbo
src/conbo/binding/AttributeBindings.js
function(el, validator) { var validateFunction; switch (true) { case conbo.isFunction(validator): { validateFunction = validator; break; } case conbo.isString(validator): { validator = new RegExp(validator); } case conbo.isRegExp(validator): { validateFunction = function(value) { return validator.test(value); }; break; } } if (!conbo.isFunction(validateFunction)) { conbo.warn(validator+' cannot be used with cb-validate'); return; } var ep = __ep(el); var form = ep.closest('form'); var getClasses = function(regEx) { return function (classes) { return classes.split(/\s+/).filter(function(el) { return regEx.test(el); }) .join(' '); }; }; var validate = function() { // Form item var value = el.value || el.innerHTML , result = validateFunction(value) , valid = (result === true) , classes = [] ; classes.push(valid ? 'cb-valid' : 'cb-invalid'); if (conbo.isString(result)) { classes.push('cb-invalid-'+result); } ep.removeClass('cb-valid cb-invalid') .removeClass(getClasses(/^cb-invalid-/)) .addClass(classes.join(' ')) ; // Form if (form) { var fp = __ep(form); fp.removeClass('cb-valid cb-invalid') .removeClass(getClasses(/^cb-invalid-/)) ; if (valid) { valid = !form.querySelector('.cb-invalid'); if (valid) { conbo.toArray(form.querySelectorAll('[required]')).forEach(function(rEl) { if (!String(rEl.value || rEl.innerHTML).trim()) { valid = false; return false; } }); } } fp.addClass(valid ? 'cb-valid' : 'cb-invalid'); } }; ep.addEventListener('change input blur', validate); }
javascript
function(el, validator) { var validateFunction; switch (true) { case conbo.isFunction(validator): { validateFunction = validator; break; } case conbo.isString(validator): { validator = new RegExp(validator); } case conbo.isRegExp(validator): { validateFunction = function(value) { return validator.test(value); }; break; } } if (!conbo.isFunction(validateFunction)) { conbo.warn(validator+' cannot be used with cb-validate'); return; } var ep = __ep(el); var form = ep.closest('form'); var getClasses = function(regEx) { return function (classes) { return classes.split(/\s+/).filter(function(el) { return regEx.test(el); }) .join(' '); }; }; var validate = function() { // Form item var value = el.value || el.innerHTML , result = validateFunction(value) , valid = (result === true) , classes = [] ; classes.push(valid ? 'cb-valid' : 'cb-invalid'); if (conbo.isString(result)) { classes.push('cb-invalid-'+result); } ep.removeClass('cb-valid cb-invalid') .removeClass(getClasses(/^cb-invalid-/)) .addClass(classes.join(' ')) ; // Form if (form) { var fp = __ep(form); fp.removeClass('cb-valid cb-invalid') .removeClass(getClasses(/^cb-invalid-/)) ; if (valid) { valid = !form.querySelector('.cb-invalid'); if (valid) { conbo.toArray(form.querySelectorAll('[required]')).forEach(function(rEl) { if (!String(rEl.value || rEl.innerHTML).trim()) { valid = false; return false; } }); } } fp.addClass(valid ? 'cb-valid' : 'cb-invalid'); } }; ep.addEventListener('change input blur', validate); }
[ "function", "(", "el", ",", "validator", ")", "{", "var", "validateFunction", ";", "switch", "(", "true", ")", "{", "case", "conbo", ".", "isFunction", "(", "validator", ")", ":", "{", "validateFunction", "=", "validator", ";", "break", ";", "}", "case", "conbo", ".", "isString", "(", "validator", ")", ":", "{", "validator", "=", "new", "RegExp", "(", "validator", ")", ";", "}", "case", "conbo", ".", "isRegExp", "(", "validator", ")", ":", "{", "validateFunction", "=", "function", "(", "value", ")", "{", "return", "validator", ".", "test", "(", "value", ")", ";", "}", ";", "break", ";", "}", "}", "if", "(", "!", "conbo", ".", "isFunction", "(", "validateFunction", ")", ")", "{", "conbo", ".", "warn", "(", "validator", "+", "' cannot be used with cb-validate'", ")", ";", "return", ";", "}", "var", "ep", "=", "__ep", "(", "el", ")", ";", "var", "form", "=", "ep", ".", "closest", "(", "'form'", ")", ";", "var", "getClasses", "=", "function", "(", "regEx", ")", "{", "return", "function", "(", "classes", ")", "{", "return", "classes", ".", "split", "(", "/", "\\s+", "/", ")", ".", "filter", "(", "function", "(", "el", ")", "{", "return", "regEx", ".", "test", "(", "el", ")", ";", "}", ")", ".", "join", "(", "' '", ")", ";", "}", ";", "}", ";", "var", "validate", "=", "function", "(", ")", "{", "// Form item\r", "var", "value", "=", "el", ".", "value", "||", "el", ".", "innerHTML", ",", "result", "=", "validateFunction", "(", "value", ")", ",", "valid", "=", "(", "result", "===", "true", ")", ",", "classes", "=", "[", "]", ";", "classes", ".", "push", "(", "valid", "?", "'cb-valid'", ":", "'cb-invalid'", ")", ";", "if", "(", "conbo", ".", "isString", "(", "result", ")", ")", "{", "classes", ".", "push", "(", "'cb-invalid-'", "+", "result", ")", ";", "}", "ep", ".", "removeClass", "(", "'cb-valid cb-invalid'", ")", ".", "removeClass", "(", "getClasses", "(", "/", "^cb-invalid-", "/", ")", ")", ".", "addClass", "(", "classes", ".", "join", "(", "' '", ")", ")", ";", "// Form\r", "if", "(", "form", ")", "{", "var", "fp", "=", "__ep", "(", "form", ")", ";", "fp", ".", "removeClass", "(", "'cb-valid cb-invalid'", ")", ".", "removeClass", "(", "getClasses", "(", "/", "^cb-invalid-", "/", ")", ")", ";", "if", "(", "valid", ")", "{", "valid", "=", "!", "form", ".", "querySelector", "(", "'.cb-invalid'", ")", ";", "if", "(", "valid", ")", "{", "conbo", ".", "toArray", "(", "form", ".", "querySelectorAll", "(", "'[required]'", ")", ")", ".", "forEach", "(", "function", "(", "rEl", ")", "{", "if", "(", "!", "String", "(", "rEl", ".", "value", "||", "rEl", ".", "innerHTML", ")", ".", "trim", "(", ")", ")", "{", "valid", "=", "false", ";", "return", "false", ";", "}", "}", ")", ";", "}", "}", "fp", ".", "addClass", "(", "valid", "?", "'cb-valid'", ":", "'cb-invalid'", ")", ";", "}", "}", ";", "ep", ".", "addEventListener", "(", "'change input blur'", ",", "validate", ")", ";", "}" ]
Use a method or regex to validate a form element and apply a cb-valid or cb-invalid CSS class based on the outcome @param {HTMLElement} el - DOM element to which the attribute applies @param {Function} validator - The function referenced by the attribute @returns {void} @example <div cb-validate="functionName"></div>
[ "Use", "a", "method", "or", "regex", "to", "validate", "a", "form", "element", "and", "apply", "a", "cb", "-", "valid", "or", "cb", "-", "invalid", "CSS", "class", "based", "on", "the", "outcome" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/AttributeBindings.js#L612-L716
44,716
mesmotronic/conbo
src/conbo/binding/AttributeBindings.js
function(el, value) { // TODO Restrict to text input fields? if (el.cbRestrict) { el.removeEventListener('keypress', el.cbRestrict); } el.cbRestrict = function(event) { if (event.ctrlKey) { return; } var code = event.keyCode || event.which; var char = event.key || String.fromCharCode(code); var regExp = value; if (!conbo.isRegExp(regExp)) { regExp = new RegExp('['+regExp+']', 'g'); } if (!char.match(regExp)) { event.preventDefault(); } }; el.addEventListener('keypress', el.cbRestrict); }
javascript
function(el, value) { // TODO Restrict to text input fields? if (el.cbRestrict) { el.removeEventListener('keypress', el.cbRestrict); } el.cbRestrict = function(event) { if (event.ctrlKey) { return; } var code = event.keyCode || event.which; var char = event.key || String.fromCharCode(code); var regExp = value; if (!conbo.isRegExp(regExp)) { regExp = new RegExp('['+regExp+']', 'g'); } if (!char.match(regExp)) { event.preventDefault(); } }; el.addEventListener('keypress', el.cbRestrict); }
[ "function", "(", "el", ",", "value", ")", "{", "// TODO Restrict to text input fields?\r", "if", "(", "el", ".", "cbRestrict", ")", "{", "el", ".", "removeEventListener", "(", "'keypress'", ",", "el", ".", "cbRestrict", ")", ";", "}", "el", ".", "cbRestrict", "=", "function", "(", "event", ")", "{", "if", "(", "event", ".", "ctrlKey", ")", "{", "return", ";", "}", "var", "code", "=", "event", ".", "keyCode", "||", "event", ".", "which", ";", "var", "char", "=", "event", ".", "key", "||", "String", ".", "fromCharCode", "(", "code", ")", ";", "var", "regExp", "=", "value", ";", "if", "(", "!", "conbo", ".", "isRegExp", "(", "regExp", ")", ")", "{", "regExp", "=", "new", "RegExp", "(", "'['", "+", "regExp", "+", "']'", ",", "'g'", ")", ";", "}", "if", "(", "!", "char", ".", "match", "(", "regExp", ")", ")", "{", "event", ".", "preventDefault", "(", ")", ";", "}", "}", ";", "el", ".", "addEventListener", "(", "'keypress'", ",", "el", ".", "cbRestrict", ")", ";", "}" ]
Restricts text input to the specified characters @param {HTMLElement} el - DOM element to which the attribute applies @param {string} value - The value referenced by the attribute @returns {void} @example <div cb-restrict="propertyName"></div>
[ "Restricts", "text", "input", "to", "the", "specified", "characters" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/AttributeBindings.js#L728-L760
44,717
mesmotronic/conbo
src/conbo/binding/AttributeBindings.js
function(el, value) { // TODO Restrict to text input fields? if (el.cbMaxChars) { el.removeEventListener('keypress', el.cbMaxChars); } el.cbMaxChars = function(event) { if ((el.value || el.innerHTML).length >= value) { event.preventDefault(); } }; el.addEventListener('keypress', el.cbMaxChars); }
javascript
function(el, value) { // TODO Restrict to text input fields? if (el.cbMaxChars) { el.removeEventListener('keypress', el.cbMaxChars); } el.cbMaxChars = function(event) { if ((el.value || el.innerHTML).length >= value) { event.preventDefault(); } }; el.addEventListener('keypress', el.cbMaxChars); }
[ "function", "(", "el", ",", "value", ")", "{", "// TODO Restrict to text input fields?\r", "if", "(", "el", ".", "cbMaxChars", ")", "{", "el", ".", "removeEventListener", "(", "'keypress'", ",", "el", ".", "cbMaxChars", ")", ";", "}", "el", ".", "cbMaxChars", "=", "function", "(", "event", ")", "{", "if", "(", "(", "el", ".", "value", "||", "el", ".", "innerHTML", ")", ".", "length", ">=", "value", ")", "{", "event", ".", "preventDefault", "(", ")", ";", "}", "}", ";", "el", ".", "addEventListener", "(", "'keypress'", ",", "el", ".", "cbMaxChars", ")", ";", "}" ]
Limits the number of characters that can be entered into input and other form fields @param {HTMLElement} el - DOM element to which the attribute applies @param {string} value - The value referenced by the attribute @returns {void} @example <div cb-max-chars="propertyName"></div>
[ "Limits", "the", "number", "of", "characters", "that", "can", "be", "entered", "into", "input", "and", "other", "form", "fields" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/AttributeBindings.js#L773-L791
44,718
unshiftio/strategy
index.js
Policy
function Policy(name, Transport, options) { var policy = this; if ('string' !== typeof name) { options = Transport; Transport = name; name = undefined; } if ('function' !== typeof Transport) { throw new Error('Transport should be a constructor.'); } policy.name = (name || Transport.prototype.name).toLowerCase(); policy.Transport = Transport; policy.options = options || {}; policy.id = 0; }
javascript
function Policy(name, Transport, options) { var policy = this; if ('string' !== typeof name) { options = Transport; Transport = name; name = undefined; } if ('function' !== typeof Transport) { throw new Error('Transport should be a constructor.'); } policy.name = (name || Transport.prototype.name).toLowerCase(); policy.Transport = Transport; policy.options = options || {}; policy.id = 0; }
[ "function", "Policy", "(", "name", ",", "Transport", ",", "options", ")", "{", "var", "policy", "=", "this", ";", "if", "(", "'string'", "!==", "typeof", "name", ")", "{", "options", "=", "Transport", ";", "Transport", "=", "name", ";", "name", "=", "undefined", ";", "}", "if", "(", "'function'", "!==", "typeof", "Transport", ")", "{", "throw", "new", "Error", "(", "'Transport should be a constructor.'", ")", ";", "}", "policy", ".", "name", "=", "(", "name", "||", "Transport", ".", "prototype", ".", "name", ")", ".", "toLowerCase", "(", ")", ";", "policy", ".", "Transport", "=", "Transport", ";", "policy", ".", "options", "=", "options", "||", "{", "}", ";", "policy", ".", "id", "=", "0", ";", "}" ]
Representation of one single transport policy. @constructor @param {String} name Name of the policy @param {TransportLayer} Transport Constructor of a TransportLayer. @param {Object} options Options for the transport & strategy instructions. @api public
[ "Representation", "of", "one", "single", "transport", "policy", "." ]
61cda48f08c6479593caf5ea5675d5b8fd4b8c3c
https://github.com/unshiftio/strategy/blob/61cda48f08c6479593caf5ea5675d5b8fd4b8c3c/index.js#L12-L29
44,719
unshiftio/strategy
index.js
Strategy
function Strategy(transports, options) { var strategy = this; if (!(strategy instanceof Strategy)) return new Strategy(transports, options); if (Object.prototype.toString.call(transports) !== '[object Array]') { options = transports; transports = []; } strategy.transports = []; // List of active transports. strategy.transport = 0; // Current selected transport id. strategy.length = 0; // Amount of transports available. strategy.id = 0; // ID generation pool. for (var i = 0; i < transports.length; i++) { strategy.push(transports[i]); } }
javascript
function Strategy(transports, options) { var strategy = this; if (!(strategy instanceof Strategy)) return new Strategy(transports, options); if (Object.prototype.toString.call(transports) !== '[object Array]') { options = transports; transports = []; } strategy.transports = []; // List of active transports. strategy.transport = 0; // Current selected transport id. strategy.length = 0; // Amount of transports available. strategy.id = 0; // ID generation pool. for (var i = 0; i < transports.length; i++) { strategy.push(transports[i]); } }
[ "function", "Strategy", "(", "transports", ",", "options", ")", "{", "var", "strategy", "=", "this", ";", "if", "(", "!", "(", "strategy", "instanceof", "Strategy", ")", ")", "return", "new", "Strategy", "(", "transports", ",", "options", ")", ";", "if", "(", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "transports", ")", "!==", "'[object Array]'", ")", "{", "options", "=", "transports", ";", "transports", "=", "[", "]", ";", "}", "strategy", ".", "transports", "=", "[", "]", ";", "// List of active transports.", "strategy", ".", "transport", "=", "0", ";", "// Current selected transport id.", "strategy", ".", "length", "=", "0", ";", "// Amount of transports available.", "strategy", ".", "id", "=", "0", ";", "// ID generation pool.", "for", "(", "var", "i", "=", "0", ";", "i", "<", "transports", ".", "length", ";", "i", "++", ")", "{", "strategy", ".", "push", "(", "transports", "[", "i", "]", ")", ";", "}", "}" ]
Transport selection strategy. @constructor @param {Array} transports Array of transports that should be added. @param {Object} options Optional configuration. @api public
[ "Transport", "selection", "strategy", "." ]
61cda48f08c6479593caf5ea5675d5b8fd4b8c3c
https://github.com/unshiftio/strategy/blob/61cda48f08c6479593caf5ea5675d5b8fd4b8c3c/index.js#L39-L56
44,720
noderaider/react-load
lib/components/createSpinner.js
Segment
function Segment(props) { var segmentStyle = props.segmentStyle; var fillStyle = props.fillStyle; var commonStyle = { position: 'absolute' }; return React.createElement( 'div', { style: _extends({}, commonStyle, segmentStyle) }, React.createElement('div', { style: _extends({}, commonStyle, fillStyle) }) ); }
javascript
function Segment(props) { var segmentStyle = props.segmentStyle; var fillStyle = props.fillStyle; var commonStyle = { position: 'absolute' }; return React.createElement( 'div', { style: _extends({}, commonStyle, segmentStyle) }, React.createElement('div', { style: _extends({}, commonStyle, fillStyle) }) ); }
[ "function", "Segment", "(", "props", ")", "{", "var", "segmentStyle", "=", "props", ".", "segmentStyle", ";", "var", "fillStyle", "=", "props", ".", "fillStyle", ";", "var", "commonStyle", "=", "{", "position", ":", "'absolute'", "}", ";", "return", "React", ".", "createElement", "(", "'div'", ",", "{", "style", ":", "_extends", "(", "{", "}", ",", "commonStyle", ",", "segmentStyle", ")", "}", ",", "React", ".", "createElement", "(", "'div'", ",", "{", "style", ":", "_extends", "(", "{", "}", ",", "commonStyle", ",", "fillStyle", ")", "}", ")", ")", ";", "}" ]
React component for segments
[ "React", "component", "for", "segments" ]
70c4b42202c108aea99b1186e2a9f672dd10b26f
https://github.com/noderaider/react-load/blob/70c4b42202c108aea99b1186e2a9f672dd10b26f/lib/components/createSpinner.js#L75-L85
44,721
rasouli100/twimap
examples/thanker.js
load_followers_priodically
function load_followers_priodically() { try{ twimap.followersAsync(last_check, function(result) { if(typeof result != "undefined" && result.length >=1){ //save it in our variable _followers_list = result; last_check = now(); msg_followers_thanks(); } },function (err){ // I command you to stay silent reset_values(); }); }catch(e){ //still... reset_values(); console.log(e); } }
javascript
function load_followers_priodically() { try{ twimap.followersAsync(last_check, function(result) { if(typeof result != "undefined" && result.length >=1){ //save it in our variable _followers_list = result; last_check = now(); msg_followers_thanks(); } },function (err){ // I command you to stay silent reset_values(); }); }catch(e){ //still... reset_values(); console.log(e); } }
[ "function", "load_followers_priodically", "(", ")", "{", "try", "{", "twimap", ".", "followersAsync", "(", "last_check", ",", "function", "(", "result", ")", "{", "if", "(", "typeof", "result", "!=", "\"undefined\"", "&&", "result", ".", "length", ">=", "1", ")", "{", "//save it in our variable", "_followers_list", "=", "result", ";", "last_check", "=", "now", "(", ")", ";", "msg_followers_thanks", "(", ")", ";", "}", "}", ",", "function", "(", "err", ")", "{", "// I command you to stay silent", "reset_values", "(", ")", ";", "}", ")", ";", "}", "catch", "(", "e", ")", "{", "//still...", "reset_values", "(", ")", ";", "console", ".", "log", "(", "e", ")", ";", "}", "}" ]
call this function periodically to get new followers callback is called when new information is available
[ "call", "this", "function", "periodically", "to", "get", "new", "followers", "callback", "is", "called", "when", "new", "information", "is", "available" ]
90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7
https://github.com/rasouli100/twimap/blob/90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7/examples/thanker.js#L40-L63
44,722
rasouli100/twimap
examples/thanker.js
msg_followers_thanks
function msg_followers_thanks(){ //move cursor _current_index++; //if there is no followers OR finished messaging followers stop if(_current_index >= _followers_list.length ){ _current_index = -1; _followe_list = null; return; } //otherwise get user name from twitter twit_cli.get("users/show",{screen_name:_followers_list[_current_index]}, function (err,dt){ //clean up the name var dude = filter_name(dt.name); //message the user twit_cli.post("direct_messages/new" , {screen_name:_followers_list[_current_index],text:random_msg(dude)}, function (err,dt){ if(!err) console.log("done..."); //go for another round msg_followers_thanks(); }); }); }
javascript
function msg_followers_thanks(){ //move cursor _current_index++; //if there is no followers OR finished messaging followers stop if(_current_index >= _followers_list.length ){ _current_index = -1; _followe_list = null; return; } //otherwise get user name from twitter twit_cli.get("users/show",{screen_name:_followers_list[_current_index]}, function (err,dt){ //clean up the name var dude = filter_name(dt.name); //message the user twit_cli.post("direct_messages/new" , {screen_name:_followers_list[_current_index],text:random_msg(dude)}, function (err,dt){ if(!err) console.log("done..."); //go for another round msg_followers_thanks(); }); }); }
[ "function", "msg_followers_thanks", "(", ")", "{", "//move cursor", "_current_index", "++", ";", "//if there is no followers OR finished messaging followers stop", "if", "(", "_current_index", ">=", "_followers_list", ".", "length", ")", "{", "_current_index", "=", "-", "1", ";", "_followe_list", "=", "null", ";", "return", ";", "}", "//otherwise get user name from twitter ", "twit_cli", ".", "get", "(", "\"users/show\"", ",", "{", "screen_name", ":", "_followers_list", "[", "_current_index", "]", "}", ",", "function", "(", "err", ",", "dt", ")", "{", "//clean up the name", "var", "dude", "=", "filter_name", "(", "dt", ".", "name", ")", ";", "//message the user", "twit_cli", ".", "post", "(", "\"direct_messages/new\"", ",", "{", "screen_name", ":", "_followers_list", "[", "_current_index", "]", ",", "text", ":", "random_msg", "(", "dude", ")", "}", ",", "function", "(", "err", ",", "dt", ")", "{", "if", "(", "!", "err", ")", "console", ".", "log", "(", "\"done...\"", ")", ";", "//go for another round", "msg_followers_thanks", "(", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
this function iterates through followers listed in variable _followers_list
[ "this", "function", "iterates", "through", "followers", "listed", "in", "variable", "_followers_list" ]
90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7
https://github.com/rasouli100/twimap/blob/90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7/examples/thanker.js#L69-L96
44,723
rasouli100/twimap
examples/thanker.js
filter_name
function filter_name(name){ if ( typeof name == "undefined" || name=="" || name==null) name = "my friend"; if(name.length > 40 ) name = name.substr(0,40); return name; }
javascript
function filter_name(name){ if ( typeof name == "undefined" || name=="" || name==null) name = "my friend"; if(name.length > 40 ) name = name.substr(0,40); return name; }
[ "function", "filter_name", "(", "name", ")", "{", "if", "(", "typeof", "name", "==", "\"undefined\"", "||", "name", "==", "\"\"", "||", "name", "==", "null", ")", "name", "=", "\"my friend\"", ";", "if", "(", "name", ".", "length", ">", "40", ")", "name", "=", "name", ".", "substr", "(", "0", ",", "40", ")", ";", "return", "name", ";", "}" ]
cut names bigger that 40 characters
[ "cut", "names", "bigger", "that", "40", "characters" ]
90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7
https://github.com/rasouli100/twimap/blob/90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7/examples/thanker.js#L99-L103
44,724
rasouli100/twimap
examples/thanker.js
random_msg
function random_msg(name){ name = filter_name(name); return util.format(thanks_temp[Math.floor(Math.random()*10)%(thanks_temp.length-1)] , name); }
javascript
function random_msg(name){ name = filter_name(name); return util.format(thanks_temp[Math.floor(Math.random()*10)%(thanks_temp.length-1)] , name); }
[ "function", "random_msg", "(", "name", ")", "{", "name", "=", "filter_name", "(", "name", ")", ";", "return", "util", ".", "format", "(", "thanks_temp", "[", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "10", ")", "%", "(", "thanks_temp", ".", "length", "-", "1", ")", "]", ",", "name", ")", ";", "}" ]
generate a random message
[ "generate", "a", "random", "message" ]
90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7
https://github.com/rasouli100/twimap/blob/90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7/examples/thanker.js#L107-L110
44,725
DynoSRC/dynosrc
lib/patchit.js
function(next) { var source = config.getSource(asset.source); async.parallel([ getFromSource.bind(null, source, asset, fromVersion, config), getFromSource.bind(null, source, asset, toVersion, config) ], next); }
javascript
function(next) { var source = config.getSource(asset.source); async.parallel([ getFromSource.bind(null, source, asset, fromVersion, config), getFromSource.bind(null, source, asset, toVersion, config) ], next); }
[ "function", "(", "next", ")", "{", "var", "source", "=", "config", ".", "getSource", "(", "asset", ".", "source", ")", ";", "async", ".", "parallel", "(", "[", "getFromSource", ".", "bind", "(", "null", ",", "source", ",", "asset", ",", "fromVersion", ",", "config", ")", ",", "getFromSource", ".", "bind", "(", "null", ",", "source", ",", "asset", ",", "toVersion", ",", "config", ")", "]", ",", "next", ")", ";", "}" ]
get the source files to compare
[ "get", "the", "source", "files", "to", "compare" ]
1a763c9310b719a51b0df56387970ecd3f08c438
https://github.com/DynoSRC/dynosrc/blob/1a763c9310b719a51b0df56387970ecd3f08c438/lib/patchit.js#L183-L190
44,726
DynoSRC/dynosrc
lib/patchit.js
function(files, next) { var fromFile = files[0], toFile = files[1]; differ(id, fromFile, toFile, next); }
javascript
function(files, next) { var fromFile = files[0], toFile = files[1]; differ(id, fromFile, toFile, next); }
[ "function", "(", "files", ",", "next", ")", "{", "var", "fromFile", "=", "files", "[", "0", "]", ",", "toFile", "=", "files", "[", "1", "]", ";", "differ", "(", "id", ",", "fromFile", ",", "toFile", ",", "next", ")", ";", "}" ]
generate the patch
[ "generate", "the", "patch" ]
1a763c9310b719a51b0df56387970ecd3f08c438
https://github.com/DynoSRC/dynosrc/blob/1a763c9310b719a51b0df56387970ecd3f08c438/lib/patchit.js#L192-L197
44,727
DynoSRC/dynosrc
lib/patchit.js
function(patch, next) { var patchObj = toPatchObject(id, fromVersion, toVersion, patch); //cache it cacheCb(patchObj); next(null, patchObj); }
javascript
function(patch, next) { var patchObj = toPatchObject(id, fromVersion, toVersion, patch); //cache it cacheCb(patchObj); next(null, patchObj); }
[ "function", "(", "patch", ",", "next", ")", "{", "var", "patchObj", "=", "toPatchObject", "(", "id", ",", "fromVersion", ",", "toVersion", ",", "patch", ")", ";", "//cache it", "cacheCb", "(", "patchObj", ")", ";", "next", "(", "null", ",", "patchObj", ")", ";", "}" ]
output in structured format
[ "output", "in", "structured", "format" ]
1a763c9310b719a51b0df56387970ecd3f08c438
https://github.com/DynoSRC/dynosrc/blob/1a763c9310b719a51b0df56387970ecd3f08c438/lib/patchit.js#L199-L204
44,728
borela/themeable
src/__mocks__/data.js
combinedData
function combinedData(flairs, presenters) { let result = [] for (let [ flairPattern, normalizedFlair ] of flairs) { for (let [ presenterPattern, presenter ] of presenters) result.push([ `${flairPattern}!${presenterPattern}`, normalizedFlair, presenter ]) } return result }
javascript
function combinedData(flairs, presenters) { let result = [] for (let [ flairPattern, normalizedFlair ] of flairs) { for (let [ presenterPattern, presenter ] of presenters) result.push([ `${flairPattern}!${presenterPattern}`, normalizedFlair, presenter ]) } return result }
[ "function", "combinedData", "(", "flairs", ",", "presenters", ")", "{", "let", "result", "=", "[", "]", "for", "(", "let", "[", "flairPattern", ",", "normalizedFlair", "]", "of", "flairs", ")", "{", "for", "(", "let", "[", "presenterPattern", ",", "presenter", "]", "of", "presenters", ")", "result", ".", "push", "(", "[", "`", "${", "flairPattern", "}", "${", "presenterPattern", "}", "`", ",", "normalizedFlair", ",", "presenter", "]", ")", "}", "return", "result", "}" ]
Generate a dataset combining the flairs and presenters patterns.
[ "Generate", "a", "dataset", "combining", "the", "flairs", "and", "presenters", "patterns", "." ]
728b1216a925210687e4dd6f0c73f7ff5c795224
https://github.com/borela/themeable/blob/728b1216a925210687e4dd6f0c73f7ff5c795224/src/__mocks__/data.js#L44-L51
44,729
borela/themeable
src/__mocks__/data.js
joinFlairs
function joinFlairs(data) { let result = [] for (let [ targetStringArray, ...rest ] of data) { // Raw flair containing only one flair don’t need to be modified. if (targetStringArray.length < 2) { result.push([ targetStringArray, ...rest ]) continue } // Concatenate the flairs using one, two and three spaces. for (let i = 1; i <= 3; i++) { const SPACES = pad('', i) result.push([ targetStringArray.join(SPACES), ...rest ]) } } return result }
javascript
function joinFlairs(data) { let result = [] for (let [ targetStringArray, ...rest ] of data) { // Raw flair containing only one flair don’t need to be modified. if (targetStringArray.length < 2) { result.push([ targetStringArray, ...rest ]) continue } // Concatenate the flairs using one, two and three spaces. for (let i = 1; i <= 3; i++) { const SPACES = pad('', i) result.push([ targetStringArray.join(SPACES), ...rest ]) } } return result }
[ "function", "joinFlairs", "(", "data", ")", "{", "let", "result", "=", "[", "]", "for", "(", "let", "[", "targetStringArray", ",", "...", "rest", "]", "of", "data", ")", "{", "// Raw flair containing only one flair don’t need to be modified.", "if", "(", "targetStringArray", ".", "length", "<", "2", ")", "{", "result", ".", "push", "(", "[", "targetStringArray", ",", "...", "rest", "]", ")", "continue", "}", "// Concatenate the flairs using one, two and three spaces.", "for", "(", "let", "i", "=", "1", ";", "i", "<=", "3", ";", "i", "++", ")", "{", "const", "SPACES", "=", "pad", "(", "''", ",", "i", ")", "result", ".", "push", "(", "[", "targetStringArray", ".", "join", "(", "SPACES", ")", ",", "...", "rest", "]", ")", "}", "}", "return", "result", "}" ]
Used to join the raw flairs and generate the full data set.
[ "Used", "to", "join", "the", "raw", "flairs", "and", "generate", "the", "full", "data", "set", "." ]
728b1216a925210687e4dd6f0c73f7ff5c795224
https://github.com/borela/themeable/blob/728b1216a925210687e4dd6f0c73f7ff5c795224/src/__mocks__/data.js#L54-L69
44,730
borela/themeable
src/__mocks__/data.js
padData
function padData(data) { let result = [] for (let [ targetString, ...rest ] of data) { // We are testing for up to 3 spaces and for empty strings we’ll use this // condition to prevent duplicates. if (targetString === '') { result.push([ ' ', ...rest ]) result.push([ ' ', ...rest ]) result.push([ ' ', ...rest ]) continue } // Other strings, add up to 3 spaces to the left and right. for (let i = 1; i <= 3; i++) { const LENGHT = targetString.length // Add spaces to the right. result.push([ pad(targetString, LENGHT + i), ...rest ]) // Add spaces to the left. result.push([ pad(LENGHT + i, targetString), ...rest ]) } } return result }
javascript
function padData(data) { let result = [] for (let [ targetString, ...rest ] of data) { // We are testing for up to 3 spaces and for empty strings we’ll use this // condition to prevent duplicates. if (targetString === '') { result.push([ ' ', ...rest ]) result.push([ ' ', ...rest ]) result.push([ ' ', ...rest ]) continue } // Other strings, add up to 3 spaces to the left and right. for (let i = 1; i <= 3; i++) { const LENGHT = targetString.length // Add spaces to the right. result.push([ pad(targetString, LENGHT + i), ...rest ]) // Add spaces to the left. result.push([ pad(LENGHT + i, targetString), ...rest ]) } } return result }
[ "function", "padData", "(", "data", ")", "{", "let", "result", "=", "[", "]", "for", "(", "let", "[", "targetString", ",", "...", "rest", "]", "of", "data", ")", "{", "// We are testing for up to 3 spaces and for empty strings we’ll use this", "// condition to prevent duplicates.", "if", "(", "targetString", "===", "''", ")", "{", "result", ".", "push", "(", "[", "' '", ",", "...", "rest", "]", ")", "result", ".", "push", "(", "[", "' '", ",", "...", "rest", "]", ")", "result", ".", "push", "(", "[", "' '", ",", "...", "rest", "]", ")", "continue", "}", "// Other strings, add up to 3 spaces to the left and right.", "for", "(", "let", "i", "=", "1", ";", "i", "<=", "3", ";", "i", "++", ")", "{", "const", "LENGHT", "=", "targetString", ".", "length", "// Add spaces to the right.", "result", ".", "push", "(", "[", "pad", "(", "targetString", ",", "LENGHT", "+", "i", ")", ",", "...", "rest", "]", ")", "// Add spaces to the left.", "result", ".", "push", "(", "[", "pad", "(", "LENGHT", "+", "i", ",", "targetString", ")", ",", "...", "rest", "]", ")", "}", "}", "return", "result", "}" ]
Used to add spaces around the pattern.
[ "Used", "to", "add", "spaces", "around", "the", "pattern", "." ]
728b1216a925210687e4dd6f0c73f7ff5c795224
https://github.com/borela/themeable/blob/728b1216a925210687e4dd6f0c73f7ff5c795224/src/__mocks__/data.js#L72-L93
44,731
nodejitsu/contour
pagelets/footer.js
column
function column(options) { return this.navigation.slice(0, 5).reduce(function reduce(columns, section) { return columns + options.fn(section); }, ''); }
javascript
function column(options) { return this.navigation.slice(0, 5).reduce(function reduce(columns, section) { return columns + options.fn(section); }, ''); }
[ "function", "column", "(", "options", ")", "{", "return", "this", ".", "navigation", ".", "slice", "(", "0", ",", "5", ")", ".", "reduce", "(", "function", "reduce", "(", "columns", ",", "section", ")", "{", "return", "columns", "+", "options", ".", "fn", "(", "section", ")", ";", "}", ",", "''", ")", ";", "}" ]
Show the first five columns as footer sections. @param {Object} options @returns {String} rendered content @api public
[ "Show", "the", "first", "five", "columns", "as", "footer", "sections", "." ]
0828e9bd25ef1eeb97ea231c447118d9867021b6
https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/footer.js#L66-L70
44,732
nodejitsu/contour
pagelets/creditcard.js
month
function month(options) { var content = '' , m = this.month; while(++m <= 12) { content += options.fn({ month: m, selected: +this.expiration_month === m ? ' selected' : '', fullMonth: this.months[m - 1] }); } return content; }
javascript
function month(options) { var content = '' , m = this.month; while(++m <= 12) { content += options.fn({ month: m, selected: +this.expiration_month === m ? ' selected' : '', fullMonth: this.months[m - 1] }); } return content; }
[ "function", "month", "(", "options", ")", "{", "var", "content", "=", "''", ",", "m", "=", "this", ".", "month", ";", "while", "(", "++", "m", "<=", "12", ")", "{", "content", "+=", "options", ".", "fn", "(", "{", "month", ":", "m", ",", "selected", ":", "+", "this", ".", "expiration_month", "===", "m", "?", "' selected'", ":", "''", ",", "fullMonth", ":", "this", ".", "months", "[", "m", "-", "1", "]", "}", ")", ";", "}", "return", "content", ";", "}" ]
Handblebar helper to generate month dropdown select options. @param {Object} options @return {String} generated template @api private
[ "Handblebar", "helper", "to", "generate", "month", "dropdown", "select", "options", "." ]
0828e9bd25ef1eeb97ea231c447118d9867021b6
https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/creditcard.js#L46-L59
44,733
nodejitsu/contour
pagelets/creditcard.js
year
function year(options) { var content = '' , y = this.year; while(++y < this.max_year) { content += options.fn({ year: y, selected: +this.expiration_year === y ? ' selected' : '', }); } return content; }
javascript
function year(options) { var content = '' , y = this.year; while(++y < this.max_year) { content += options.fn({ year: y, selected: +this.expiration_year === y ? ' selected' : '', }); } return content; }
[ "function", "year", "(", "options", ")", "{", "var", "content", "=", "''", ",", "y", "=", "this", ".", "year", ";", "while", "(", "++", "y", "<", "this", ".", "max_year", ")", "{", "content", "+=", "options", ".", "fn", "(", "{", "year", ":", "y", ",", "selected", ":", "+", "this", ".", "expiration_year", "===", "y", "?", "' selected'", ":", "''", ",", "}", ")", ";", "}", "return", "content", ";", "}" ]
Handblebar helper to generate year dropdown select options. @param {Object} options @return {String} generated template @api private
[ "Handblebar", "helper", "to", "generate", "year", "dropdown", "select", "options", "." ]
0828e9bd25ef1eeb97ea231c447118d9867021b6
https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/creditcard.js#L68-L80
44,734
opensoars/f_
lib/getConstructor/index.js
f_Constructor
function f_Constructor(ins_o) { var self = this; // Sanitize instance options if (!ins_o || typeof ins_o !== 'object') { ins_o = {}; } if (!ins_o.custom_data || typeof ins_o.custom_data !== 'object') { ins_o.custom_data = {}; } // Apply instance modules and properties for (var module_name in f_instance_modules) { /* istanbul ignore else */ if (f_instance_modules.hasOwnProperty(module_name)) { self['f_' + module_name] = f_instance_modules[module_name]; } } // Apply instance options // Create data namespace, store name as f_data_namespace var data_namespace = con_o.data_namespace || ins_o.data_namespace || 'data'; self[data_namespace] = ins_o.custom_data; self.f_data_namespace = data_namespace; /** @TODO write desc for f_function_flow */ self.f_function_flow = []; for (var property_name in f_instance_properties) { /* istanbul ignore else */ if (f_instance_properties.hasOwnProperty(property_name)) { self['f_' + property_name] = f_instance_properties[property_name]; } } // Create instance function_flow, this in order to track tries con_o.function_flow.forEach(function (flow) { var new_flow_object = { tries: 0 }; for (var property in flow) { /* istanbul ignore else */ if (flow.hasOwnProperty(property)) { if (property !== 'function') { new_flow_object[property] = flow[property]; } } } self.f_function_flow.push(new_flow_object); }); // Finaly, call user specified initializer and pass the instance options // custom data as the first argument if (con_o.initializer) { con_o.initializer.apply(self, [ins_o.custom_data]); } }
javascript
function f_Constructor(ins_o) { var self = this; // Sanitize instance options if (!ins_o || typeof ins_o !== 'object') { ins_o = {}; } if (!ins_o.custom_data || typeof ins_o.custom_data !== 'object') { ins_o.custom_data = {}; } // Apply instance modules and properties for (var module_name in f_instance_modules) { /* istanbul ignore else */ if (f_instance_modules.hasOwnProperty(module_name)) { self['f_' + module_name] = f_instance_modules[module_name]; } } // Apply instance options // Create data namespace, store name as f_data_namespace var data_namespace = con_o.data_namespace || ins_o.data_namespace || 'data'; self[data_namespace] = ins_o.custom_data; self.f_data_namespace = data_namespace; /** @TODO write desc for f_function_flow */ self.f_function_flow = []; for (var property_name in f_instance_properties) { /* istanbul ignore else */ if (f_instance_properties.hasOwnProperty(property_name)) { self['f_' + property_name] = f_instance_properties[property_name]; } } // Create instance function_flow, this in order to track tries con_o.function_flow.forEach(function (flow) { var new_flow_object = { tries: 0 }; for (var property in flow) { /* istanbul ignore else */ if (flow.hasOwnProperty(property)) { if (property !== 'function') { new_flow_object[property] = flow[property]; } } } self.f_function_flow.push(new_flow_object); }); // Finaly, call user specified initializer and pass the instance options // custom data as the first argument if (con_o.initializer) { con_o.initializer.apply(self, [ins_o.custom_data]); } }
[ "function", "f_Constructor", "(", "ins_o", ")", "{", "var", "self", "=", "this", ";", "// Sanitize instance options", "if", "(", "!", "ins_o", "||", "typeof", "ins_o", "!==", "'object'", ")", "{", "ins_o", "=", "{", "}", ";", "}", "if", "(", "!", "ins_o", ".", "custom_data", "||", "typeof", "ins_o", ".", "custom_data", "!==", "'object'", ")", "{", "ins_o", ".", "custom_data", "=", "{", "}", ";", "}", "// Apply instance modules and properties", "for", "(", "var", "module_name", "in", "f_instance_modules", ")", "{", "/* istanbul ignore else */", "if", "(", "f_instance_modules", ".", "hasOwnProperty", "(", "module_name", ")", ")", "{", "self", "[", "'f_'", "+", "module_name", "]", "=", "f_instance_modules", "[", "module_name", "]", ";", "}", "}", "// Apply instance options", "// Create data namespace, store name as f_data_namespace", "var", "data_namespace", "=", "con_o", ".", "data_namespace", "||", "ins_o", ".", "data_namespace", "||", "'data'", ";", "self", "[", "data_namespace", "]", "=", "ins_o", ".", "custom_data", ";", "self", ".", "f_data_namespace", "=", "data_namespace", ";", "/** @TODO write desc for f_function_flow */", "self", ".", "f_function_flow", "=", "[", "]", ";", "for", "(", "var", "property_name", "in", "f_instance_properties", ")", "{", "/* istanbul ignore else */", "if", "(", "f_instance_properties", ".", "hasOwnProperty", "(", "property_name", ")", ")", "{", "self", "[", "'f_'", "+", "property_name", "]", "=", "f_instance_properties", "[", "property_name", "]", ";", "}", "}", "// Create instance function_flow, this in order to track tries", "con_o", ".", "function_flow", ".", "forEach", "(", "function", "(", "flow", ")", "{", "var", "new_flow_object", "=", "{", "tries", ":", "0", "}", ";", "for", "(", "var", "property", "in", "flow", ")", "{", "/* istanbul ignore else */", "if", "(", "flow", ".", "hasOwnProperty", "(", "property", ")", ")", "{", "if", "(", "property", "!==", "'function'", ")", "{", "new_flow_object", "[", "property", "]", "=", "flow", "[", "property", "]", ";", "}", "}", "}", "self", ".", "f_function_flow", ".", "push", "(", "new_flow_object", ")", ";", "}", ")", ";", "// Finaly, call user specified initializer and pass the instance options", "// custom data as the first argument", "if", "(", "con_o", ".", "initializer", ")", "{", "con_o", ".", "initializer", ".", "apply", "(", "self", ",", "[", "ins_o", ".", "custom_data", "]", ")", ";", "}", "}" ]
The constructor returned when getConstructor is called. @TODO Module this, split split! @constructor @param {object} ins_o - Instance options @example new f_Constructor({ a: 'b' }) // { a: 'b' }
[ "The", "constructor", "returned", "when", "getConstructor", "is", "called", "." ]
d96545de56d41db3d978dffd81b179f3ad5a62a6
https://github.com/opensoars/f_/blob/d96545de56d41db3d978dffd81b179f3ad5a62a6/lib/getConstructor/index.js#L40-L95
44,735
odogono/elsinore-js
src/query/limit.js
compile
function compile(context, commands) { let ii, cmd, limitOptions; // log.debug('limit: in-compile cmds:', commands); // look for the limit commands within the commands for (ii = commands.length - 1; ii >= 0; ii--) { cmd = commands[ii]; if (cmd[0] === LIMIT) { // cmdLimit = cmd; limitOptions = { offset: context.valueOf(cmd[2]), limit: context.valueOf(cmd[1]) }; commands.splice(ii, 1); } else if (limitOptions && cmd[0] === ENTITY_FILTER) { // set the options object of the entityFilter command if (limitOptions) { cmd[3] = { ...cmd[3], ...limitOptions }; } limitOptions = null; } } // if we still have an open limit and no entity filter was found, add one if (limitOptions) { commands.unshift([ENTITY_FILTER, null, null, limitOptions]); } return commands; }
javascript
function compile(context, commands) { let ii, cmd, limitOptions; // log.debug('limit: in-compile cmds:', commands); // look for the limit commands within the commands for (ii = commands.length - 1; ii >= 0; ii--) { cmd = commands[ii]; if (cmd[0] === LIMIT) { // cmdLimit = cmd; limitOptions = { offset: context.valueOf(cmd[2]), limit: context.valueOf(cmd[1]) }; commands.splice(ii, 1); } else if (limitOptions && cmd[0] === ENTITY_FILTER) { // set the options object of the entityFilter command if (limitOptions) { cmd[3] = { ...cmd[3], ...limitOptions }; } limitOptions = null; } } // if we still have an open limit and no entity filter was found, add one if (limitOptions) { commands.unshift([ENTITY_FILTER, null, null, limitOptions]); } return commands; }
[ "function", "compile", "(", "context", ",", "commands", ")", "{", "let", "ii", ",", "cmd", ",", "limitOptions", ";", "// log.debug('limit: in-compile cmds:', commands);", "// look for the limit commands within the commands", "for", "(", "ii", "=", "commands", ".", "length", "-", "1", ";", "ii", ">=", "0", ";", "ii", "--", ")", "{", "cmd", "=", "commands", "[", "ii", "]", ";", "if", "(", "cmd", "[", "0", "]", "===", "LIMIT", ")", "{", "// cmdLimit = cmd;", "limitOptions", "=", "{", "offset", ":", "context", ".", "valueOf", "(", "cmd", "[", "2", "]", ")", ",", "limit", ":", "context", ".", "valueOf", "(", "cmd", "[", "1", "]", ")", "}", ";", "commands", ".", "splice", "(", "ii", ",", "1", ")", ";", "}", "else", "if", "(", "limitOptions", "&&", "cmd", "[", "0", "]", "===", "ENTITY_FILTER", ")", "{", "// set the options object of the entityFilter command", "if", "(", "limitOptions", ")", "{", "cmd", "[", "3", "]", "=", "{", "...", "cmd", "[", "3", "]", ",", "...", "limitOptions", "}", ";", "}", "limitOptions", "=", "null", ";", "}", "}", "// if we still have an open limit and no entity filter was found, add one", "if", "(", "limitOptions", ")", "{", "commands", ".", "unshift", "(", "[", "ENTITY_FILTER", ",", "null", ",", "null", ",", "limitOptions", "]", ")", ";", "}", "return", "commands", ";", "}" ]
Compilation involves altering the previous entityfilter so that it receives the limit arguments
[ "Compilation", "involves", "altering", "the", "previous", "entityfilter", "so", "that", "it", "receives", "the", "limit", "arguments" ]
1ecce67ad0022646419a740def029b1ba92dd558
https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/query/limit.js#L59-L89
44,736
bminer/stride
stride.js
emitDone
function emitDone(rawArgs) { if(EventEmitter.listenerCount(emitter, "done") > 0) { var args = new Array(rawArgs.length + 1); args[0] = "done"; for(var i = 0; i < rawArgs.length; i++) args[i + 1] = rawArgs[i]; process.nextTick(function() { emitter.emit.apply(emitter, args); }); } }
javascript
function emitDone(rawArgs) { if(EventEmitter.listenerCount(emitter, "done") > 0) { var args = new Array(rawArgs.length + 1); args[0] = "done"; for(var i = 0; i < rawArgs.length; i++) args[i + 1] = rawArgs[i]; process.nextTick(function() { emitter.emit.apply(emitter, args); }); } }
[ "function", "emitDone", "(", "rawArgs", ")", "{", "if", "(", "EventEmitter", ".", "listenerCount", "(", "emitter", ",", "\"done\"", ")", ">", "0", ")", "{", "var", "args", "=", "new", "Array", "(", "rawArgs", ".", "length", "+", "1", ")", ";", "args", "[", "0", "]", "=", "\"done\"", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "rawArgs", ".", "length", ";", "i", "++", ")", "args", "[", "i", "+", "1", "]", "=", "rawArgs", "[", "i", "]", ";", "process", ".", "nextTick", "(", "function", "(", ")", "{", "emitter", ".", "emit", ".", "apply", "(", "emitter", ",", "args", ")", ";", "}", ")", ";", "}", "}" ]
Add function to the end to emit "done" event
[ "Add", "function", "to", "the", "end", "to", "emit", "done", "event" ]
62ba73ba09595e452563f59c77473fc33204880b
https://github.com/bminer/stride/blob/62ba73ba09595e452563f59c77473fc33204880b/stride.js#L270-L280
44,737
onecommons/base
lib/errorhandler.js
errorHandler
function errorHandler(err, req, res, next){ if (!req.suppressErrorHandlerConsole && !req.app.suppressErrorHandlerConsole) { if (req.log) { req.log.error(err, "Unhandled Error"); } else { console.log("Unhandled error"); console.log(err.stack || err); } } if (err.status) res.statusCode = err.status; if (res.statusCode < 400) res.statusCode = 500; if (res._header) return; //?? var accept = req.headers.accept || ''; var stack = req.app.get('env') != 'production' ? err.stack : ''; // html if (~accept.indexOf('html')) { res.render('error.html', { message: http.STATUS_CODES[res.statusCode], statusCode: res.statusCode, error: err.toString(), errorstack: (stack || '').split('\n').slice(1) }); // json } else if (~accept.indexOf('json')) { var error = { message: err.message, stack: stack }; for (var prop in err) error[prop] = err[prop]; res.json({ error: error }); // plain text } else { res.setHeader('Content-Type', 'text/plain'); res.end(stack); } }
javascript
function errorHandler(err, req, res, next){ if (!req.suppressErrorHandlerConsole && !req.app.suppressErrorHandlerConsole) { if (req.log) { req.log.error(err, "Unhandled Error"); } else { console.log("Unhandled error"); console.log(err.stack || err); } } if (err.status) res.statusCode = err.status; if (res.statusCode < 400) res.statusCode = 500; if (res._header) return; //?? var accept = req.headers.accept || ''; var stack = req.app.get('env') != 'production' ? err.stack : ''; // html if (~accept.indexOf('html')) { res.render('error.html', { message: http.STATUS_CODES[res.statusCode], statusCode: res.statusCode, error: err.toString(), errorstack: (stack || '').split('\n').slice(1) }); // json } else if (~accept.indexOf('json')) { var error = { message: err.message, stack: stack }; for (var prop in err) error[prop] = err[prop]; res.json({ error: error }); // plain text } else { res.setHeader('Content-Type', 'text/plain'); res.end(stack); } }
[ "function", "errorHandler", "(", "err", ",", "req", ",", "res", ",", "next", ")", "{", "if", "(", "!", "req", ".", "suppressErrorHandlerConsole", "&&", "!", "req", ".", "app", ".", "suppressErrorHandlerConsole", ")", "{", "if", "(", "req", ".", "log", ")", "{", "req", ".", "log", ".", "error", "(", "err", ",", "\"Unhandled Error\"", ")", ";", "}", "else", "{", "console", ".", "log", "(", "\"Unhandled error\"", ")", ";", "console", ".", "log", "(", "err", ".", "stack", "||", "err", ")", ";", "}", "}", "if", "(", "err", ".", "status", ")", "res", ".", "statusCode", "=", "err", ".", "status", ";", "if", "(", "res", ".", "statusCode", "<", "400", ")", "res", ".", "statusCode", "=", "500", ";", "if", "(", "res", ".", "_header", ")", "return", ";", "//??", "var", "accept", "=", "req", ".", "headers", ".", "accept", "||", "''", ";", "var", "stack", "=", "req", ".", "app", ".", "get", "(", "'env'", ")", "!=", "'production'", "?", "err", ".", "stack", ":", "''", ";", "// html", "if", "(", "~", "accept", ".", "indexOf", "(", "'html'", ")", ")", "{", "res", ".", "render", "(", "'error.html'", ",", "{", "message", ":", "http", ".", "STATUS_CODES", "[", "res", ".", "statusCode", "]", ",", "statusCode", ":", "res", ".", "statusCode", ",", "error", ":", "err", ".", "toString", "(", ")", ",", "errorstack", ":", "(", "stack", "||", "''", ")", ".", "split", "(", "'\\n'", ")", ".", "slice", "(", "1", ")", "}", ")", ";", "// json", "}", "else", "if", "(", "~", "accept", ".", "indexOf", "(", "'json'", ")", ")", "{", "var", "error", "=", "{", "message", ":", "err", ".", "message", ",", "stack", ":", "stack", "}", ";", "for", "(", "var", "prop", "in", "err", ")", "error", "[", "prop", "]", "=", "err", "[", "prop", "]", ";", "res", ".", "json", "(", "{", "error", ":", "error", "}", ")", ";", "// plain text", "}", "else", "{", "res", ".", "setHeader", "(", "'Content-Type'", ",", "'text/plain'", ")", ";", "res", ".", "end", "(", "stack", ")", ";", "}", "}" ]
derived from "errorhandler" package
[ "derived", "from", "errorhandler", "package" ]
4f35d9f714d0367b0622a3504802363404290246
https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/lib/errorhandler.js#L4-L36
44,738
vid/SenseBase
index.js
setup
function setup(context) { if (GLOBAL.config) { console.log('already configured'); console.trace(); return; } if (!context) { context = require('./config.js'); } GLOBAL.config = context.config; var svc = { pubsub: pubsub, auth: auth, indexer: indexer, pageCache: pageCache }; GLOBAL.svc = svc; auth.setupUsers(GLOBAL, context.logins); }
javascript
function setup(context) { if (GLOBAL.config) { console.log('already configured'); console.trace(); return; } if (!context) { context = require('./config.js'); } GLOBAL.config = context.config; var svc = { pubsub: pubsub, auth: auth, indexer: indexer, pageCache: pageCache }; GLOBAL.svc = svc; auth.setupUsers(GLOBAL, context.logins); }
[ "function", "setup", "(", "context", ")", "{", "if", "(", "GLOBAL", ".", "config", ")", "{", "console", ".", "log", "(", "'already configured'", ")", ";", "console", ".", "trace", "(", ")", ";", "return", ";", "}", "if", "(", "!", "context", ")", "{", "context", "=", "require", "(", "'./config.js'", ")", ";", "}", "GLOBAL", ".", "config", "=", "context", ".", "config", ";", "var", "svc", "=", "{", "pubsub", ":", "pubsub", ",", "auth", ":", "auth", ",", "indexer", ":", "indexer", ",", "pageCache", ":", "pageCache", "}", ";", "GLOBAL", ".", "svc", "=", "svc", ";", "auth", ".", "setupUsers", "(", "GLOBAL", ",", "context", ".", "logins", ")", ";", "}" ]
Set up the GLOBAL environment with configuration and services Defaults to directory config and users if no context is passed. pubsub will need to be started on its own.
[ "Set", "up", "the", "GLOBAL", "environment", "with", "configuration", "and", "services", "Defaults", "to", "directory", "config", "and", "users", "if", "no", "context", "is", "passed", ".", "pubsub", "will", "need", "to", "be", "started", "on", "its", "own", "." ]
d60bcf28239e7dde437d8a6bdae41a6921dcd05b
https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/index.js#L65-L81
44,739
pierrec/node-ekam
lib/include.js
setParents
function setParents () { var q = async.queue(processFile, 1) q.drain = function () { self.emit('drain') } // Process files with no dependency first self.nodeps.forEach( q.push ) function processFile (item, cb) { debug('dep:', item.id) // Add files with no dependency left to be processed self.deps .forEach(function (file) { if ( file.count > 0 && file.deps.indexOf(item.id) >= 0 ) { item.parents.push(file.id) file.count-- debug('file %s -> %d', file.id, file.count) if (file.count === 0) q.push(file) } }) cb() } }
javascript
function setParents () { var q = async.queue(processFile, 1) q.drain = function () { self.emit('drain') } // Process files with no dependency first self.nodeps.forEach( q.push ) function processFile (item, cb) { debug('dep:', item.id) // Add files with no dependency left to be processed self.deps .forEach(function (file) { if ( file.count > 0 && file.deps.indexOf(item.id) >= 0 ) { item.parents.push(file.id) file.count-- debug('file %s -> %d', file.id, file.count) if (file.count === 0) q.push(file) } }) cb() } }
[ "function", "setParents", "(", ")", "{", "var", "q", "=", "async", ".", "queue", "(", "processFile", ",", "1", ")", "q", ".", "drain", "=", "function", "(", ")", "{", "self", ".", "emit", "(", "'drain'", ")", "}", "// Process files with no dependency first", "self", ".", "nodeps", ".", "forEach", "(", "q", ".", "push", ")", "function", "processFile", "(", "item", ",", "cb", ")", "{", "debug", "(", "'dep:'", ",", "item", ".", "id", ")", "// Add files with no dependency left to be processed", "self", ".", "deps", ".", "forEach", "(", "function", "(", "file", ")", "{", "if", "(", "file", ".", "count", ">", "0", "&&", "file", ".", "deps", ".", "indexOf", "(", "item", ".", "id", ")", ">=", "0", ")", "{", "item", ".", "parents", ".", "push", "(", "file", ".", "id", ")", "file", ".", "count", "--", "debug", "(", "'file %s -> %d'", ",", "file", ".", "id", ",", "file", ".", "count", ")", "if", "(", "file", ".", "count", "===", "0", ")", "q", ".", "push", "(", "file", ")", "}", "}", ")", "cb", "(", ")", "}", "}" ]
Once all files are loaded, set their parents
[ "Once", "all", "files", "are", "loaded", "set", "their", "parents" ]
fd36038231c4f49ecae36e25352138cba0ac11aa
https://github.com/pierrec/node-ekam/blob/fd36038231c4f49ecae36e25352138cba0ac11aa/lib/include.js#L71-L92
44,740
theworkers/W.js
build/W.node.js
bind
function bind( fn, scope ) { var bound, args; if ( fn.bind === nativeBind && nativeBind ) return nativeBind.apply( fn, Array.prototype.slice.call( arguments, 1 ) ); args = Array.prototype.slice.call( arguments, 2 ); // @todo: don't link this bound = function() { if ( !(this instanceof bound) ) return fn.apply( scope, args.concat( Array.prototype.slice.call( arguments ) ) ); W.ctor.prototype = fn.prototype; var self = new ctor(); var result = fn.apply( self, args.concat( Array.prototype.slice.call( arguments ) ) ); if ( Object( result ) === result ) return result; return self; }; return bound; }
javascript
function bind( fn, scope ) { var bound, args; if ( fn.bind === nativeBind && nativeBind ) return nativeBind.apply( fn, Array.prototype.slice.call( arguments, 1 ) ); args = Array.prototype.slice.call( arguments, 2 ); // @todo: don't link this bound = function() { if ( !(this instanceof bound) ) return fn.apply( scope, args.concat( Array.prototype.slice.call( arguments ) ) ); W.ctor.prototype = fn.prototype; var self = new ctor(); var result = fn.apply( self, args.concat( Array.prototype.slice.call( arguments ) ) ); if ( Object( result ) === result ) return result; return self; }; return bound; }
[ "function", "bind", "(", "fn", ",", "scope", ")", "{", "var", "bound", ",", "args", ";", "if", "(", "fn", ".", "bind", "===", "nativeBind", "&&", "nativeBind", ")", "return", "nativeBind", ".", "apply", "(", "fn", ",", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", ")", ";", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "2", ")", ";", "// @todo: don't link this", "bound", "=", "function", "(", ")", "{", "if", "(", "!", "(", "this", "instanceof", "bound", ")", ")", "return", "fn", ".", "apply", "(", "scope", ",", "args", ".", "concat", "(", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ")", ")", ";", "W", ".", "ctor", ".", "prototype", "=", "fn", ".", "prototype", ";", "var", "self", "=", "new", "ctor", "(", ")", ";", "var", "result", "=", "fn", ".", "apply", "(", "self", ",", "args", ".", "concat", "(", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ")", ")", ";", "if", "(", "Object", "(", "result", ")", "===", "result", ")", "return", "result", ";", "return", "self", ";", "}", ";", "return", "bound", ";", "}" ]
Bind function to scope. Useful for events. @param {Function} fn function @param {Object} scope Scope of the function to be executed in @example $("div").fadeIn(100, W.bind(this, this.transitionDidFinish));
[ "Bind", "function", "to", "scope", ".", "Useful", "for", "events", "." ]
25a11baf8edb27c306f2baf6438bed2faf935bc6
https://github.com/theworkers/W.js/blob/25a11baf8edb27c306f2baf6438bed2faf935bc6/build/W.node.js#L17-L31
44,741
theworkers/W.js
build/W.node.js
Route
function Route(method, path, callbacks, options) { options = options || {}; this.path = path; this.method = method; this.callbacks = callbacks; this.regexp = pathRegexp(path, this.keys = [], options.sensitive, options.strict); }
javascript
function Route(method, path, callbacks, options) { options = options || {}; this.path = path; this.method = method; this.callbacks = callbacks; this.regexp = pathRegexp(path, this.keys = [], options.sensitive, options.strict); }
[ "function", "Route", "(", "method", ",", "path", ",", "callbacks", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "this", ".", "path", "=", "path", ";", "this", ".", "method", "=", "method", ";", "this", ".", "callbacks", "=", "callbacks", ";", "this", ".", "regexp", "=", "pathRegexp", "(", "path", ",", "this", ".", "keys", "=", "[", "]", ",", "options", ".", "sensitive", ",", "options", ".", "strict", ")", ";", "}" ]
Initialize `Route` with the given HTTP `method`, `path`, and an array of `callbacks` and `options`. Options: - `sensitive` enable case-sensitive routes - `strict` enable strict matching for trailing slashes @param {String} method @param {String} path @param {Array} callbacks @param {Object} options. @api private
[ "Initialize", "Route", "with", "the", "given", "HTTP", "method", "path", "and", "an", "array", "of", "callbacks", "and", "options", "." ]
25a11baf8edb27c306f2baf6438bed2faf935bc6
https://github.com/theworkers/W.js/blob/25a11baf8edb27c306f2baf6438bed2faf935bc6/build/W.node.js#L923-L929
44,742
theworkers/W.js
build/W.node.js
function () { if (this._intervalId) { clearInterval(this._intervalId); this._intervalId = undefined; this.trigger(this.options.stoppedEventName, this); return true; } return false; }
javascript
function () { if (this._intervalId) { clearInterval(this._intervalId); this._intervalId = undefined; this.trigger(this.options.stoppedEventName, this); return true; } return false; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "_intervalId", ")", "{", "clearInterval", "(", "this", ".", "_intervalId", ")", ";", "this", ".", "_intervalId", "=", "undefined", ";", "this", ".", "trigger", "(", "this", ".", "options", ".", "stoppedEventName", ",", "this", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Blackberry uses stop
[ "Blackberry", "uses", "stop" ]
25a11baf8edb27c306f2baf6438bed2faf935bc6
https://github.com/theworkers/W.js/blob/25a11baf8edb27c306f2baf6438bed2faf935bc6/build/W.node.js#L1132-L1140
44,743
vail-systems/node-signal-windows
src/framer.js
function(bufferOrArray, callback) { var self = this, ix = this.offset, frame = [], isArray = Object.prototype.toString.call( bufferOrArray) === '[object Array]'; self.frameIx = 0; while (ix < bufferOrArray.length) { var value = isArray ? bufferOrArray[ix] : bufferOrArray['read' + self.sampleType](ix); frame.push(this.map ? this.map[value] : value); if (frame.length == this.frameSize || ix+self.wordSize == bufferOrArray.length) finishFrame(frame); ix += self.wordSize; } // Did we not process any frames at all for some reason? if (this.frameIx == 0) callback(undefined); function finishFrame(frame) { if (this.scale) frame = frame.map(function (s, ix) {return s * self.scale[ix];}); callback(frame, self.frameIx); if (ix != bufferOrArray.length - self.wordSize) { ix -= (self.frameSize - self.frameStep) * self.wordSize; self.frameIx++; frame.length = 0; } } }
javascript
function(bufferOrArray, callback) { var self = this, ix = this.offset, frame = [], isArray = Object.prototype.toString.call( bufferOrArray) === '[object Array]'; self.frameIx = 0; while (ix < bufferOrArray.length) { var value = isArray ? bufferOrArray[ix] : bufferOrArray['read' + self.sampleType](ix); frame.push(this.map ? this.map[value] : value); if (frame.length == this.frameSize || ix+self.wordSize == bufferOrArray.length) finishFrame(frame); ix += self.wordSize; } // Did we not process any frames at all for some reason? if (this.frameIx == 0) callback(undefined); function finishFrame(frame) { if (this.scale) frame = frame.map(function (s, ix) {return s * self.scale[ix];}); callback(frame, self.frameIx); if (ix != bufferOrArray.length - self.wordSize) { ix -= (self.frameSize - self.frameStep) * self.wordSize; self.frameIx++; frame.length = 0; } } }
[ "function", "(", "bufferOrArray", ",", "callback", ")", "{", "var", "self", "=", "this", ",", "ix", "=", "this", ".", "offset", ",", "frame", "=", "[", "]", ",", "isArray", "=", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "bufferOrArray", ")", "===", "'[object Array]'", ";", "self", ".", "frameIx", "=", "0", ";", "while", "(", "ix", "<", "bufferOrArray", ".", "length", ")", "{", "var", "value", "=", "isArray", "?", "bufferOrArray", "[", "ix", "]", ":", "bufferOrArray", "[", "'read'", "+", "self", ".", "sampleType", "]", "(", "ix", ")", ";", "frame", ".", "push", "(", "this", ".", "map", "?", "this", ".", "map", "[", "value", "]", ":", "value", ")", ";", "if", "(", "frame", ".", "length", "==", "this", ".", "frameSize", "||", "ix", "+", "self", ".", "wordSize", "==", "bufferOrArray", ".", "length", ")", "finishFrame", "(", "frame", ")", ";", "ix", "+=", "self", ".", "wordSize", ";", "}", "// Did we not process any frames at all for some reason?", "if", "(", "this", ".", "frameIx", "==", "0", ")", "callback", "(", "undefined", ")", ";", "function", "finishFrame", "(", "frame", ")", "{", "if", "(", "this", ".", "scale", ")", "frame", "=", "frame", ".", "map", "(", "function", "(", "s", ",", "ix", ")", "{", "return", "s", "*", "self", ".", "scale", "[", "ix", "]", ";", "}", ")", ";", "callback", "(", "frame", ",", "self", ".", "frameIx", ")", ";", "if", "(", "ix", "!=", "bufferOrArray", ".", "length", "-", "self", ".", "wordSize", ")", "{", "ix", "-=", "(", "self", ".", "frameSize", "-", "self", ".", "frameStep", ")", "*", "self", ".", "wordSize", ";", "self", ".", "frameIx", "++", ";", "frame", ".", "length", "=", "0", ";", "}", "}", "}" ]
Frames a buffer of single-byte char values or an array of Numbers into windows of the specified size.
[ "Frames", "a", "buffer", "of", "single", "-", "byte", "char", "values", "or", "an", "array", "of", "Numbers", "into", "windows", "of", "the", "specified", "size", "." ]
b6ad09e6a735b69cbe5ed4e6def4b1d00e1d7256
https://github.com/vail-systems/node-signal-windows/blob/b6ad09e6a735b69cbe5ed4e6def4b1d00e1d7256/src/framer.js#L24-L58
44,744
yawetse/bindie
lib/bindie.js
function (options) { events.EventEmitter.call(this); var defaultOptions = { ejsdelimiter: '?', strictbinding:false }; this.options = extend(defaultOptions, options); ejs.delimiter = this.options.ejsdelimiter; this.binders = {}; this.update = this._update; this.render = this._render; this.addBinder = this._addBinder; }
javascript
function (options) { events.EventEmitter.call(this); var defaultOptions = { ejsdelimiter: '?', strictbinding:false }; this.options = extend(defaultOptions, options); ejs.delimiter = this.options.ejsdelimiter; this.binders = {}; this.update = this._update; this.render = this._render; this.addBinder = this._addBinder; }
[ "function", "(", "options", ")", "{", "events", ".", "EventEmitter", ".", "call", "(", "this", ")", ";", "var", "defaultOptions", "=", "{", "ejsdelimiter", ":", "'?'", ",", "strictbinding", ":", "false", "}", ";", "this", ".", "options", "=", "extend", "(", "defaultOptions", ",", "options", ")", ";", "ejs", ".", "delimiter", "=", "this", ".", "options", ".", "ejsdelimiter", ";", "this", ".", "binders", "=", "{", "}", ";", "this", ".", "update", "=", "this", ".", "_update", ";", "this", ".", "render", "=", "this", ".", "_render", ";", "this", ".", "addBinder", "=", "this", ".", "_addBinder", ";", "}" ]
A module that represents a bindie object, a componentTab is a page composition tool. @{@link https://github.com/typesettin/bindie} @author Yaw Joseph Etse @copyright Copyright (c) 2014 Typesettin. All rights reserved. @license MIT @constructor bindie @requires module:ejs @requires module:events @requires module:util-extend @requires module:util @param {object} el element of tab container @param {object} options configuration options
[ "A", "module", "that", "represents", "a", "bindie", "object", "a", "componentTab", "is", "a", "page", "composition", "tool", "." ]
83173e654e210953636fa86d1b7a3b1b6a92f2ed
https://github.com/yawetse/bindie/blob/83173e654e210953636fa86d1b7a3b1b6a92f2ed/lib/bindie.js#L28-L42
44,745
Stitchuuuu/thread-promisify
util.js
copyArguments
function copyArguments(args) { var copy = []; for (var i = 0; i < args.length; i++) { copy.push(args[i]); } return copy; }
javascript
function copyArguments(args) { var copy = []; for (var i = 0; i < args.length; i++) { copy.push(args[i]); } return copy; }
[ "function", "copyArguments", "(", "args", ")", "{", "var", "copy", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "{", "copy", ".", "push", "(", "args", "[", "i", "]", ")", ";", "}", "return", "copy", ";", "}" ]
Copy arguments in a clean classic array
[ "Copy", "arguments", "in", "a", "clean", "classic", "array" ]
5c6fc0b481520049e2078461693ceee7c27ddd53
https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/util.js#L98-L104
44,746
Stitchuuuu/thread-promisify
util.js
executeSerializedFunction
function executeSerializedFunction(id, args) { SerializedFunctions.forEach(function(sf) { if (sf.id == id) { sf.func.apply(null, args); } }); }
javascript
function executeSerializedFunction(id, args) { SerializedFunctions.forEach(function(sf) { if (sf.id == id) { sf.func.apply(null, args); } }); }
[ "function", "executeSerializedFunction", "(", "id", ",", "args", ")", "{", "SerializedFunctions", ".", "forEach", "(", "function", "(", "sf", ")", "{", "if", "(", "sf", ".", "id", "==", "id", ")", "{", "sf", ".", "func", ".", "apply", "(", "null", ",", "args", ")", ";", "}", "}", ")", ";", "}" ]
Execute a serialized function with an id Those are for progress functions, don't use Promise it will not be checked
[ "Execute", "a", "serialized", "function", "with", "an", "id", "Those", "are", "for", "progress", "functions", "don", "t", "use", "Promise", "it", "will", "not", "be", "checked" ]
5c6fc0b481520049e2078461693ceee7c27ddd53
https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/util.js#L110-L116
44,747
socialally/air
lib/air/hidden.js
hidden
function hidden(val) { // return whether the first element in the set // is hidden if(val === undefined) { return this.attr(attr); // hide on truthy }else if(val) { this.attr(attr, '1'); // show on falsey }else{ this.attr(attr, null); } return this; }
javascript
function hidden(val) { // return whether the first element in the set // is hidden if(val === undefined) { return this.attr(attr); // hide on truthy }else if(val) { this.attr(attr, '1'); // show on falsey }else{ this.attr(attr, null); } return this; }
[ "function", "hidden", "(", "val", ")", "{", "// return whether the first element in the set", "// is hidden", "if", "(", "val", "===", "undefined", ")", "{", "return", "this", ".", "attr", "(", "attr", ")", ";", "// hide on truthy", "}", "else", "if", "(", "val", ")", "{", "this", ".", "attr", "(", "attr", ",", "'1'", ")", ";", "// show on falsey", "}", "else", "{", "this", ".", "attr", "(", "attr", ",", "null", ")", ";", "}", "return", "this", ";", "}" ]
Modify the hidden attribute.
[ "Modify", "the", "hidden", "attribute", "." ]
a3d94de58aaa4930a425fbcc7266764bf6ca8ca6
https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/hidden.js#L6-L19
44,748
nodejitsu/contour
pagelets/nodejitsu/tooltip/base.js
function (element) { var left = 0 , top = 0; do { left += element.offsetLeft; top += element.offsetTop; } while (element = element.offsetParent); return { left: left, top: top }; }
javascript
function (element) { var left = 0 , top = 0; do { left += element.offsetLeft; top += element.offsetTop; } while (element = element.offsetParent); return { left: left, top: top }; }
[ "function", "(", "element", ")", "{", "var", "left", "=", "0", ",", "top", "=", "0", ";", "do", "{", "left", "+=", "element", ".", "offsetLeft", ";", "top", "+=", "element", ".", "offsetTop", ";", "}", "while", "(", "element", "=", "element", ".", "offsetParent", ")", ";", "return", "{", "left", ":", "left", ",", "top", ":", "top", "}", ";", "}" ]
Calculate the position of the current element that acted as trigger. Used for proper position of the tooltip. @param {Object} element @return {Object} offsets top and left @api private
[ "Calculate", "the", "position", "of", "the", "current", "element", "that", "acted", "as", "trigger", ".", "Used", "for", "proper", "position", "of", "the", "tooltip", "." ]
0828e9bd25ef1eeb97ea231c447118d9867021b6
https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/tooltip/base.js#L70-L83
44,749
nodejitsu/contour
pagelets/nodejitsu/tooltip/base.js
trigger
function trigger(event, target) { target = target || event.type; if (target === 'mouseout') target = 'mouseover'; return target === $(event.element).get('data-trigger'); }
javascript
function trigger(event, target) { target = target || event.type; if (target === 'mouseout') target = 'mouseover'; return target === $(event.element).get('data-trigger'); }
[ "function", "trigger", "(", "event", ",", "target", ")", "{", "target", "=", "target", "||", "event", ".", "type", ";", "if", "(", "target", "===", "'mouseout'", ")", "target", "=", "'mouseover'", ";", "return", "target", "===", "$", "(", "event", ".", "element", ")", ".", "get", "(", "'data-trigger'", ")", ";", "}" ]
Should this event trigger the tooltip? @param {Event} event @param {String} target compare to type of target @returns {Boolean} @api private
[ "Should", "this", "event", "trigger", "the", "tooltip?" ]
0828e9bd25ef1eeb97ea231c447118d9867021b6
https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/tooltip/base.js#L93-L98
44,750
nodejitsu/contour
pagelets/nodejitsu/tooltip/base.js
create
function create(event) { if (!this.trigger(event)) return; if ('preventDefault' in event) event.preventDefault(); if (this.trigger(event, 'click') && this.remove(event)) return; // // Create a new tooltip, but make sure to destroy remaining ones before. // this.timer = setTimeout(function execute() { this.render(event); }.bind(this), this.delay); }
javascript
function create(event) { if (!this.trigger(event)) return; if ('preventDefault' in event) event.preventDefault(); if (this.trigger(event, 'click') && this.remove(event)) return; // // Create a new tooltip, but make sure to destroy remaining ones before. // this.timer = setTimeout(function execute() { this.render(event); }.bind(this), this.delay); }
[ "function", "create", "(", "event", ")", "{", "if", "(", "!", "this", ".", "trigger", "(", "event", ")", ")", "return", ";", "if", "(", "'preventDefault'", "in", "event", ")", "event", ".", "preventDefault", "(", ")", ";", "if", "(", "this", ".", "trigger", "(", "event", ",", "'click'", ")", "&&", "this", ".", "remove", "(", "event", ")", ")", "return", ";", "//", "// Create a new tooltip, but make sure to destroy remaining ones before.", "//", "this", ".", "timer", "=", "setTimeout", "(", "function", "execute", "(", ")", "{", "this", ".", "render", "(", "event", ")", ";", "}", ".", "bind", "(", "this", ")", ",", "this", ".", "delay", ")", ";", "}" ]
Trigger rendering of the tooltip after a slight delay, less twitchy more user friendly. @param {Event} event @api public
[ "Trigger", "rendering", "of", "the", "tooltip", "after", "a", "slight", "delay", "less", "twitchy", "more", "user", "friendly", "." ]
0828e9bd25ef1eeb97ea231c447118d9867021b6
https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/tooltip/base.js#L107-L118
44,751
nodejitsu/contour
pagelets/nodejitsu/tooltip/base.js
remove
function remove(event) { // // Current event is not set as trigger (e.g. mouse click vs. hover). // if (!this.trigger(event)) return false; if ('preventDefault' in event) event.preventDefault(); clearTimeout(this.timer); var id = document.getElementById('tooltip'); return id ? !!document.body.removeChild(id) : false; }
javascript
function remove(event) { // // Current event is not set as trigger (e.g. mouse click vs. hover). // if (!this.trigger(event)) return false; if ('preventDefault' in event) event.preventDefault(); clearTimeout(this.timer); var id = document.getElementById('tooltip'); return id ? !!document.body.removeChild(id) : false; }
[ "function", "remove", "(", "event", ")", "{", "//", "// Current event is not set as trigger (e.g. mouse click vs. hover).", "//", "if", "(", "!", "this", ".", "trigger", "(", "event", ")", ")", "return", "false", ";", "if", "(", "'preventDefault'", "in", "event", ")", "event", ".", "preventDefault", "(", ")", ";", "clearTimeout", "(", "this", ".", "timer", ")", ";", "var", "id", "=", "document", ".", "getElementById", "(", "'tooltip'", ")", ";", "return", "id", "?", "!", "!", "document", ".", "body", ".", "removeChild", "(", "id", ")", ":", "false", ";", "}" ]
Remove the tooltip, can only be triggered if it actually exists. @returns {Boolean} was tooltip removed or not @api public
[ "Remove", "the", "tooltip", "can", "only", "be", "triggered", "if", "it", "actually", "exists", "." ]
0828e9bd25ef1eeb97ea231c447118d9867021b6
https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/tooltip/base.js#L126-L136
44,752
nodejitsu/contour
pagelets/nodejitsu/tooltip/base.js
render
function render(event) { var tooltip = document.createElement('div') , element = $(event.element) , pos = element.get('data-placement') , offset = this.offset(event.element) , placement; // // Create the tooltip with the proper content and insert. // tooltip.id = "tooltip"; tooltip.innerHTML = element.get('data-content'); tooltip.className = ['animated', 'tooltip', 'fadeIn', pos].concat( element.get('data-color') ).filter(Boolean).join(' '); document.body.appendChild(tooltip); // // Update the position of the tooltip. // placement = this.placement(pos, tooltip, event.element); tooltip.setAttribute('style', [ 'left:' + (offset.left + placement.left) + 'px', 'top:' + (offset.top + placement.top) + 'px' ].join(';')); }
javascript
function render(event) { var tooltip = document.createElement('div') , element = $(event.element) , pos = element.get('data-placement') , offset = this.offset(event.element) , placement; // // Create the tooltip with the proper content and insert. // tooltip.id = "tooltip"; tooltip.innerHTML = element.get('data-content'); tooltip.className = ['animated', 'tooltip', 'fadeIn', pos].concat( element.get('data-color') ).filter(Boolean).join(' '); document.body.appendChild(tooltip); // // Update the position of the tooltip. // placement = this.placement(pos, tooltip, event.element); tooltip.setAttribute('style', [ 'left:' + (offset.left + placement.left) + 'px', 'top:' + (offset.top + placement.top) + 'px' ].join(';')); }
[ "function", "render", "(", "event", ")", "{", "var", "tooltip", "=", "document", ".", "createElement", "(", "'div'", ")", ",", "element", "=", "$", "(", "event", ".", "element", ")", ",", "pos", "=", "element", ".", "get", "(", "'data-placement'", ")", ",", "offset", "=", "this", ".", "offset", "(", "event", ".", "element", ")", ",", "placement", ";", "//", "// Create the tooltip with the proper content and insert.", "//", "tooltip", ".", "id", "=", "\"tooltip\"", ";", "tooltip", ".", "innerHTML", "=", "element", ".", "get", "(", "'data-content'", ")", ";", "tooltip", ".", "className", "=", "[", "'animated'", ",", "'tooltip'", ",", "'fadeIn'", ",", "pos", "]", ".", "concat", "(", "element", ".", "get", "(", "'data-color'", ")", ")", ".", "filter", "(", "Boolean", ")", ".", "join", "(", "' '", ")", ";", "document", ".", "body", ".", "appendChild", "(", "tooltip", ")", ";", "//", "// Update the position of the tooltip.", "//", "placement", "=", "this", ".", "placement", "(", "pos", ",", "tooltip", ",", "event", ".", "element", ")", ";", "tooltip", ".", "setAttribute", "(", "'style'", ",", "[", "'left:'", "+", "(", "offset", ".", "left", "+", "placement", ".", "left", ")", "+", "'px'", ",", "'top:'", "+", "(", "offset", ".", "top", "+", "placement", ".", "top", ")", "+", "'px'", "]", ".", "join", "(", "';'", ")", ")", ";", "}" ]
Render the tooltip. @param {Event} event @api private
[ "Render", "the", "tooltip", "." ]
0828e9bd25ef1eeb97ea231c447118d9867021b6
https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/tooltip/base.js#L144-L170
44,753
assemble/grunt-assemble-lunr
index.js
function () { addCacheItem(params.context.page); params.context.lunr = params.context.lunr || {}; params.context.lunr.dataPath = params.context.lunr.dataPath || 'search_index.json'; }
javascript
function () { addCacheItem(params.context.page); params.context.lunr = params.context.lunr || {}; params.context.lunr.dataPath = params.context.lunr.dataPath || 'search_index.json'; }
[ "function", "(", ")", "{", "addCacheItem", "(", "params", ".", "context", ".", "page", ")", ";", "params", ".", "context", ".", "lunr", "=", "params", ".", "context", ".", "lunr", "||", "{", "}", ";", "params", ".", "context", ".", "lunr", ".", "dataPath", "=", "params", ".", "context", ".", "lunr", ".", "dataPath", "||", "'search_index.json'", ";", "}" ]
call before each page is rendered to get information from the context
[ "call", "before", "each", "page", "is", "rendered", "to", "get", "information", "from", "the", "context" ]
1477e95d1cb98e65448790f7fdc031418a4b51dd
https://github.com/assemble/grunt-assemble-lunr/blob/1477e95d1cb98e65448790f7fdc031418a4b51dd/index.js#L61-L65
44,754
termi/ASTQuery
src/matchSelector.js
getPathValue
function getPathValue(node, path) { let names = path.split("."), name; while ( name = names.shift() ) { if (node == null) { return names.length ? void 0 : null; } node = node[name]; } return node; }
javascript
function getPathValue(node, path) { let names = path.split("."), name; while ( name = names.shift() ) { if (node == null) { return names.length ? void 0 : null; } node = node[name]; } return node; }
[ "function", "getPathValue", "(", "node", ",", "path", ")", "{", "let", "names", "=", "path", ".", "split", "(", "\".\"", ")", ",", "name", ";", "while", "(", "name", "=", "names", ".", "shift", "(", ")", ")", "{", "if", "(", "node", "==", "null", ")", "{", "return", "names", ".", "length", "?", "void", "0", ":", "null", ";", "}", "node", "=", "node", "[", "name", "]", ";", "}", "return", "node", ";", "}" ]
Get the value of a property which may be multiple levels down in the object.
[ "Get", "the", "value", "of", "a", "property", "which", "may", "be", "multiple", "levels", "down", "in", "the", "object", "." ]
992fe7998eb768eddf8a4dc07fa169c1a3e461f1
https://github.com/termi/ASTQuery/blob/992fe7998eb768eddf8a4dc07fa169c1a3e461f1/src/matchSelector.js#L8-L19
44,755
ratnam99/Angular2-JWTSession
angular2-jwt.js
tokenNotExpired
function tokenNotExpired(tokenName, jwt) { if (tokenName === void 0) { tokenName = AuthConfigConsts.DEFAULT_TOKEN_NAME; } var token = jwt || localStorage.getItem(tokenName) || sessionStorage.getItem(tokenName); var jwtHelper = new JwtHelper(); return token != null && !jwtHelper.isTokenExpired(token); }
javascript
function tokenNotExpired(tokenName, jwt) { if (tokenName === void 0) { tokenName = AuthConfigConsts.DEFAULT_TOKEN_NAME; } var token = jwt || localStorage.getItem(tokenName) || sessionStorage.getItem(tokenName); var jwtHelper = new JwtHelper(); return token != null && !jwtHelper.isTokenExpired(token); }
[ "function", "tokenNotExpired", "(", "tokenName", ",", "jwt", ")", "{", "if", "(", "tokenName", "===", "void", "0", ")", "{", "tokenName", "=", "AuthConfigConsts", ".", "DEFAULT_TOKEN_NAME", ";", "}", "var", "token", "=", "jwt", "||", "localStorage", ".", "getItem", "(", "tokenName", ")", "||", "sessionStorage", ".", "getItem", "(", "tokenName", ")", ";", "var", "jwtHelper", "=", "new", "JwtHelper", "(", ")", ";", "return", "token", "!=", "null", "&&", "!", "jwtHelper", ".", "isTokenExpired", "(", "token", ")", ";", "}" ]
Checks for presence of token and that token hasn't expired. For use with the @CanActivate router decorator and NgIf
[ "Checks", "for", "presence", "of", "token", "and", "that", "token", "hasn", "t", "expired", ".", "For", "use", "with", "the" ]
ddc53b07f61d3504bc9b9bbff9762f44bf638a56
https://github.com/ratnam99/Angular2-JWTSession/blob/ddc53b07f61d3504bc9b9bbff9762f44bf638a56/angular2-jwt.js#L276-L281
44,756
socialally/air
lib/air/attr.js
attr
function attr(key, val) { var i, attrs, map = {}; if(!this.length || key !== undefined && !Boolean(key)) { return this; } if(key === undefined && val === undefined) { // no args, get all attributes for first element as object attrs = this.dom[0].attributes; // convert NamedNodeMap to plain object for(i = 0;i < attrs.length;i++) { // NOTE: nodeValue is deprecated, check support for `value` in IE9! map[attrs[i].name] = attrs[i].value; } return map; }else if(typeof key === 'string' && !val) { // delete attribute on all matched elements if(val === null) { this.each(function(el) { el.removeAttribute(key); }) return this; } // get attribute for first matched elements return this.dom[0].getAttribute(key); // handle object map of attributes }else { this.each(function(el) { if(typeof key === 'object') { for(var z in key) { if(key[z] === null) { el.removeAttribute(z); continue; } el.setAttribute(z, key[z]); } }else{ el.setAttribute(key, val); } }); } return this; }
javascript
function attr(key, val) { var i, attrs, map = {}; if(!this.length || key !== undefined && !Boolean(key)) { return this; } if(key === undefined && val === undefined) { // no args, get all attributes for first element as object attrs = this.dom[0].attributes; // convert NamedNodeMap to plain object for(i = 0;i < attrs.length;i++) { // NOTE: nodeValue is deprecated, check support for `value` in IE9! map[attrs[i].name] = attrs[i].value; } return map; }else if(typeof key === 'string' && !val) { // delete attribute on all matched elements if(val === null) { this.each(function(el) { el.removeAttribute(key); }) return this; } // get attribute for first matched elements return this.dom[0].getAttribute(key); // handle object map of attributes }else { this.each(function(el) { if(typeof key === 'object') { for(var z in key) { if(key[z] === null) { el.removeAttribute(z); continue; } el.setAttribute(z, key[z]); } }else{ el.setAttribute(key, val); } }); } return this; }
[ "function", "attr", "(", "key", ",", "val", ")", "{", "var", "i", ",", "attrs", ",", "map", "=", "{", "}", ";", "if", "(", "!", "this", ".", "length", "||", "key", "!==", "undefined", "&&", "!", "Boolean", "(", "key", ")", ")", "{", "return", "this", ";", "}", "if", "(", "key", "===", "undefined", "&&", "val", "===", "undefined", ")", "{", "// no args, get all attributes for first element as object", "attrs", "=", "this", ".", "dom", "[", "0", "]", ".", "attributes", ";", "// convert NamedNodeMap to plain object", "for", "(", "i", "=", "0", ";", "i", "<", "attrs", ".", "length", ";", "i", "++", ")", "{", "// NOTE: nodeValue is deprecated, check support for `value` in IE9!", "map", "[", "attrs", "[", "i", "]", ".", "name", "]", "=", "attrs", "[", "i", "]", ".", "value", ";", "}", "return", "map", ";", "}", "else", "if", "(", "typeof", "key", "===", "'string'", "&&", "!", "val", ")", "{", "// delete attribute on all matched elements", "if", "(", "val", "===", "null", ")", "{", "this", ".", "each", "(", "function", "(", "el", ")", "{", "el", ".", "removeAttribute", "(", "key", ")", ";", "}", ")", "return", "this", ";", "}", "// get attribute for first matched elements", "return", "this", ".", "dom", "[", "0", "]", ".", "getAttribute", "(", "key", ")", ";", "// handle object map of attributes", "}", "else", "{", "this", ".", "each", "(", "function", "(", "el", ")", "{", "if", "(", "typeof", "key", "===", "'object'", ")", "{", "for", "(", "var", "z", "in", "key", ")", "{", "if", "(", "key", "[", "z", "]", "===", "null", ")", "{", "el", ".", "removeAttribute", "(", "z", ")", ";", "continue", ";", "}", "el", ".", "setAttribute", "(", "z", ",", "key", "[", "z", "]", ")", ";", "}", "}", "else", "{", "el", ".", "setAttribute", "(", "key", ",", "val", ")", ";", "}", "}", ")", ";", "}", "return", "this", ";", "}" ]
Get the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched element.
[ "Get", "the", "value", "of", "an", "attribute", "for", "the", "first", "element", "in", "the", "set", "of", "matched", "elements", "or", "set", "one", "or", "more", "attributes", "for", "every", "matched", "element", "." ]
a3d94de58aaa4930a425fbcc7266764bf6ca8ca6
https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/attr.js#L5-L47
44,757
sakunyo/grunt-pandoc
tasks/PandocRun.js
function (type) { var exec = []; switch (type || this.configs["publish"]) { case "EPUB": this.publishEPUB(exec); break; case "LATEX": this.publishLatex(exec); break; case "HTML": this.publishHTML(exec); default: break; } return exec; }
javascript
function (type) { var exec = []; switch (type || this.configs["publish"]) { case "EPUB": this.publishEPUB(exec); break; case "LATEX": this.publishLatex(exec); break; case "HTML": this.publishHTML(exec); default: break; } return exec; }
[ "function", "(", "type", ")", "{", "var", "exec", "=", "[", "]", ";", "switch", "(", "type", "||", "this", ".", "configs", "[", "\"publish\"", "]", ")", "{", "case", "\"EPUB\"", ":", "this", ".", "publishEPUB", "(", "exec", ")", ";", "break", ";", "case", "\"LATEX\"", ":", "this", ".", "publishLatex", "(", "exec", ")", ";", "break", ";", "case", "\"HTML\"", ":", "this", ".", "publishHTML", "(", "exec", ")", ";", "default", ":", "break", ";", "}", "return", "exec", ";", "}" ]
getEXEC Choice Publish Format @param type @returns {string}
[ "getEXEC", "Choice", "Publish", "Format" ]
448b81beca6dec84c55448c47edaab5d43093844
https://github.com/sakunyo/grunt-pandoc/blob/448b81beca6dec84c55448c47edaab5d43093844/tasks/PandocRun.js#L44-L60
44,758
btholt/generator-mdpress
app/templates/_ignite.js
waitAndAdvance
function waitAndAdvance(step, steps) { setTimeout(function(){ if (step < steps - 1) { api.next(); waitAndAdvance(step+1, steps); } else { // after 15 seconds on last slide, exit fullscreen if(document.cancelFullScreen) { document.cancelFullScreen(); } else if(document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if(document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } } }, slideAdvance); }
javascript
function waitAndAdvance(step, steps) { setTimeout(function(){ if (step < steps - 1) { api.next(); waitAndAdvance(step+1, steps); } else { // after 15 seconds on last slide, exit fullscreen if(document.cancelFullScreen) { document.cancelFullScreen(); } else if(document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if(document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } } }, slideAdvance); }
[ "function", "waitAndAdvance", "(", "step", ",", "steps", ")", "{", "setTimeout", "(", "function", "(", ")", "{", "if", "(", "step", "<", "steps", "-", "1", ")", "{", "api", ".", "next", "(", ")", ";", "waitAndAdvance", "(", "step", "+", "1", ",", "steps", ")", ";", "}", "else", "{", "// after 15 seconds on last slide, exit fullscreen", "if", "(", "document", ".", "cancelFullScreen", ")", "{", "document", ".", "cancelFullScreen", "(", ")", ";", "}", "else", "if", "(", "document", ".", "mozCancelFullScreen", ")", "{", "document", ".", "mozCancelFullScreen", "(", ")", ";", "}", "else", "if", "(", "document", ".", "webkitCancelFullScreen", ")", "{", "document", ".", "webkitCancelFullScreen", "(", ")", ";", "}", "}", "}", ",", "slideAdvance", ")", ";", "}" ]
recursive function to wait seconds before advancing
[ "recursive", "function", "to", "wait", "seconds", "before", "advancing" ]
712d77e1812be9e0705e3056ca3d0e513c1baa81
https://github.com/btholt/generator-mdpress/blob/712d77e1812be9e0705e3056ca3d0e513c1baa81/app/templates/_ignite.js#L47-L64
44,759
thii/abbajs
index.js
function(zCriticalValue) { var baselineP = this.baseline.pEstimate(zCriticalValue); var variationP = this.variation.pEstimate(zCriticalValue); var difference = variationP.value - baselineP.value; var standardError = Math.sqrt(Math.pow(baselineP.error, 2) + Math.pow(variationP.error, 2)); return new Abba.ValueWithError(difference, standardError); }
javascript
function(zCriticalValue) { var baselineP = this.baseline.pEstimate(zCriticalValue); var variationP = this.variation.pEstimate(zCriticalValue); var difference = variationP.value - baselineP.value; var standardError = Math.sqrt(Math.pow(baselineP.error, 2) + Math.pow(variationP.error, 2)); return new Abba.ValueWithError(difference, standardError); }
[ "function", "(", "zCriticalValue", ")", "{", "var", "baselineP", "=", "this", ".", "baseline", ".", "pEstimate", "(", "zCriticalValue", ")", ";", "var", "variationP", "=", "this", ".", "variation", ".", "pEstimate", "(", "zCriticalValue", ")", ";", "var", "difference", "=", "variationP", ".", "value", "-", "baselineP", ".", "value", ";", "var", "standardError", "=", "Math", ".", "sqrt", "(", "Math", ".", "pow", "(", "baselineP", ".", "error", ",", "2", ")", "+", "Math", ".", "pow", "(", "variationP", ".", "error", ",", "2", ")", ")", ";", "return", "new", "Abba", ".", "ValueWithError", "(", "difference", ",", "standardError", ")", ";", "}" ]
Generate an estimate of the difference in success rates between the variation and the baseline.
[ "Generate", "an", "estimate", "of", "the", "difference", "in", "success", "rates", "between", "the", "variation", "and", "the", "baseline", "." ]
b75b5d4f0cb6bf920cdec36814b72be1e30cf908
https://github.com/thii/abbajs/blob/b75b5d4f0cb6bf920cdec36814b72be1e30cf908/index.js#L175-L181
44,760
thii/abbajs
index.js
function(zCriticalValue) { var baselineValue = this.baseline.pEstimate(zCriticalValue).value; var ratio = this.differenceEstimate(zCriticalValue).value / baselineValue; var error = this.differenceEstimate(zCriticalValue).error / baselineValue; return new Abba.ValueWithError(ratio, error); }
javascript
function(zCriticalValue) { var baselineValue = this.baseline.pEstimate(zCriticalValue).value; var ratio = this.differenceEstimate(zCriticalValue).value / baselineValue; var error = this.differenceEstimate(zCriticalValue).error / baselineValue; return new Abba.ValueWithError(ratio, error); }
[ "function", "(", "zCriticalValue", ")", "{", "var", "baselineValue", "=", "this", ".", "baseline", ".", "pEstimate", "(", "zCriticalValue", ")", ".", "value", ";", "var", "ratio", "=", "this", ".", "differenceEstimate", "(", "zCriticalValue", ")", ".", "value", "/", "baselineValue", ";", "var", "error", "=", "this", ".", "differenceEstimate", "(", "zCriticalValue", ")", ".", "error", "/", "baselineValue", ";", "return", "new", "Abba", ".", "ValueWithError", "(", "ratio", ",", "error", ")", ";", "}" ]
Return the difference in sucess rates as a proportion of the baseline success rate.
[ "Return", "the", "difference", "in", "sucess", "rates", "as", "a", "proportion", "of", "the", "baseline", "success", "rate", "." ]
b75b5d4f0cb6bf920cdec36814b72be1e30cf908
https://github.com/thii/abbajs/blob/b75b5d4f0cb6bf920cdec36814b72be1e30cf908/index.js#L184-L189
44,761
DScheglov/merest
lib/controllers/instance-method.js
callInstanceMethod
function callInstanceMethod(methodName, req, res, next) { res.__apiMethod = 'instanceMethod'; res.__apiInstanceMethod = methodName; const self = this; const id = req.params.id; const methodOptions = this.apiOptions.expose[methodName]; const wrapper = (methodOptions.exec instanceof Function) ? methodOptions.exec : null; let filter = this.option(methodName, 'filter'); if (filter instanceof Function) { filter = filter.call(this, req); } const query = Object.assign({}, filter, { _id: id }); const params = (methodOptions.method !== 'get') ? req.body : req.query; this.model.findById(query, function (err, obj) { if (err) return next(err); if (!obj) { return next(new ModelAPIError( 404, `The ${self.nameSingle} was not found by ${id}` )); }; const mFunc = wrapper || obj[methodName]; mFunc.call(obj, params, function(err, result) { if (err) return next(err); res.json(result); }); }); }
javascript
function callInstanceMethod(methodName, req, res, next) { res.__apiMethod = 'instanceMethod'; res.__apiInstanceMethod = methodName; const self = this; const id = req.params.id; const methodOptions = this.apiOptions.expose[methodName]; const wrapper = (methodOptions.exec instanceof Function) ? methodOptions.exec : null; let filter = this.option(methodName, 'filter'); if (filter instanceof Function) { filter = filter.call(this, req); } const query = Object.assign({}, filter, { _id: id }); const params = (methodOptions.method !== 'get') ? req.body : req.query; this.model.findById(query, function (err, obj) { if (err) return next(err); if (!obj) { return next(new ModelAPIError( 404, `The ${self.nameSingle} was not found by ${id}` )); }; const mFunc = wrapper || obj[methodName]; mFunc.call(obj, params, function(err, result) { if (err) return next(err); res.json(result); }); }); }
[ "function", "callInstanceMethod", "(", "methodName", ",", "req", ",", "res", ",", "next", ")", "{", "res", ".", "__apiMethod", "=", "'instanceMethod'", ";", "res", ".", "__apiInstanceMethod", "=", "methodName", ";", "const", "self", "=", "this", ";", "const", "id", "=", "req", ".", "params", ".", "id", ";", "const", "methodOptions", "=", "this", ".", "apiOptions", ".", "expose", "[", "methodName", "]", ";", "const", "wrapper", "=", "(", "methodOptions", ".", "exec", "instanceof", "Function", ")", "?", "methodOptions", ".", "exec", ":", "null", ";", "let", "filter", "=", "this", ".", "option", "(", "methodName", ",", "'filter'", ")", ";", "if", "(", "filter", "instanceof", "Function", ")", "{", "filter", "=", "filter", ".", "call", "(", "this", ",", "req", ")", ";", "}", "const", "query", "=", "Object", ".", "assign", "(", "{", "}", ",", "filter", ",", "{", "_id", ":", "id", "}", ")", ";", "const", "params", "=", "(", "methodOptions", ".", "method", "!==", "'get'", ")", "?", "req", ".", "body", ":", "req", ".", "query", ";", "this", ".", "model", ".", "findById", "(", "query", ",", "function", "(", "err", ",", "obj", ")", "{", "if", "(", "err", ")", "return", "next", "(", "err", ")", ";", "if", "(", "!", "obj", ")", "{", "return", "next", "(", "new", "ModelAPIError", "(", "404", ",", "`", "${", "self", ".", "nameSingle", "}", "${", "id", "}", "`", ")", ")", ";", "}", ";", "const", "mFunc", "=", "wrapper", "||", "obj", "[", "methodName", "]", ";", "mFunc", ".", "call", "(", "obj", ",", "params", ",", "function", "(", "err", ",", "result", ")", "{", "if", "(", "err", ")", "return", "next", "(", "err", ")", ";", "res", ".", "json", "(", "result", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
callInstanceMethod - calls specific method of model instance @param {String} methodName the name of the method should be called @param {express.Request} req the http(s) request @param {express.Response} res the http(s) response @param {Function} next the callback should be called if controller fails @memberof ModelAPIRouter
[ "callInstanceMethod", "-", "calls", "specific", "method", "of", "model", "instance" ]
d39e7ef0d56236247773467e9bfe83cb128ebc01
https://github.com/DScheglov/merest/blob/d39e7ef0d56236247773467e9bfe83cb128ebc01/lib/controllers/instance-method.js#L16-L50
44,762
theboyWhoCriedWoolf/transition-manager
example/ViewManager.js
fetchView
function fetchView( data, id ) { data.backgroundColor = randomCol(); data.fontColour = data.backgroundImage? '' : getContrastYIQ( data.backgroundColor ); let wrapper = document.createElement('div'); wrapper.className = 'section hidden'; wrapper.innerHTML = SimpleViewTemplate( data ); wrapper.dataset.id = id; container.appendChild( wrapper ); return wrapper; }
javascript
function fetchView( data, id ) { data.backgroundColor = randomCol(); data.fontColour = data.backgroundImage? '' : getContrastYIQ( data.backgroundColor ); let wrapper = document.createElement('div'); wrapper.className = 'section hidden'; wrapper.innerHTML = SimpleViewTemplate( data ); wrapper.dataset.id = id; container.appendChild( wrapper ); return wrapper; }
[ "function", "fetchView", "(", "data", ",", "id", ")", "{", "data", ".", "backgroundColor", "=", "randomCol", "(", ")", ";", "data", ".", "fontColour", "=", "data", ".", "backgroundImage", "?", "''", ":", "getContrastYIQ", "(", "data", ".", "backgroundColor", ")", ";", "let", "wrapper", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "wrapper", ".", "className", "=", "'section hidden'", ";", "wrapper", ".", "innerHTML", "=", "SimpleViewTemplate", "(", "data", ")", ";", "wrapper", ".", "dataset", ".", "id", "=", "id", ";", "container", ".", "appendChild", "(", "wrapper", ")", ";", "return", "wrapper", ";", "}" ]
create and apped a new View to the DOM prepoppulating with view data @param {object} data @param {int} id - incremented ID @return {Node}
[ "create", "and", "apped", "a", "new", "View", "to", "the", "DOM", "prepoppulating", "with", "view", "data" ]
a20fda0bb07c0098bf709ea03770b1ee2a855655
https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/example/ViewManager.js#L79-L91
44,763
socialally/air
lib/air/disabled.js
disabled
function disabled(val) { // return whether the first element in the set // is hidden if(val === undefined) { return this.hasClass(className); // hide on truthy }else if(val) { this.addClass(className); // show on falsey }else{ this.removeClass(className); } return this; }
javascript
function disabled(val) { // return whether the first element in the set // is hidden if(val === undefined) { return this.hasClass(className); // hide on truthy }else if(val) { this.addClass(className); // show on falsey }else{ this.removeClass(className); } return this; }
[ "function", "disabled", "(", "val", ")", "{", "// return whether the first element in the set", "// is hidden", "if", "(", "val", "===", "undefined", ")", "{", "return", "this", ".", "hasClass", "(", "className", ")", ";", "// hide on truthy", "}", "else", "if", "(", "val", ")", "{", "this", ".", "addClass", "(", "className", ")", ";", "// show on falsey", "}", "else", "{", "this", ".", "removeClass", "(", "className", ")", ";", "}", "return", "this", ";", "}" ]
Toggles the disabled class on an element. A typical css rule might be: .disabled{pointer-events: none; opacity: 0.8;}
[ "Toggles", "the", "disabled", "class", "on", "an", "element", "." ]
a3d94de58aaa4930a425fbcc7266764bf6ca8ca6
https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/disabled.js#L10-L23
44,764
Sobesednik/wrote
es5/src/write.js
write
function write(ws, source) { return new Promise(function ($return, $error) { if (!(ws instanceof Writable)) { return $error(new Error('Writable stream expected')); } if (source instanceof Readable) { if (!source.readable) { return $error(new Error('Stream is not readable')); } return Promise.resolve(new Promise(function (resolve, reject) { ws.on('finish', resolve); ws.on('error', reject); source.on('error', reject); source.pipe(ws); })).then(function ($await_2) { try { return $return(ws); } catch ($boundEx) { return $error($boundEx); } }.bind(this), $error); } return Promise.resolve(makePromise(ws.end.bind(ws), source)).then(function ($await_3) { try { return $return(ws); } catch ($boundEx) { return $error($boundEx); } }.bind(this), $error); }.bind(this)); }
javascript
function write(ws, source) { return new Promise(function ($return, $error) { if (!(ws instanceof Writable)) { return $error(new Error('Writable stream expected')); } if (source instanceof Readable) { if (!source.readable) { return $error(new Error('Stream is not readable')); } return Promise.resolve(new Promise(function (resolve, reject) { ws.on('finish', resolve); ws.on('error', reject); source.on('error', reject); source.pipe(ws); })).then(function ($await_2) { try { return $return(ws); } catch ($boundEx) { return $error($boundEx); } }.bind(this), $error); } return Promise.resolve(makePromise(ws.end.bind(ws), source)).then(function ($await_3) { try { return $return(ws); } catch ($boundEx) { return $error($boundEx); } }.bind(this), $error); }.bind(this)); }
[ "function", "write", "(", "ws", ",", "source", ")", "{", "return", "new", "Promise", "(", "function", "(", "$return", ",", "$error", ")", "{", "if", "(", "!", "(", "ws", "instanceof", "Writable", ")", ")", "{", "return", "$error", "(", "new", "Error", "(", "'Writable stream expected'", ")", ")", ";", "}", "if", "(", "source", "instanceof", "Readable", ")", "{", "if", "(", "!", "source", ".", "readable", ")", "{", "return", "$error", "(", "new", "Error", "(", "'Stream is not readable'", ")", ")", ";", "}", "return", "Promise", ".", "resolve", "(", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "ws", ".", "on", "(", "'finish'", ",", "resolve", ")", ";", "ws", ".", "on", "(", "'error'", ",", "reject", ")", ";", "source", ".", "on", "(", "'error'", ",", "reject", ")", ";", "source", ".", "pipe", "(", "ws", ")", ";", "}", ")", ")", ".", "then", "(", "function", "(", "$await_2", ")", "{", "try", "{", "return", "$return", "(", "ws", ")", ";", "}", "catch", "(", "$boundEx", ")", "{", "return", "$error", "(", "$boundEx", ")", ";", "}", "}", ".", "bind", "(", "this", ")", ",", "$error", ")", ";", "}", "return", "Promise", ".", "resolve", "(", "makePromise", "(", "ws", ".", "end", ".", "bind", "(", "ws", ")", ",", "source", ")", ")", ".", "then", "(", "function", "(", "$await_3", ")", "{", "try", "{", "return", "$return", "(", "ws", ")", ";", "}", "catch", "(", "$boundEx", ")", "{", "return", "$error", "(", "$boundEx", ")", ";", "}", "}", ".", "bind", "(", "this", ")", ",", "$error", ")", ";", "}", ".", "bind", "(", "this", ")", ")", ";", "}" ]
Write data to the stream, and resolve when it's ended. @param {Writable} ws write stream @param {string|Readable} source read source @returns {Promise<Writable>} A promise resolved with the writable stream, or rejected when an error occurred while reading or writing.
[ "Write", "data", "to", "the", "stream", "and", "resolve", "when", "it", "s", "ended", "." ]
24992ad3bba4e5959dfb617b6c1f22d9a1306ab9
https://github.com/Sobesednik/wrote/blob/24992ad3bba4e5959dfb617b6c1f22d9a1306ab9/es5/src/write.js#L12-L42
44,765
OpenSmartEnvironment/ose
lib/space/index.js
init
function init() { // {{{2 /** * Class constructor * * @method constructor * @internal */ O.inherited(this)(); this.setMaxListeners(Consts.coreListeners); this.subjectState = this.SUBJECT_STATE.INIT; this.peers = {}; this.shards = {}; }
javascript
function init() { // {{{2 /** * Class constructor * * @method constructor * @internal */ O.inherited(this)(); this.setMaxListeners(Consts.coreListeners); this.subjectState = this.SUBJECT_STATE.INIT; this.peers = {}; this.shards = {}; }
[ "function", "init", "(", ")", "{", "// {{{2", "/**\n * Class constructor\n *\n * @method constructor\n * @internal\n */", "O", ".", "inherited", "(", "this", ")", "(", ")", ";", "this", ".", "setMaxListeners", "(", "Consts", ".", "coreListeners", ")", ";", "this", ".", "subjectState", "=", "this", ".", "SUBJECT_STATE", ".", "INIT", ";", "this", ".", "peers", "=", "{", "}", ";", "this", ".", "shards", "=", "{", "}", ";", "}" ]
shards {{{2 Object containing shards indexed by `sid` @property shards @type Object @internal Public {{{1
[ "shards", "{{{", "2", "Object", "containing", "shards", "indexed", "by", "sid" ]
2ab051d9db6e77341c40abb9cbdae6ce586917e0
https://github.com/OpenSmartEnvironment/ose/blob/2ab051d9db6e77341c40abb9cbdae6ce586917e0/lib/space/index.js#L68-L84
44,766
vid/SenseBase
web/ext-lib/jqCron/jqCron.js
newSelector
function newSelector($block, multiple, type){ var selector = new jqCronSelector(_self, $block, multiple, type); selector.$.bind('selector:open', function(){ // we close all opened selectors of all other jqCron for(var n = jqCronInstances.length; n--; ){ if(jqCronInstances[n] != _self) { jqCronInstances[n].closeSelectors(); } else { // we close all other opened selectors of this jqCron for(var o = _selectors.length; o--; ){ if(_selectors[o] != selector) { _selectors[o].close(); } } } } }); selector.$.bind('selector:change', function(){ var boundChanged = false; // don't propagate if not initialized if(!_initialized) return; // bind data between two minute selectors (only if they have the same multiple settings) if(settings.multiple_mins == settings.multiple_time_minutes) { if(selector == _selectorMins) { boundChanged = _selectorTimeM.setValue(_selectorMins.getValue()); } else if(selector == _selectorTimeM) { boundChanged = _selectorMins.setValue(_selectorTimeM.getValue()); } } // we propagate the change event to the main object boundChanged || _$obj.trigger('cron:change', _self.getCron()); }); _selectors.push(selector); return selector; }
javascript
function newSelector($block, multiple, type){ var selector = new jqCronSelector(_self, $block, multiple, type); selector.$.bind('selector:open', function(){ // we close all opened selectors of all other jqCron for(var n = jqCronInstances.length; n--; ){ if(jqCronInstances[n] != _self) { jqCronInstances[n].closeSelectors(); } else { // we close all other opened selectors of this jqCron for(var o = _selectors.length; o--; ){ if(_selectors[o] != selector) { _selectors[o].close(); } } } } }); selector.$.bind('selector:change', function(){ var boundChanged = false; // don't propagate if not initialized if(!_initialized) return; // bind data between two minute selectors (only if they have the same multiple settings) if(settings.multiple_mins == settings.multiple_time_minutes) { if(selector == _selectorMins) { boundChanged = _selectorTimeM.setValue(_selectorMins.getValue()); } else if(selector == _selectorTimeM) { boundChanged = _selectorMins.setValue(_selectorTimeM.getValue()); } } // we propagate the change event to the main object boundChanged || _$obj.trigger('cron:change', _self.getCron()); }); _selectors.push(selector); return selector; }
[ "function", "newSelector", "(", "$block", ",", "multiple", ",", "type", ")", "{", "var", "selector", "=", "new", "jqCronSelector", "(", "_self", ",", "$block", ",", "multiple", ",", "type", ")", ";", "selector", ".", "$", ".", "bind", "(", "'selector:open'", ",", "function", "(", ")", "{", "// we close all opened selectors of all other jqCron", "for", "(", "var", "n", "=", "jqCronInstances", ".", "length", ";", "n", "--", ";", ")", "{", "if", "(", "jqCronInstances", "[", "n", "]", "!=", "_self", ")", "{", "jqCronInstances", "[", "n", "]", ".", "closeSelectors", "(", ")", ";", "}", "else", "{", "// we close all other opened selectors of this jqCron", "for", "(", "var", "o", "=", "_selectors", ".", "length", ";", "o", "--", ";", ")", "{", "if", "(", "_selectors", "[", "o", "]", "!=", "selector", ")", "{", "_selectors", "[", "o", "]", ".", "close", "(", ")", ";", "}", "}", "}", "}", "}", ")", ";", "selector", ".", "$", ".", "bind", "(", "'selector:change'", ",", "function", "(", ")", "{", "var", "boundChanged", "=", "false", ";", "// don't propagate if not initialized", "if", "(", "!", "_initialized", ")", "return", ";", "// bind data between two minute selectors (only if they have the same multiple settings)", "if", "(", "settings", ".", "multiple_mins", "==", "settings", ".", "multiple_time_minutes", ")", "{", "if", "(", "selector", "==", "_selectorMins", ")", "{", "boundChanged", "=", "_selectorTimeM", ".", "setValue", "(", "_selectorMins", ".", "getValue", "(", ")", ")", ";", "}", "else", "if", "(", "selector", "==", "_selectorTimeM", ")", "{", "boundChanged", "=", "_selectorMins", ".", "setValue", "(", "_selectorTimeM", ".", "getValue", "(", ")", ")", ";", "}", "}", "// we propagate the change event to the main object", "boundChanged", "||", "_$obj", ".", "trigger", "(", "'cron:change'", ",", "_self", ".", "getCron", "(", ")", ")", ";", "}", ")", ";", "_selectors", ".", "push", "(", "selector", ")", ";", "return", "selector", ";", "}" ]
instanciate a new selector
[ "instanciate", "a", "new", "selector" ]
d60bcf28239e7dde437d8a6bdae41a6921dcd05b
https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/ext-lib/jqCron/jqCron.js#L169-L205
44,767
vid/SenseBase
web/ext-lib/jqCron/jqCron.js
array_unique
function array_unique(l){ var i=0,n=l.length,k={},a=[]; while(i<n) { k[l[i]] || (k[l[i]] = 1 && a.push(l[i])); i++; } return a; }
javascript
function array_unique(l){ var i=0,n=l.length,k={},a=[]; while(i<n) { k[l[i]] || (k[l[i]] = 1 && a.push(l[i])); i++; } return a; }
[ "function", "array_unique", "(", "l", ")", "{", "var", "i", "=", "0", ",", "n", "=", "l", ".", "length", ",", "k", "=", "{", "}", ",", "a", "=", "[", "]", ";", "while", "(", "i", "<", "n", ")", "{", "k", "[", "l", "[", "i", "]", "]", "||", "(", "k", "[", "l", "[", "i", "]", "]", "=", "1", "&&", "a", ".", "push", "(", "l", "[", "i", "]", ")", ")", ";", "i", "++", ";", "}", "return", "a", ";", "}" ]
return an array without doublon
[ "return", "an", "array", "without", "doublon" ]
d60bcf28239e7dde437d8a6bdae41a6921dcd05b
https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/ext-lib/jqCron/jqCron.js#L522-L529
44,768
xudafeng/passme
demo/editor/rainyday.js
RainyDay
function RainyDay(options) { this.img = document.getElementById(options.element); this.opacity = options.opacity || 1; this.blurRadius = options.blur || 10; this.w = this.img.clientWidth; this.h = this.img.clientHeight; this.drops = []; // prepare canvas elements this.canvas = this.prepareCanvas(this.img); this.prepareBackground(this.w, this.h); this.prepareGlass(); // assume defaults this.reflection = this.REFLECTION_MINIATURE; this.trail = this.TRAIL_DROPS; this.gravity = this.GRAVITY_NON_LINEAR; this.collision = this.COLLISION_SIMPLE; this.VARIABLE_GRAVITY_THRESHOLD = 3; this.VARIABLE_GRAVITY_ANGLE = Math.PI / 2; this.VARIABLE_GRAVITY_ANGLE_VARIANCE = 0; this.VARIABLE_FPS = options.fps; this.VARIABLE_FILL_STYLE = '#8ED6FF'; this.VARIABLE_COLLISIONS = true; this.REFLECTION_SCALEDOWN_FACTOR = 5; this.REFLECTION_DROP_MAPPING_WIDTH = 200; this.REFLECTION_DROP_MAPPING_HEIGHT = 200; }
javascript
function RainyDay(options) { this.img = document.getElementById(options.element); this.opacity = options.opacity || 1; this.blurRadius = options.blur || 10; this.w = this.img.clientWidth; this.h = this.img.clientHeight; this.drops = []; // prepare canvas elements this.canvas = this.prepareCanvas(this.img); this.prepareBackground(this.w, this.h); this.prepareGlass(); // assume defaults this.reflection = this.REFLECTION_MINIATURE; this.trail = this.TRAIL_DROPS; this.gravity = this.GRAVITY_NON_LINEAR; this.collision = this.COLLISION_SIMPLE; this.VARIABLE_GRAVITY_THRESHOLD = 3; this.VARIABLE_GRAVITY_ANGLE = Math.PI / 2; this.VARIABLE_GRAVITY_ANGLE_VARIANCE = 0; this.VARIABLE_FPS = options.fps; this.VARIABLE_FILL_STYLE = '#8ED6FF'; this.VARIABLE_COLLISIONS = true; this.REFLECTION_SCALEDOWN_FACTOR = 5; this.REFLECTION_DROP_MAPPING_WIDTH = 200; this.REFLECTION_DROP_MAPPING_HEIGHT = 200; }
[ "function", "RainyDay", "(", "options", ")", "{", "this", ".", "img", "=", "document", ".", "getElementById", "(", "options", ".", "element", ")", ";", "this", ".", "opacity", "=", "options", ".", "opacity", "||", "1", ";", "this", ".", "blurRadius", "=", "options", ".", "blur", "||", "10", ";", "this", ".", "w", "=", "this", ".", "img", ".", "clientWidth", ";", "this", ".", "h", "=", "this", ".", "img", ".", "clientHeight", ";", "this", ".", "drops", "=", "[", "]", ";", "// prepare canvas elements", "this", ".", "canvas", "=", "this", ".", "prepareCanvas", "(", "this", ".", "img", ")", ";", "this", ".", "prepareBackground", "(", "this", ".", "w", ",", "this", ".", "h", ")", ";", "this", ".", "prepareGlass", "(", ")", ";", "// assume defaults", "this", ".", "reflection", "=", "this", ".", "REFLECTION_MINIATURE", ";", "this", ".", "trail", "=", "this", ".", "TRAIL_DROPS", ";", "this", ".", "gravity", "=", "this", ".", "GRAVITY_NON_LINEAR", ";", "this", ".", "collision", "=", "this", ".", "COLLISION_SIMPLE", ";", "this", ".", "VARIABLE_GRAVITY_THRESHOLD", "=", "3", ";", "this", ".", "VARIABLE_GRAVITY_ANGLE", "=", "Math", ".", "PI", "/", "2", ";", "this", ".", "VARIABLE_GRAVITY_ANGLE_VARIANCE", "=", "0", ";", "this", ".", "VARIABLE_FPS", "=", "options", ".", "fps", ";", "this", ".", "VARIABLE_FILL_STYLE", "=", "'#8ED6FF'", ";", "this", ".", "VARIABLE_COLLISIONS", "=", "true", ";", "this", ".", "REFLECTION_SCALEDOWN_FACTOR", "=", "5", ";", "this", ".", "REFLECTION_DROP_MAPPING_WIDTH", "=", "200", ";", "this", ".", "REFLECTION_DROP_MAPPING_HEIGHT", "=", "200", ";", "}" ]
Defines a new instance of the rainyday.js. @param options options element with script parameters
[ "Defines", "a", "new", "instance", "of", "the", "rainyday", ".", "js", "." ]
14c5a9d76569fc67101b35284ea2f049bcc9896e
https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/rainyday.js#L6-L33
44,769
xudafeng/passme
demo/editor/rainyday.js
Drop
function Drop(rainyday, centerX, centerY, min, base) { this.x = Math.floor(centerX); this.y = Math.floor(centerY); this.r = (Math.random() * base) + min; this.rainyday = rainyday; this.context = rainyday.context; this.reflection = rainyday.reflected; }
javascript
function Drop(rainyday, centerX, centerY, min, base) { this.x = Math.floor(centerX); this.y = Math.floor(centerY); this.r = (Math.random() * base) + min; this.rainyday = rainyday; this.context = rainyday.context; this.reflection = rainyday.reflected; }
[ "function", "Drop", "(", "rainyday", ",", "centerX", ",", "centerY", ",", "min", ",", "base", ")", "{", "this", ".", "x", "=", "Math", ".", "floor", "(", "centerX", ")", ";", "this", ".", "y", "=", "Math", ".", "floor", "(", "centerY", ")", ";", "this", ".", "r", "=", "(", "Math", ".", "random", "(", ")", "*", "base", ")", "+", "min", ";", "this", ".", "rainyday", "=", "rainyday", ";", "this", ".", "context", "=", "rainyday", ".", "context", ";", "this", ".", "reflection", "=", "rainyday", ".", "reflected", ";", "}" ]
Defines a new raindrop object. @param rainyday reference to the parent object @param centerX x position of the center of this drop @param centerY y position of the center of this drop @param min minimum size of a drop @param base base value for randomizing drop size
[ "Defines", "a", "new", "raindrop", "object", "." ]
14c5a9d76569fc67101b35284ea2f049bcc9896e
https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/rainyday.js#L252-L259
44,770
xudafeng/passme
demo/editor/rainyday.js
CollisionMatrix
function CollisionMatrix(x, y, r) { this.resolution = r; this.xc = x; this.yc = y; this.matrix = new Array(x); for (var i = 0; i <= (x + 5); i++) { this.matrix[i] = new Array(y); for (var j = 0; j <= (y + 5); ++j) { this.matrix[i][j] = new DropItem(null); } } }
javascript
function CollisionMatrix(x, y, r) { this.resolution = r; this.xc = x; this.yc = y; this.matrix = new Array(x); for (var i = 0; i <= (x + 5); i++) { this.matrix[i] = new Array(y); for (var j = 0; j <= (y + 5); ++j) { this.matrix[i][j] = new DropItem(null); } } }
[ "function", "CollisionMatrix", "(", "x", ",", "y", ",", "r", ")", "{", "this", ".", "resolution", "=", "r", ";", "this", ".", "xc", "=", "x", ";", "this", ".", "yc", "=", "y", ";", "this", ".", "matrix", "=", "new", "Array", "(", "x", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<=", "(", "x", "+", "5", ")", ";", "i", "++", ")", "{", "this", ".", "matrix", "[", "i", "]", "=", "new", "Array", "(", "y", ")", ";", "for", "(", "var", "j", "=", "0", ";", "j", "<=", "(", "y", "+", "5", ")", ";", "++", "j", ")", "{", "this", ".", "matrix", "[", "i", "]", "[", "j", "]", "=", "new", "DropItem", "(", "null", ")", ";", "}", "}", "}" ]
Defines a gravity matrix object which handles collision detection. @param x number of columns in the matrix @param y number of rows in the matrix @param r grid size
[ "Defines", "a", "gravity", "matrix", "object", "which", "handles", "collision", "detection", "." ]
14c5a9d76569fc67101b35284ea2f049bcc9896e
https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/rainyday.js#L814-L825
44,771
theboyWhoCriedWoolf/transition-manager
src/core/transitionController.js
_transitionViews
function _transitionViews( transitionObj ) { if( !transitionObj ){ return TransitionController.error('transition is not defined'); } const transitionModule = _options.transitions[ transitionObj.transitionType ]; if( transitionModule ) { const deferred = Deferred(), views = transitionObj.views, currentViewRef = transitionObj.currentViewID, nextViewRef = transitionObj.nextViewID; /* individual transition completed */ deferred.promise.then( () => { transitionComplete.dispatch( transitionObj ); TransitionController.log( transitionObj.transitionType +' -- completed'); }); if( transitionModule.initialize ){ transitionModule.initialize( views, transitionObj.data, deferred, currentViewRef, nextViewRef ); } transitionStarted.dispatch( transitionObj ); TransitionController.log( transitionObj.transitionType +' -- started'); transitionModule.animate( views, transitionObj.data, deferred, currentViewRef, nextViewRef ); return deferred.promise; } else { TransitionController.error(transitionObj.transitionType + ' does NOT exist' ); } }
javascript
function _transitionViews( transitionObj ) { if( !transitionObj ){ return TransitionController.error('transition is not defined'); } const transitionModule = _options.transitions[ transitionObj.transitionType ]; if( transitionModule ) { const deferred = Deferred(), views = transitionObj.views, currentViewRef = transitionObj.currentViewID, nextViewRef = transitionObj.nextViewID; /* individual transition completed */ deferred.promise.then( () => { transitionComplete.dispatch( transitionObj ); TransitionController.log( transitionObj.transitionType +' -- completed'); }); if( transitionModule.initialize ){ transitionModule.initialize( views, transitionObj.data, deferred, currentViewRef, nextViewRef ); } transitionStarted.dispatch( transitionObj ); TransitionController.log( transitionObj.transitionType +' -- started'); transitionModule.animate( views, transitionObj.data, deferred, currentViewRef, nextViewRef ); return deferred.promise; } else { TransitionController.error(transitionObj.transitionType + ' does NOT exist' ); } }
[ "function", "_transitionViews", "(", "transitionObj", ")", "{", "if", "(", "!", "transitionObj", ")", "{", "return", "TransitionController", ".", "error", "(", "'transition is not defined'", ")", ";", "}", "const", "transitionModule", "=", "_options", ".", "transitions", "[", "transitionObj", ".", "transitionType", "]", ";", "if", "(", "transitionModule", ")", "{", "const", "deferred", "=", "Deferred", "(", ")", ",", "views", "=", "transitionObj", ".", "views", ",", "currentViewRef", "=", "transitionObj", ".", "currentViewID", ",", "nextViewRef", "=", "transitionObj", ".", "nextViewID", ";", "/* individual transition completed */", "deferred", ".", "promise", ".", "then", "(", "(", ")", "=>", "{", "transitionComplete", ".", "dispatch", "(", "transitionObj", ")", ";", "TransitionController", ".", "log", "(", "transitionObj", ".", "transitionType", "+", "' -- completed'", ")", ";", "}", ")", ";", "if", "(", "transitionModule", ".", "initialize", ")", "{", "transitionModule", ".", "initialize", "(", "views", ",", "transitionObj", ".", "data", ",", "deferred", ",", "currentViewRef", ",", "nextViewRef", ")", ";", "}", "transitionStarted", ".", "dispatch", "(", "transitionObj", ")", ";", "TransitionController", ".", "log", "(", "transitionObj", ".", "transitionType", "+", "' -- started'", ")", ";", "transitionModule", ".", "animate", "(", "views", ",", "transitionObj", ".", "data", ",", "deferred", ",", "currentViewRef", ",", "nextViewRef", ")", ";", "return", "deferred", ".", "promise", ";", "}", "else", "{", "TransitionController", ".", "error", "(", "transitionObj", ".", "transitionType", "+", "' does NOT exist'", ")", ";", "}", "}" ]
transition the views, find the transition module if it exists then pass in the linked views, data and settings @param {onject} transitionObj - contains {transitionType, views, currentViewID, nextViewID} @param {array} viewsToDispose - array to store the views passed to each module to dispatch on transition completed @return {array} promises from Deferred
[ "transition", "the", "views", "find", "the", "transition", "module", "if", "it", "exists", "then", "pass", "in", "the", "linked", "views", "data", "and", "settings" ]
a20fda0bb07c0098bf709ea03770b1ee2a855655
https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionController.js#L42-L73
44,772
socialally/air
lib/air/template.js
template
function template(source, target) { source = source || {}; target = target || {}; for(var z in source) { target[z] = $.partial(source[z]); } return target; }
javascript
function template(source, target) { source = source || {}; target = target || {}; for(var z in source) { target[z] = $.partial(source[z]); } return target; }
[ "function", "template", "(", "source", ",", "target", ")", "{", "source", "=", "source", "||", "{", "}", ";", "target", "=", "target", "||", "{", "}", ";", "for", "(", "var", "z", "in", "source", ")", "{", "target", "[", "z", "]", "=", "$", ".", "partial", "(", "source", "[", "z", "]", ")", ";", "}", "return", "target", ";", "}" ]
Get a map of template elements. Source object is id => selector, target object is id => elements(s).
[ "Get", "a", "map", "of", "template", "elements", "." ]
a3d94de58aaa4930a425fbcc7266764bf6ca8ca6
https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/template.js#L10-L17
44,773
socialally/air
lib/air/template.js
swap
function swap(source, target) { // wrap to allow string selectors, arrays etc. source = $(source); target = $(target); source.each(function(el, index) { var content = target.get(index); if(el.parentNode && content) { // deep clone template partial content = content.cloneNode(true); // replace sourc element with cloned target element el.parentNode.replaceChild(content, el); } }) }
javascript
function swap(source, target) { // wrap to allow string selectors, arrays etc. source = $(source); target = $(target); source.each(function(el, index) { var content = target.get(index); if(el.parentNode && content) { // deep clone template partial content = content.cloneNode(true); // replace sourc element with cloned target element el.parentNode.replaceChild(content, el); } }) }
[ "function", "swap", "(", "source", ",", "target", ")", "{", "// wrap to allow string selectors, arrays etc.", "source", "=", "$", "(", "source", ")", ";", "target", "=", "$", "(", "target", ")", ";", "source", ".", "each", "(", "function", "(", "el", ",", "index", ")", "{", "var", "content", "=", "target", ".", "get", "(", "index", ")", ";", "if", "(", "el", ".", "parentNode", "&&", "content", ")", "{", "// deep clone template partial", "content", "=", "content", ".", "cloneNode", "(", "true", ")", ";", "// replace sourc element with cloned target element", "el", ".", "parentNode", ".", "replaceChild", "(", "content", ",", "el", ")", ";", "}", "}", ")", "}" ]
Swap a source list of element's with a target list of element's. The target elements are cloned as they should be template partials, the source element(s) should exist in the DOM.
[ "Swap", "a", "source", "list", "of", "element", "s", "with", "a", "target", "list", "of", "element", "s", "." ]
a3d94de58aaa4930a425fbcc7266764bf6ca8ca6
https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/template.js#L39-L52
44,774
kbremner/grunt-dropbox
tasks/dropbox.js
createUploadPromise
function createUploadPromise(filepath, destination, options) { return function () { // get the name of the file and construct the url for uploading it var filename = getFilename(filepath), dropboxPath = destination + (options.version_name ? ("/" + options.version_name + "/") : "/") + filepath, // read the file and start the upload, decrementing the in-flight count when complete // Use encoding = null to keep the file as a Buffer reqOptions = { access_token: options.access_token, dropboxPath: dropboxPath, fileBuffer: grunt.file.read(filepath, { encoding : null }) }; grunt.log.writeln("Uploading " + filepath + " to " + dropboxPath + "..."); // return the upload promise return dropboxClient.upload(reqOptions); }; }
javascript
function createUploadPromise(filepath, destination, options) { return function () { // get the name of the file and construct the url for uploading it var filename = getFilename(filepath), dropboxPath = destination + (options.version_name ? ("/" + options.version_name + "/") : "/") + filepath, // read the file and start the upload, decrementing the in-flight count when complete // Use encoding = null to keep the file as a Buffer reqOptions = { access_token: options.access_token, dropboxPath: dropboxPath, fileBuffer: grunt.file.read(filepath, { encoding : null }) }; grunt.log.writeln("Uploading " + filepath + " to " + dropboxPath + "..."); // return the upload promise return dropboxClient.upload(reqOptions); }; }
[ "function", "createUploadPromise", "(", "filepath", ",", "destination", ",", "options", ")", "{", "return", "function", "(", ")", "{", "// get the name of the file and construct the url for uploading it", "var", "filename", "=", "getFilename", "(", "filepath", ")", ",", "dropboxPath", "=", "destination", "+", "(", "options", ".", "version_name", "?", "(", "\"/\"", "+", "options", ".", "version_name", "+", "\"/\"", ")", ":", "\"/\"", ")", "+", "filepath", ",", "// read the file and start the upload, decrementing the in-flight count when complete", "// Use encoding = null to keep the file as a Buffer", "reqOptions", "=", "{", "access_token", ":", "options", ".", "access_token", ",", "dropboxPath", ":", "dropboxPath", ",", "fileBuffer", ":", "grunt", ".", "file", ".", "read", "(", "filepath", ",", "{", "encoding", ":", "null", "}", ")", "}", ";", "grunt", ".", "log", ".", "writeln", "(", "\"Uploading \"", "+", "filepath", "+", "\" to \"", "+", "dropboxPath", "+", "\"...\"", ")", ";", "// return the upload promise", "return", "dropboxClient", ".", "upload", "(", "reqOptions", ")", ";", "}", ";", "}" ]
returns a function that creates a promise to upload the file to the destination
[ "returns", "a", "function", "that", "creates", "a", "promise", "to", "upload", "the", "file", "to", "the", "destination" ]
3f3b354b9f5f2bd1a42bf1e3cbde382a9583db08
https://github.com/kbremner/grunt-dropbox/blob/3f3b354b9f5f2bd1a42bf1e3cbde382a9583db08/tasks/dropbox.js#L46-L64
44,775
wunderbyte/grunt-spiritual-build
tasks/guibundles.js
process
function process(sources, options) { sources = explodeall(sources); if (!grunt.fail.errorcount) { var content = extract(sources, options); return enclose(content.join(SPACER)); } }
javascript
function process(sources, options) { sources = explodeall(sources); if (!grunt.fail.errorcount) { var content = extract(sources, options); return enclose(content.join(SPACER)); } }
[ "function", "process", "(", "sources", ",", "options", ")", "{", "sources", "=", "explodeall", "(", "sources", ")", ";", "if", "(", "!", "grunt", ".", "fail", ".", "errorcount", ")", "{", "var", "content", "=", "extract", "(", "sources", ",", "options", ")", ";", "return", "enclose", "(", "content", ".", "join", "(", "SPACER", ")", ")", ";", "}", "}" ]
Process sources with options. @param {Array<string>} sources @param {object} options @returns {string}
[ "Process", "sources", "with", "options", "." ]
6676b699904fe72f899fe7b88871de5ef23a23c3
https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/tasks/guibundles.js#L60-L66
44,776
wunderbyte/grunt-spiritual-build
tasks/guibundles.js
extract
function extract(sources, options) { return sources .map(function(src) { return [src, grunt.file.read(src)]; }) .filter(function(list) { return syntax.valid(grunt, list[0], list[1]); }) .map(function(list) { return extras(list[0], list[1], options); }); }
javascript
function extract(sources, options) { return sources .map(function(src) { return [src, grunt.file.read(src)]; }) .filter(function(list) { return syntax.valid(grunt, list[0], list[1]); }) .map(function(list) { return extras(list[0], list[1], options); }); }
[ "function", "extract", "(", "sources", ",", "options", ")", "{", "return", "sources", ".", "map", "(", "function", "(", "src", ")", "{", "return", "[", "src", ",", "grunt", ".", "file", ".", "read", "(", "src", ")", "]", ";", "}", ")", ".", "filter", "(", "function", "(", "list", ")", "{", "return", "syntax", ".", "valid", "(", "grunt", ",", "list", "[", "0", "]", ",", "list", "[", "1", "]", ")", ";", "}", ")", ".", "map", "(", "function", "(", "list", ")", "{", "return", "extras", "(", "list", "[", "0", "]", ",", "list", "[", "1", "]", ",", "options", ")", ";", "}", ")", ";", "}" ]
Extract content from files and parse through various options. @param {Array<string>} sources @param {object} options @returns {Array<string>}
[ "Extract", "content", "from", "files", "and", "parse", "through", "various", "options", "." ]
6676b699904fe72f899fe7b88871de5ef23a23c3
https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/tasks/guibundles.js#L75-L86
44,777
wunderbyte/grunt-spiritual-build
tasks/guibundles.js
writefile
function writefile(filepath, filetext, options) { var version = '-1.0.0'; var packag = filename('package.json', options); var banner = filename('BANNER.txt', options); if (grunt.file.exists(banner)) { filetext = grunt.file.read(banner) + '\n' + filetext; } if (grunt.file.exists(packag)) { var json = grunt.file.readJSON(packag); version = json.version; } grunt.file.write( filepath, grunt.template.process(filetext, { data: { version: version } }) ); grunt.log.writeln('File "' + chalk.cyan(filepath) + '" created.'); }
javascript
function writefile(filepath, filetext, options) { var version = '-1.0.0'; var packag = filename('package.json', options); var banner = filename('BANNER.txt', options); if (grunt.file.exists(banner)) { filetext = grunt.file.read(banner) + '\n' + filetext; } if (grunt.file.exists(packag)) { var json = grunt.file.readJSON(packag); version = json.version; } grunt.file.write( filepath, grunt.template.process(filetext, { data: { version: version } }) ); grunt.log.writeln('File "' + chalk.cyan(filepath) + '" created.'); }
[ "function", "writefile", "(", "filepath", ",", "filetext", ",", "options", ")", "{", "var", "version", "=", "'-1.0.0'", ";", "var", "packag", "=", "filename", "(", "'package.json'", ",", "options", ")", ";", "var", "banner", "=", "filename", "(", "'BANNER.txt'", ",", "options", ")", ";", "if", "(", "grunt", ".", "file", ".", "exists", "(", "banner", ")", ")", "{", "filetext", "=", "grunt", ".", "file", ".", "read", "(", "banner", ")", "+", "'\\n'", "+", "filetext", ";", "}", "if", "(", "grunt", ".", "file", ".", "exists", "(", "packag", ")", ")", "{", "var", "json", "=", "grunt", ".", "file", ".", "readJSON", "(", "packag", ")", ";", "version", "=", "json", ".", "version", ";", "}", "grunt", ".", "file", ".", "write", "(", "filepath", ",", "grunt", ".", "template", ".", "process", "(", "filetext", ",", "{", "data", ":", "{", "version", ":", "version", "}", "}", ")", ")", ";", "grunt", ".", "log", ".", "writeln", "(", "'File \"'", "+", "chalk", ".", "cyan", "(", "filepath", ")", "+", "'\" created.'", ")", ";", "}" ]
Write file and report to console. @param {String} filepath @param {String} filetext
[ "Write", "file", "and", "report", "to", "console", "." ]
6676b699904fe72f899fe7b88871de5ef23a23c3
https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/tasks/guibundles.js#L148-L168
44,778
wunderbyte/grunt-spiritual-build
tasks/guibundles.js
uglyfile
function uglyfile(prettyfile, sourcecode, options) { var mintarget = prettyfile.replace('.js', '.min.js'); var maptarget = prettyfile.replace('.js', '.js.map'); var uglycodes = uglify(options.max ? prettyfile : sourcecode); writefile(mintarget, uglycodes.code, options); if (options.map) { writefile(maptarget, uglycodes.map, options); } }
javascript
function uglyfile(prettyfile, sourcecode, options) { var mintarget = prettyfile.replace('.js', '.min.js'); var maptarget = prettyfile.replace('.js', '.js.map'); var uglycodes = uglify(options.max ? prettyfile : sourcecode); writefile(mintarget, uglycodes.code, options); if (options.map) { writefile(maptarget, uglycodes.map, options); } }
[ "function", "uglyfile", "(", "prettyfile", ",", "sourcecode", ",", "options", ")", "{", "var", "mintarget", "=", "prettyfile", ".", "replace", "(", "'.js'", ",", "'.min.js'", ")", ";", "var", "maptarget", "=", "prettyfile", ".", "replace", "(", "'.js'", ",", "'.js.map'", ")", ";", "var", "uglycodes", "=", "uglify", "(", "options", ".", "max", "?", "prettyfile", ":", "sourcecode", ")", ";", "writefile", "(", "mintarget", ",", "uglycodes", ".", "code", ",", "options", ")", ";", "if", "(", "options", ".", "map", ")", "{", "writefile", "(", "maptarget", ",", "uglycodes", ".", "map", ",", "options", ")", ";", "}", "}" ]
Write uglified file @param {string} prettyfile @param {object} options
[ "Write", "uglified", "file" ]
6676b699904fe72f899fe7b88871de5ef23a23c3
https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/tasks/guibundles.js#L175-L183
44,779
wunderbyte/grunt-spiritual-build
tasks/guibundles.js
uglify
function uglify(prettyfile, sourcecode) { console.warn( 'Not quite getting the right path to source in the map :/' ); return ugli.minify(sourcecode || prettyfile, { fromString: sourcecode !== undefined, outSourceMap: path.basename(prettyfile) + '.map', compress: { warnings: false } }); }
javascript
function uglify(prettyfile, sourcecode) { console.warn( 'Not quite getting the right path to source in the map :/' ); return ugli.minify(sourcecode || prettyfile, { fromString: sourcecode !== undefined, outSourceMap: path.basename(prettyfile) + '.map', compress: { warnings: false } }); }
[ "function", "uglify", "(", "prettyfile", ",", "sourcecode", ")", "{", "console", ".", "warn", "(", "'Not quite getting the right path to source in the map :/'", ")", ";", "return", "ugli", ".", "minify", "(", "sourcecode", "||", "prettyfile", ",", "{", "fromString", ":", "sourcecode", "!==", "undefined", ",", "outSourceMap", ":", "path", ".", "basename", "(", "prettyfile", ")", "+", "'.map'", ",", "compress", ":", "{", "warnings", ":", "false", "}", "}", ")", ";", "}" ]
Uglify file or sourcecode string. @param {string} prettyfile @param @optional {string} sourcecode
[ "Uglify", "file", "or", "sourcecode", "string", "." ]
6676b699904fe72f899fe7b88871de5ef23a23c3
https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/tasks/guibundles.js#L190-L201
44,780
leomp12/nodejs-rest-auto-router
main.js
function (obj, meta, status = 200, errorCode = -1, devMsg = null, usrMsg = null, moreInfo = null) { if (res.finished) { // request ended return } // ref.: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html if (status < 300) { // OK // respond client and close request let body switch (typeof obj) { case 'object': // expected if (meta) { res.setHeader('X-Metadata', 'true') body = JSON.stringify({ 'meta': meta, 'result': obj }) } else { body = JSON.stringify(obj) } break case 'string': case 'number': // maybe an ID returned after modification request body = JSON.stringify({ 'result': obj }) break default: // return null JSON object body = '{}' } if (verb === 'GET') { // ETag to verify browser cache validation // have to be set here, web servers will not etag proxy requests // Cloudflare keep only weak ETags res.setHeader('ETag', etag(body, { 'weak': true })) } res.writeHead(status) res.end(body) } else if (status < 400 && typeof obj === 'string') { // redirect // expect obj to be the redirect URL // return object with previous and next (after redirect) URL let response = { 'status': status, 'requested_url': req.url, 'endpoint': obj } // explain type of redirect in message if (status === 301) { response.message = 'Moved permanently, please re-send this request to the specified endpoint' } else { response.message = 'Temporary redirect, re-send this request to the specified temporary endpoint, ' + 'continue to use the original request endpoint for future requests' } res.writeHead(status, { 'Location': obj }) res.end(JSON.stringify(response)) } else if (typeof obj === 'object' && obj !== null && Object.keys(obj).length > 0) { // custom error object res.writeHead(status) res.end(JSON.stringify(obj)) } else { // client and/or server error httpErrorHandling(res, status, errorCode, devMsg, usrMsg, moreInfo) } }
javascript
function (obj, meta, status = 200, errorCode = -1, devMsg = null, usrMsg = null, moreInfo = null) { if (res.finished) { // request ended return } // ref.: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html if (status < 300) { // OK // respond client and close request let body switch (typeof obj) { case 'object': // expected if (meta) { res.setHeader('X-Metadata', 'true') body = JSON.stringify({ 'meta': meta, 'result': obj }) } else { body = JSON.stringify(obj) } break case 'string': case 'number': // maybe an ID returned after modification request body = JSON.stringify({ 'result': obj }) break default: // return null JSON object body = '{}' } if (verb === 'GET') { // ETag to verify browser cache validation // have to be set here, web servers will not etag proxy requests // Cloudflare keep only weak ETags res.setHeader('ETag', etag(body, { 'weak': true })) } res.writeHead(status) res.end(body) } else if (status < 400 && typeof obj === 'string') { // redirect // expect obj to be the redirect URL // return object with previous and next (after redirect) URL let response = { 'status': status, 'requested_url': req.url, 'endpoint': obj } // explain type of redirect in message if (status === 301) { response.message = 'Moved permanently, please re-send this request to the specified endpoint' } else { response.message = 'Temporary redirect, re-send this request to the specified temporary endpoint, ' + 'continue to use the original request endpoint for future requests' } res.writeHead(status, { 'Location': obj }) res.end(JSON.stringify(response)) } else if (typeof obj === 'object' && obj !== null && Object.keys(obj).length > 0) { // custom error object res.writeHead(status) res.end(JSON.stringify(obj)) } else { // client and/or server error httpErrorHandling(res, status, errorCode, devMsg, usrMsg, moreInfo) } }
[ "function", "(", "obj", ",", "meta", ",", "status", "=", "200", ",", "errorCode", "=", "-", "1", ",", "devMsg", "=", "null", ",", "usrMsg", "=", "null", ",", "moreInfo", "=", "null", ")", "{", "if", "(", "res", ".", "finished", ")", "{", "// request ended", "return", "}", "// ref.: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html", "if", "(", "status", "<", "300", ")", "{", "// OK", "// respond client and close request", "let", "body", "switch", "(", "typeof", "obj", ")", "{", "case", "'object'", ":", "// expected", "if", "(", "meta", ")", "{", "res", ".", "setHeader", "(", "'X-Metadata'", ",", "'true'", ")", "body", "=", "JSON", ".", "stringify", "(", "{", "'meta'", ":", "meta", ",", "'result'", ":", "obj", "}", ")", "}", "else", "{", "body", "=", "JSON", ".", "stringify", "(", "obj", ")", "}", "break", "case", "'string'", ":", "case", "'number'", ":", "// maybe an ID returned after modification request", "body", "=", "JSON", ".", "stringify", "(", "{", "'result'", ":", "obj", "}", ")", "break", "default", ":", "// return null JSON object", "body", "=", "'{}'", "}", "if", "(", "verb", "===", "'GET'", ")", "{", "// ETag to verify browser cache validation", "// have to be set here, web servers will not etag proxy requests", "// Cloudflare keep only weak ETags", "res", ".", "setHeader", "(", "'ETag'", ",", "etag", "(", "body", ",", "{", "'weak'", ":", "true", "}", ")", ")", "}", "res", ".", "writeHead", "(", "status", ")", "res", ".", "end", "(", "body", ")", "}", "else", "if", "(", "status", "<", "400", "&&", "typeof", "obj", "===", "'string'", ")", "{", "// redirect", "// expect obj to be the redirect URL", "// return object with previous and next (after redirect) URL", "let", "response", "=", "{", "'status'", ":", "status", ",", "'requested_url'", ":", "req", ".", "url", ",", "'endpoint'", ":", "obj", "}", "// explain type of redirect in message", "if", "(", "status", "===", "301", ")", "{", "response", ".", "message", "=", "'Moved permanently, please re-send this request to the specified endpoint'", "}", "else", "{", "response", ".", "message", "=", "'Temporary redirect, re-send this request to the specified temporary endpoint, '", "+", "'continue to use the original request endpoint for future requests'", "}", "res", ".", "writeHead", "(", "status", ",", "{", "'Location'", ":", "obj", "}", ")", "res", ".", "end", "(", "JSON", ".", "stringify", "(", "response", ")", ")", "}", "else", "if", "(", "typeof", "obj", "===", "'object'", "&&", "obj", "!==", "null", "&&", "Object", ".", "keys", "(", "obj", ")", ".", "length", ">", "0", ")", "{", "// custom error object", "res", ".", "writeHead", "(", "status", ")", "res", ".", "end", "(", "JSON", ".", "stringify", "(", "obj", ")", ")", "}", "else", "{", "// client and/or server error", "httpErrorHandling", "(", "res", ",", "status", ",", "errorCode", ",", "devMsg", ",", "usrMsg", ",", "moreInfo", ")", "}", "}" ]
respond client and close request
[ "respond", "client", "and", "close", "request" ]
eec413b9fd4565c5471f6eff11c316e6a984d110
https://github.com/leomp12/nodejs-rest-auto-router/blob/eec413b9fd4565c5471f6eff11c316e6a984d110/main.js#L183-L251
44,781
odogono/elsinore-js
src/query/without.js
without
function without(componentIDs) { const context = this.readContext(this); context.pushOp(WITHOUT); // the preceeding command is used as the first argument context.pushVal(componentIDs, true); return context; }
javascript
function without(componentIDs) { const context = this.readContext(this); context.pushOp(WITHOUT); // the preceeding command is used as the first argument context.pushVal(componentIDs, true); return context; }
[ "function", "without", "(", "componentIDs", ")", "{", "const", "context", "=", "this", ".", "readContext", "(", "this", ")", ";", "context", ".", "pushOp", "(", "WITHOUT", ")", ";", "// the preceeding command is used as the first argument", "context", ".", "pushVal", "(", "componentIDs", ",", "true", ")", ";", "return", "context", ";", "}" ]
Returns a value with componentsIDs with all of values excluded
[ "Returns", "a", "value", "with", "componentsIDs", "with", "all", "of", "values", "excluded" ]
1ecce67ad0022646419a740def029b1ba92dd558
https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/query/without.js#L15-L23
44,782
CodeboxIDE/large-watcher
index.js
dualDiff
function dualDiff(a1, a2) { var o1={}, o2={}, diff1=[], diff2=[], i, len, k; for (i=0, len=a1.length; i<len; i++) { o1[a1[i]] = true; } for (i=0, len=a2.length; i<len; i++) { o2[a2[i]] = true; } for (k in o1) { if (!(k in o2)) { diff1.push(k); } } for (k in o2) { if (!(k in o1)) { diff2.push(k); } } return [diff1, diff2]; }
javascript
function dualDiff(a1, a2) { var o1={}, o2={}, diff1=[], diff2=[], i, len, k; for (i=0, len=a1.length; i<len; i++) { o1[a1[i]] = true; } for (i=0, len=a2.length; i<len; i++) { o2[a2[i]] = true; } for (k in o1) { if (!(k in o2)) { diff1.push(k); } } for (k in o2) { if (!(k in o1)) { diff2.push(k); } } return [diff1, diff2]; }
[ "function", "dualDiff", "(", "a1", ",", "a2", ")", "{", "var", "o1", "=", "{", "}", ",", "o2", "=", "{", "}", ",", "diff1", "=", "[", "]", ",", "diff2", "=", "[", "]", ",", "i", ",", "len", ",", "k", ";", "for", "(", "i", "=", "0", ",", "len", "=", "a1", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "o1", "[", "a1", "[", "i", "]", "]", "=", "true", ";", "}", "for", "(", "i", "=", "0", ",", "len", "=", "a2", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "o2", "[", "a2", "[", "i", "]", "]", "=", "true", ";", "}", "for", "(", "k", "in", "o1", ")", "{", "if", "(", "!", "(", "k", "in", "o2", ")", ")", "{", "diff1", ".", "push", "(", "k", ")", ";", "}", "}", "for", "(", "k", "in", "o2", ")", "{", "if", "(", "!", "(", "k", "in", "o1", ")", ")", "{", "diff2", ".", "push", "(", "k", ")", ";", "}", "}", "return", "[", "diff1", ",", "diff2", "]", ";", "}" ]
Returns both the left and right diff seperately
[ "Returns", "both", "the", "left", "and", "right", "diff", "seperately" ]
876af5d8964b73348d5bcaaecff9b4d3fb7f8d03
https://github.com/CodeboxIDE/large-watcher/blob/876af5d8964b73348d5bcaaecff9b4d3fb7f8d03/index.js#L228-L235
44,783
Notificare/notificare-live-api-node
lib/util/crypto.js
generateHmac
function generateHmac(data, key, encoding) { var hmac = crypto.createHmac(HMAC_SHA256_ALGORITHM, key); hmac.update(data); return hmac.digest(encoding); }
javascript
function generateHmac(data, key, encoding) { var hmac = crypto.createHmac(HMAC_SHA256_ALGORITHM, key); hmac.update(data); return hmac.digest(encoding); }
[ "function", "generateHmac", "(", "data", ",", "key", ",", "encoding", ")", "{", "var", "hmac", "=", "crypto", ".", "createHmac", "(", "HMAC_SHA256_ALGORITHM", ",", "key", ")", ";", "hmac", ".", "update", "(", "data", ")", ";", "return", "hmac", ".", "digest", "(", "encoding", ")", ";", "}" ]
Generate a HMAC for the given data @param {String} data @param {String} key @param {String} encoding @returns {String|Buffer} will return a Buffer if no encoding given
[ "Generate", "a", "HMAC", "for", "the", "given", "data" ]
98d17dcc1ae3f9d58d478f27e796222aa44c6eae
https://github.com/Notificare/notificare-live-api-node/blob/98d17dcc1ae3f9d58d478f27e796222aa44c6eae/lib/util/crypto.js#L15-L19
44,784
socialally/air
lib/air/css.js
css
function css(key, val) { var style, props; if(!this.length) { return this; } if(key && typeof key === 'object') { props = key; }else if(key && val) { props = {}; props[key] = val; } // get style object if(key === undefined) { style = window.getComputedStyle(this.dom[0], null); // TODO: convert to plain object map? // for the moment return CSSStyleDeclaration return style; // get single style property value }else if(typeof key === 'string' && !val) { style = window.getComputedStyle(this.dom[0], null); return style.getPropertyValue(key); } // set inline styles this.each(function(el) { el.style = el.style; for(var z in props) { el.style[z] = '' + props[z]; } }); return this; }
javascript
function css(key, val) { var style, props; if(!this.length) { return this; } if(key && typeof key === 'object') { props = key; }else if(key && val) { props = {}; props[key] = val; } // get style object if(key === undefined) { style = window.getComputedStyle(this.dom[0], null); // TODO: convert to plain object map? // for the moment return CSSStyleDeclaration return style; // get single style property value }else if(typeof key === 'string' && !val) { style = window.getComputedStyle(this.dom[0], null); return style.getPropertyValue(key); } // set inline styles this.each(function(el) { el.style = el.style; for(var z in props) { el.style[z] = '' + props[z]; } }); return this; }
[ "function", "css", "(", "key", ",", "val", ")", "{", "var", "style", ",", "props", ";", "if", "(", "!", "this", ".", "length", ")", "{", "return", "this", ";", "}", "if", "(", "key", "&&", "typeof", "key", "===", "'object'", ")", "{", "props", "=", "key", ";", "}", "else", "if", "(", "key", "&&", "val", ")", "{", "props", "=", "{", "}", ";", "props", "[", "key", "]", "=", "val", ";", "}", "// get style object", "if", "(", "key", "===", "undefined", ")", "{", "style", "=", "window", ".", "getComputedStyle", "(", "this", ".", "dom", "[", "0", "]", ",", "null", ")", ";", "// TODO: convert to plain object map?", "// for the moment return CSSStyleDeclaration", "return", "style", ";", "// get single style property value", "}", "else", "if", "(", "typeof", "key", "===", "'string'", "&&", "!", "val", ")", "{", "style", "=", "window", ".", "getComputedStyle", "(", "this", ".", "dom", "[", "0", "]", ",", "null", ")", ";", "return", "style", ".", "getPropertyValue", "(", "key", ")", ";", "}", "// set inline styles", "this", ".", "each", "(", "function", "(", "el", ")", "{", "el", ".", "style", "=", "el", ".", "style", ";", "for", "(", "var", "z", "in", "props", ")", "{", "el", ".", "style", "[", "z", "]", "=", "''", "+", "props", "[", "z", "]", ";", "}", "}", ")", ";", "return", "this", ";", "}" ]
Get the value of a computed style property for the first element in the set of matched elements or set one or more CSS properties for every matched element.
[ "Get", "the", "value", "of", "a", "computed", "style", "property", "for", "the", "first", "element", "in", "the", "set", "of", "matched", "elements", "or", "set", "one", "or", "more", "CSS", "properties", "for", "every", "matched", "element", "." ]
a3d94de58aaa4930a425fbcc7266764bf6ca8ca6
https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/css.js#L6-L39
44,785
Whitebolt/require-extra
src/import.js
_filesInDirectory
async function _filesInDirectory(dirPath, options) { const basedir = options.basedir || getCallingDir(); const resolvedDirPath = basedir?path.resolve(basedir, dirPath):dirPath; let xExt = _getExtensionRegEx(options.extension || settings.get('extensions')); try { const files = (await readDir(resolvedDirPath)); if (options.rescursive) { const dirs = chain(await Promise.all(chain(files) .map(fileName=>path.resolve(resolvedDirPath, fileName)) .map(async (file)=>{ const stat = await lstat(file); if (stat.isDirectory()) return file; }) .value())).filter(file=>file); if (dirs.value().length) files.push(...(await Promise.all( dirs.map(dirPath=>_filesInDirectory(dirPath, options)).value() ))); } return chain(files) .flattenDeep() .filter(fileName=>xExt.test(fileName)) .map(fileName=>path.resolve(resolvedDirPath, fileName)) .value(); } catch (err) { return []; } }
javascript
async function _filesInDirectory(dirPath, options) { const basedir = options.basedir || getCallingDir(); const resolvedDirPath = basedir?path.resolve(basedir, dirPath):dirPath; let xExt = _getExtensionRegEx(options.extension || settings.get('extensions')); try { const files = (await readDir(resolvedDirPath)); if (options.rescursive) { const dirs = chain(await Promise.all(chain(files) .map(fileName=>path.resolve(resolvedDirPath, fileName)) .map(async (file)=>{ const stat = await lstat(file); if (stat.isDirectory()) return file; }) .value())).filter(file=>file); if (dirs.value().length) files.push(...(await Promise.all( dirs.map(dirPath=>_filesInDirectory(dirPath, options)).value() ))); } return chain(files) .flattenDeep() .filter(fileName=>xExt.test(fileName)) .map(fileName=>path.resolve(resolvedDirPath, fileName)) .value(); } catch (err) { return []; } }
[ "async", "function", "_filesInDirectory", "(", "dirPath", ",", "options", ")", "{", "const", "basedir", "=", "options", ".", "basedir", "||", "getCallingDir", "(", ")", ";", "const", "resolvedDirPath", "=", "basedir", "?", "path", ".", "resolve", "(", "basedir", ",", "dirPath", ")", ":", "dirPath", ";", "let", "xExt", "=", "_getExtensionRegEx", "(", "options", ".", "extension", "||", "settings", ".", "get", "(", "'extensions'", ")", ")", ";", "try", "{", "const", "files", "=", "(", "await", "readDir", "(", "resolvedDirPath", ")", ")", ";", "if", "(", "options", ".", "rescursive", ")", "{", "const", "dirs", "=", "chain", "(", "await", "Promise", ".", "all", "(", "chain", "(", "files", ")", ".", "map", "(", "fileName", "=>", "path", ".", "resolve", "(", "resolvedDirPath", ",", "fileName", ")", ")", ".", "map", "(", "async", "(", "file", ")", "=>", "{", "const", "stat", "=", "await", "lstat", "(", "file", ")", ";", "if", "(", "stat", ".", "isDirectory", "(", ")", ")", "return", "file", ";", "}", ")", ".", "value", "(", ")", ")", ")", ".", "filter", "(", "file", "=>", "file", ")", ";", "if", "(", "dirs", ".", "value", "(", ")", ".", "length", ")", "files", ".", "push", "(", "...", "(", "await", "Promise", ".", "all", "(", "dirs", ".", "map", "(", "dirPath", "=>", "_filesInDirectory", "(", "dirPath", ",", "options", ")", ")", ".", "value", "(", ")", ")", ")", ")", ";", "}", "return", "chain", "(", "files", ")", ".", "flattenDeep", "(", ")", ".", "filter", "(", "fileName", "=>", "xExt", ".", "test", "(", "fileName", ")", ")", ".", "map", "(", "fileName", "=>", "path", ".", "resolve", "(", "resolvedDirPath", ",", "fileName", ")", ")", ".", "value", "(", ")", ";", "}", "catch", "(", "err", ")", "{", "return", "[", "]", ";", "}", "}" ]
Get a list of files in the directory. @private @param {string} dirPath Directory path to scan. @param {Object} [options] Import options object. @returns {Promise.<string[]>} Promise resolving to array of files.
[ "Get", "a", "list", "of", "files", "in", "the", "directory", "." ]
2a8f737aab67305c9fda3ee56aa7953e97cee859
https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L32-L59
44,786
Whitebolt/require-extra
src/import.js
filesInDirectories
async function filesInDirectories(dirPaths, options) { let files = await Promise.all(makeArray(dirPaths).map(dirPath=>_filesInDirectory(dirPath, options))); return flattenDeep(files); }
javascript
async function filesInDirectories(dirPaths, options) { let files = await Promise.all(makeArray(dirPaths).map(dirPath=>_filesInDirectory(dirPath, options))); return flattenDeep(files); }
[ "async", "function", "filesInDirectories", "(", "dirPaths", ",", "options", ")", "{", "let", "files", "=", "await", "Promise", ".", "all", "(", "makeArray", "(", "dirPaths", ")", ".", "map", "(", "dirPath", "=>", "_filesInDirectory", "(", "dirPath", ",", "options", ")", ")", ")", ";", "return", "flattenDeep", "(", "files", ")", ";", "}" ]
Get all the files in a collection of directories. @param {Array|Set|string} dirPaths Path(s) to get files from. @param [options] Import options object.
[ "Get", "all", "the", "files", "in", "a", "collection", "of", "directories", "." ]
2a8f737aab67305c9fda3ee56aa7953e97cee859
https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L67-L70
44,787
Whitebolt/require-extra
src/import.js
_getExtensionRegEx
function _getExtensionRegEx(ext=settings.get('extensions')) { let _ext = '(?:' + makeArray(ext).join('|') + ')'; return new RegExp(_ext + '$'); }
javascript
function _getExtensionRegEx(ext=settings.get('extensions')) { let _ext = '(?:' + makeArray(ext).join('|') + ')'; return new RegExp(_ext + '$'); }
[ "function", "_getExtensionRegEx", "(", "ext", "=", "settings", ".", "get", "(", "'extensions'", ")", ")", "{", "let", "_ext", "=", "'(?:'", "+", "makeArray", "(", "ext", ")", ".", "join", "(", "'|'", ")", "+", "')'", ";", "return", "new", "RegExp", "(", "_ext", "+", "'$'", ")", ";", "}" ]
Get a regular expression for the given selection of file extensions, which will then be able to match file paths, which have those extensions. @private @param {Array|string} [ext=config.get('extensions')] The extension(s). @returns {RegExp} File path matcher.
[ "Get", "a", "regular", "expression", "for", "the", "given", "selection", "of", "file", "extensions", "which", "will", "then", "be", "able", "to", "match", "file", "paths", "which", "have", "those", "extensions", "." ]
2a8f737aab67305c9fda3ee56aa7953e97cee859
https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L93-L96
44,788
Whitebolt/require-extra
src/import.js
_canImport
function _canImport(fileName, callingFileName, options) { if (callingFileName && (fileName === callingFileName)) return false; let _fileName = _getFileTests(fileName, options); if (options.includes) return (intersection(options.includes, _fileName).length > 0); if (options.excludes) return (intersection(options.includes, _fileName).length === 0); return true; }
javascript
function _canImport(fileName, callingFileName, options) { if (callingFileName && (fileName === callingFileName)) return false; let _fileName = _getFileTests(fileName, options); if (options.includes) return (intersection(options.includes, _fileName).length > 0); if (options.excludes) return (intersection(options.includes, _fileName).length === 0); return true; }
[ "function", "_canImport", "(", "fileName", ",", "callingFileName", ",", "options", ")", "{", "if", "(", "callingFileName", "&&", "(", "fileName", "===", "callingFileName", ")", ")", "return", "false", ";", "let", "_fileName", "=", "_getFileTests", "(", "fileName", ",", "options", ")", ";", "if", "(", "options", ".", "includes", ")", "return", "(", "intersection", "(", "options", ".", "includes", ",", "_fileName", ")", ".", "length", ">", "0", ")", ";", "if", "(", "options", ".", "excludes", ")", "return", "(", "intersection", "(", "options", ".", "includes", ",", "_fileName", ")", ".", "length", "===", "0", ")", ";", "return", "true", ";", "}" ]
Can a filename be imported according to the rules the supplied options. @private @param {string} fileName Filename to test. @param {string} callingFileName Calling filename (file doing the import). @param {Object} options Import/Export options. @returns {boolean}
[ "Can", "a", "filename", "be", "imported", "according", "to", "the", "rules", "the", "supplied", "options", "." ]
2a8f737aab67305c9fda3ee56aa7953e97cee859
https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L124-L130
44,789
Whitebolt/require-extra
src/import.js
_importDirectoryOptionsParser
function _importDirectoryOptionsParser(options={}) { const _options = Object.assign({ imports: {}, onload: options.callback, extension: makeArray(options.extensions || settings.get('extensions')), useSyncRequire: settings.get('useSyncRequire'), merge: settings.get('mergeImports'), rescursive: false }, options, { squashErrors: !!options.retry }); if (_options.extensions) delete _options.extensions; if (options.callback) console.warn(`The options.callback method is deprecated, please use options.onload() instead. This being used in ${getCallingFileName()}`); return _options; }
javascript
function _importDirectoryOptionsParser(options={}) { const _options = Object.assign({ imports: {}, onload: options.callback, extension: makeArray(options.extensions || settings.get('extensions')), useSyncRequire: settings.get('useSyncRequire'), merge: settings.get('mergeImports'), rescursive: false }, options, { squashErrors: !!options.retry }); if (_options.extensions) delete _options.extensions; if (options.callback) console.warn(`The options.callback method is deprecated, please use options.onload() instead. This being used in ${getCallingFileName()}`); return _options; }
[ "function", "_importDirectoryOptionsParser", "(", "options", "=", "{", "}", ")", "{", "const", "_options", "=", "Object", ".", "assign", "(", "{", "imports", ":", "{", "}", ",", "onload", ":", "options", ".", "callback", ",", "extension", ":", "makeArray", "(", "options", ".", "extensions", "||", "settings", ".", "get", "(", "'extensions'", ")", ")", ",", "useSyncRequire", ":", "settings", ".", "get", "(", "'useSyncRequire'", ")", ",", "merge", ":", "settings", ".", "get", "(", "'mergeImports'", ")", ",", "rescursive", ":", "false", "}", ",", "options", ",", "{", "squashErrors", ":", "!", "!", "options", ".", "retry", "}", ")", ";", "if", "(", "_options", ".", "extensions", ")", "delete", "_options", ".", "extensions", ";", "if", "(", "options", ".", "callback", ")", "console", ".", "warn", "(", "`", "${", "getCallingFileName", "(", ")", "}", "`", ")", ";", "return", "_options", ";", "}" ]
Parse the input options, filling-in any defaults. @private @param {Object} [options={}] The options to parse. @returns {Object}
[ "Parse", "the", "input", "options", "filling", "-", "in", "any", "defaults", "." ]
2a8f737aab67305c9fda3ee56aa7953e97cee859
https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L157-L174
44,790
Whitebolt/require-extra
src/import.js
importDirectory
function importDirectory(dirPath, options, callback) { if (!callback) return _importDirectory(dirPath, options); _importDirectory(dirPath, options).then( imports=>setImmediate(()=>callback(null, imports)), err=>setImmediate(()=>callback(err, undefined)) ); }
javascript
function importDirectory(dirPath, options, callback) { if (!callback) return _importDirectory(dirPath, options); _importDirectory(dirPath, options).then( imports=>setImmediate(()=>callback(null, imports)), err=>setImmediate(()=>callback(err, undefined)) ); }
[ "function", "importDirectory", "(", "dirPath", ",", "options", ",", "callback", ")", "{", "if", "(", "!", "callback", ")", "return", "_importDirectory", "(", "dirPath", ",", "options", ")", ";", "_importDirectory", "(", "dirPath", ",", "options", ")", ".", "then", "(", "imports", "=>", "setImmediate", "(", "(", ")", "=>", "callback", "(", "null", ",", "imports", ")", ")", ",", "err", "=>", "setImmediate", "(", "(", ")", "=>", "callback", "(", "err", ",", "undefined", ")", ")", ")", ";", "}" ]
Import all the modules in a set of given paths,according to the supplied options. @public @param {string|Array.<string>} dirPath The path(s) to import from. @param {Object} [options=''] The option to use in the import. @param {Function} [callback] Node-style callback to fire, use if you do not want a promise. @returns {Promise.<Object>}
[ "Import", "all", "the", "modules", "in", "a", "set", "of", "given", "paths", "according", "to", "the", "supplied", "options", "." ]
2a8f737aab67305c9fda3ee56aa7953e97cee859
https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L243-L249
44,791
odogono/elsinore-js
src/error/index.js
captureStackTrace
function captureStackTrace(error, constructor) { if (Error.captureStackTrace) { Error.captureStackTrace(error, constructor); } else { error.stack = new Error().stack; } }
javascript
function captureStackTrace(error, constructor) { if (Error.captureStackTrace) { Error.captureStackTrace(error, constructor); } else { error.stack = new Error().stack; } }
[ "function", "captureStackTrace", "(", "error", ",", "constructor", ")", "{", "if", "(", "Error", ".", "captureStackTrace", ")", "{", "Error", ".", "captureStackTrace", "(", "error", ",", "constructor", ")", ";", "}", "else", "{", "error", ".", "stack", "=", "new", "Error", "(", ")", ".", "stack", ";", "}", "}" ]
Error.captureStackTrace is not available in all environments, so this function wraps an alternative @param {*} error @param {*} constructor
[ "Error", ".", "captureStackTrace", "is", "not", "available", "in", "all", "environments", "so", "this", "function", "wraps", "an", "alternative" ]
1ecce67ad0022646419a740def029b1ba92dd558
https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/error/index.js#L63-L69
44,792
base/base-fs-tree
index.js
createFile
function createFile(tree, name, prop, options) { var opts = utils.extend({}, options); var str = create(tree[name], {label: 'cwd'}); var file = new utils.File({path: `${prop}-${name}.txt`, contents: new Buffer(str)}); if (typeof opts.treename === 'function') { opts.treename(file); } file.writeFile = true; file.render = false; file.layout = null; file.isTree = true; utils.contents.sync(file); return file; }
javascript
function createFile(tree, name, prop, options) { var opts = utils.extend({}, options); var str = create(tree[name], {label: 'cwd'}); var file = new utils.File({path: `${prop}-${name}.txt`, contents: new Buffer(str)}); if (typeof opts.treename === 'function') { opts.treename(file); } file.writeFile = true; file.render = false; file.layout = null; file.isTree = true; utils.contents.sync(file); return file; }
[ "function", "createFile", "(", "tree", ",", "name", ",", "prop", ",", "options", ")", "{", "var", "opts", "=", "utils", ".", "extend", "(", "{", "}", ",", "options", ")", ";", "var", "str", "=", "create", "(", "tree", "[", "name", "]", ",", "{", "label", ":", "'cwd'", "}", ")", ";", "var", "file", "=", "new", "utils", ".", "File", "(", "{", "path", ":", "`", "${", "prop", "}", "${", "name", "}", "`", ",", "contents", ":", "new", "Buffer", "(", "str", ")", "}", ")", ";", "if", "(", "typeof", "opts", ".", "treename", "===", "'function'", ")", "{", "opts", ".", "treename", "(", "file", ")", ";", "}", "file", ".", "writeFile", "=", "true", ";", "file", ".", "render", "=", "false", ";", "file", ".", "layout", "=", "null", ";", "file", ".", "isTree", "=", "true", ";", "utils", ".", "contents", ".", "sync", "(", "file", ")", ";", "return", "file", ";", "}" ]
Create a file
[ "Create", "a", "file" ]
b4b589ff85addd659d7446bf1e96b408e2fdadc5
https://github.com/base/base-fs-tree/blob/b4b589ff85addd659d7446bf1e96b408e2fdadc5/index.js#L131-L145
44,793
FinalDevStudio/fi-khipu
lib/utils.js
sortObject
function sortObject(object) { var keys = Object.keys(object); var sorted = {}; var options = { sensitivity: 'base' }; function compare(a, b) { return a.localeCompare(b, options); } keys.sort(compare); for (var index in keys) { if (keys[index]) { var key = keys[index]; if (Array.isArray(object[key])) { sorted[key] = object[key].sort(compare); } else if (typeof object[key] === 'object') { sorted[key] = sortObject(object[key]); } else { sorted[key] = object[key]; } } } return sorted; }
javascript
function sortObject(object) { var keys = Object.keys(object); var sorted = {}; var options = { sensitivity: 'base' }; function compare(a, b) { return a.localeCompare(b, options); } keys.sort(compare); for (var index in keys) { if (keys[index]) { var key = keys[index]; if (Array.isArray(object[key])) { sorted[key] = object[key].sort(compare); } else if (typeof object[key] === 'object') { sorted[key] = sortObject(object[key]); } else { sorted[key] = object[key]; } } } return sorted; }
[ "function", "sortObject", "(", "object", ")", "{", "var", "keys", "=", "Object", ".", "keys", "(", "object", ")", ";", "var", "sorted", "=", "{", "}", ";", "var", "options", "=", "{", "sensitivity", ":", "'base'", "}", ";", "function", "compare", "(", "a", ",", "b", ")", "{", "return", "a", ".", "localeCompare", "(", "b", ",", "options", ")", ";", "}", "keys", ".", "sort", "(", "compare", ")", ";", "for", "(", "var", "index", "in", "keys", ")", "{", "if", "(", "keys", "[", "index", "]", ")", "{", "var", "key", "=", "keys", "[", "index", "]", ";", "if", "(", "Array", ".", "isArray", "(", "object", "[", "key", "]", ")", ")", "{", "sorted", "[", "key", "]", "=", "object", "[", "key", "]", ".", "sort", "(", "compare", ")", ";", "}", "else", "if", "(", "typeof", "object", "[", "key", "]", "===", "'object'", ")", "{", "sorted", "[", "key", "]", "=", "sortObject", "(", "object", "[", "key", "]", ")", ";", "}", "else", "{", "sorted", "[", "key", "]", "=", "object", "[", "key", "]", ";", "}", "}", "}", "return", "sorted", ";", "}" ]
Alphabetically sorts every property in an object and in any array values.
[ "Alphabetically", "sorts", "every", "property", "in", "an", "object", "and", "in", "any", "array", "values", "." ]
76f5ec38e88dc2053502c320e309b74039b4d517
https://github.com/FinalDevStudio/fi-khipu/blob/76f5ec38e88dc2053502c320e309b74039b4d517/lib/utils.js#L13-L42
44,794
SteveWestbrook/is-valid-var-name
index.js
isValidES2015VarName
function isValidES2015VarName(name) { // In ES2015-compatible code, these are reserved words. if (name === 'await') { return false; } if (name === 'enum') { return false; } return validateVarName(allowedCharactersES2015, name, exports.strict); }
javascript
function isValidES2015VarName(name) { // In ES2015-compatible code, these are reserved words. if (name === 'await') { return false; } if (name === 'enum') { return false; } return validateVarName(allowedCharactersES2015, name, exports.strict); }
[ "function", "isValidES2015VarName", "(", "name", ")", "{", "// In ES2015-compatible code, these are reserved words.", "if", "(", "name", "===", "'await'", ")", "{", "return", "false", ";", "}", "if", "(", "name", "===", "'enum'", ")", "{", "return", "false", ";", "}", "return", "validateVarName", "(", "allowedCharactersES2015", ",", "name", ",", "exports", ".", "strict", ")", ";", "}" ]
Determines whether a variable name is valid. Specifically, checks whether the characters are valid and whether the name is a reserved word. Note that while literals can be used as unquoted property names, these will not necessarily be accepted as valid by this function. @param name The variable name to check. @return true if the name is valid, or false if it is not. @public
[ "Determines", "whether", "a", "variable", "name", "is", "valid", ".", "Specifically", "checks", "whether", "the", "characters", "are", "valid", "and", "whether", "the", "name", "is", "a", "reserved", "word", ".", "Note", "that", "while", "literals", "can", "be", "used", "as", "unquoted", "property", "names", "these", "will", "not", "necessarily", "be", "accepted", "as", "valid", "by", "this", "function", "." ]
3eca627d3a6c5fd52ffa3e6082554662c3fea0ec
https://github.com/SteveWestbrook/is-valid-var-name/blob/3eca627d3a6c5fd52ffa3e6082554662c3fea0ec/index.js#L34-L40
44,795
SteveWestbrook/is-valid-var-name
index.js
validateVarName
function validateVarName(regex, name, strict) { if (strict) { // These are only an issue in strict mode. if (name === 'eval') { return false; } if (name === 'arguments') { return false; } } var result = regex.test(name); result = result && validateCommonReservedWords(name); return result; }
javascript
function validateVarName(regex, name, strict) { if (strict) { // These are only an issue in strict mode. if (name === 'eval') { return false; } if (name === 'arguments') { return false; } } var result = regex.test(name); result = result && validateCommonReservedWords(name); return result; }
[ "function", "validateVarName", "(", "regex", ",", "name", ",", "strict", ")", "{", "if", "(", "strict", ")", "{", "// These are only an issue in strict mode.", "if", "(", "name", "===", "'eval'", ")", "{", "return", "false", ";", "}", "if", "(", "name", "===", "'arguments'", ")", "{", "return", "false", ";", "}", "}", "var", "result", "=", "regex", ".", "test", "(", "name", ")", ";", "result", "=", "result", "&&", "validateCommonReservedWords", "(", "name", ")", ";", "return", "result", ";", "}" ]
Validates a variable name using the regular expression provided. Also uses reserved words common to ES5 and ES2015. @param regex {RegExp} A regular expression used to validate name. @param name {String} The variable name to check. @param [strict] If this is true, strict mode checking is on. @return true if the name is valid, or false if it is not. @private
[ "Validates", "a", "variable", "name", "using", "the", "regular", "expression", "provided", ".", "Also", "uses", "reserved", "words", "common", "to", "ES5", "and", "ES2015", "." ]
3eca627d3a6c5fd52ffa3e6082554662c3fea0ec
https://github.com/SteveWestbrook/is-valid-var-name/blob/3eca627d3a6c5fd52ffa3e6082554662c3fea0ec/index.js#L66-L77
44,796
fod/px.js
lib/px.js
function(s) { //TODO: validate array length //TODO: return unwanted subset as new Px object var counts = this.valCounts(), multipliers = []; _.each(s, function(d, i) { if (d[0] === '*') { s[i] = _.range(0, counts[i] - 1); } }); for (var i = 0, l = counts.length; i < l - 1; i++) { multipliers[i] = _.reduce(counts.slice(i+1), function(a, b) { return a * b; }); } multipliers.push(1); for (var j = 0, k = s.length; j < k; j++) { // drop the values this.metadata.VALUES[this.variables()[j]] = _.filter(this.metadata.VALUES[this.variables()[j]], function(e, m) { return _.indexOf(s[j], m) !== -1; }); } var keepIdxs = []; var pattern = function pattern(c,m,w,p) { if (c.length > 1) { p = typeof p !== 'undefined' ? p : 1; var count = c.pop(), multiple = m.pop(), want = w.pop(); var patt = _.flatten(_.map(_.range(0, count), function(d) { return _.include(want, d) ? p : _arrayOfZeroes(multiple); })); pattern(c, m, w, patt); } keepIdxs.push(_.flatten(p)); }; pattern(counts,multipliers,s); keepIdxs = keepIdxs[0]; var indices = []; _.each(s[0], function(d) { var start = d * multipliers[0]; var end = start + multipliers[0]; indices.push(_.filter(_.range(start, end), function(d, i) {return keepIdxs[i] === 1;})); }); indices = _.flatten(indices); this.data = _.filter(this.data, function(d, i) {return _.indexOf(indices, i) !== -1;}); }
javascript
function(s) { //TODO: validate array length //TODO: return unwanted subset as new Px object var counts = this.valCounts(), multipliers = []; _.each(s, function(d, i) { if (d[0] === '*') { s[i] = _.range(0, counts[i] - 1); } }); for (var i = 0, l = counts.length; i < l - 1; i++) { multipliers[i] = _.reduce(counts.slice(i+1), function(a, b) { return a * b; }); } multipliers.push(1); for (var j = 0, k = s.length; j < k; j++) { // drop the values this.metadata.VALUES[this.variables()[j]] = _.filter(this.metadata.VALUES[this.variables()[j]], function(e, m) { return _.indexOf(s[j], m) !== -1; }); } var keepIdxs = []; var pattern = function pattern(c,m,w,p) { if (c.length > 1) { p = typeof p !== 'undefined' ? p : 1; var count = c.pop(), multiple = m.pop(), want = w.pop(); var patt = _.flatten(_.map(_.range(0, count), function(d) { return _.include(want, d) ? p : _arrayOfZeroes(multiple); })); pattern(c, m, w, patt); } keepIdxs.push(_.flatten(p)); }; pattern(counts,multipliers,s); keepIdxs = keepIdxs[0]; var indices = []; _.each(s[0], function(d) { var start = d * multipliers[0]; var end = start + multipliers[0]; indices.push(_.filter(_.range(start, end), function(d, i) {return keepIdxs[i] === 1;})); }); indices = _.flatten(indices); this.data = _.filter(this.data, function(d, i) {return _.indexOf(indices, i) !== -1;}); }
[ "function", "(", "s", ")", "{", "//TODO: validate array length", "//TODO: return unwanted subset as new Px object", "var", "counts", "=", "this", ".", "valCounts", "(", ")", ",", "multipliers", "=", "[", "]", ";", "_", ".", "each", "(", "s", ",", "function", "(", "d", ",", "i", ")", "{", "if", "(", "d", "[", "0", "]", "===", "'*'", ")", "{", "s", "[", "i", "]", "=", "_", ".", "range", "(", "0", ",", "counts", "[", "i", "]", "-", "1", ")", ";", "}", "}", ")", ";", "for", "(", "var", "i", "=", "0", ",", "l", "=", "counts", ".", "length", ";", "i", "<", "l", "-", "1", ";", "i", "++", ")", "{", "multipliers", "[", "i", "]", "=", "_", ".", "reduce", "(", "counts", ".", "slice", "(", "i", "+", "1", ")", ",", "function", "(", "a", ",", "b", ")", "{", "return", "a", "*", "b", ";", "}", ")", ";", "}", "multipliers", ".", "push", "(", "1", ")", ";", "for", "(", "var", "j", "=", "0", ",", "k", "=", "s", ".", "length", ";", "j", "<", "k", ";", "j", "++", ")", "{", "// drop the values", "this", ".", "metadata", ".", "VALUES", "[", "this", ".", "variables", "(", ")", "[", "j", "]", "]", "=", "_", ".", "filter", "(", "this", ".", "metadata", ".", "VALUES", "[", "this", ".", "variables", "(", ")", "[", "j", "]", "]", ",", "function", "(", "e", ",", "m", ")", "{", "return", "_", ".", "indexOf", "(", "s", "[", "j", "]", ",", "m", ")", "!==", "-", "1", ";", "}", ")", ";", "}", "var", "keepIdxs", "=", "[", "]", ";", "var", "pattern", "=", "function", "pattern", "(", "c", ",", "m", ",", "w", ",", "p", ")", "{", "if", "(", "c", ".", "length", ">", "1", ")", "{", "p", "=", "typeof", "p", "!==", "'undefined'", "?", "p", ":", "1", ";", "var", "count", "=", "c", ".", "pop", "(", ")", ",", "multiple", "=", "m", ".", "pop", "(", ")", ",", "want", "=", "w", ".", "pop", "(", ")", ";", "var", "patt", "=", "_", ".", "flatten", "(", "_", ".", "map", "(", "_", ".", "range", "(", "0", ",", "count", ")", ",", "function", "(", "d", ")", "{", "return", "_", ".", "include", "(", "want", ",", "d", ")", "?", "p", ":", "_arrayOfZeroes", "(", "multiple", ")", ";", "}", ")", ")", ";", "pattern", "(", "c", ",", "m", ",", "w", ",", "patt", ")", ";", "}", "keepIdxs", ".", "push", "(", "_", ".", "flatten", "(", "p", ")", ")", ";", "}", ";", "pattern", "(", "counts", ",", "multipliers", ",", "s", ")", ";", "keepIdxs", "=", "keepIdxs", "[", "0", "]", ";", "var", "indices", "=", "[", "]", ";", "_", ".", "each", "(", "s", "[", "0", "]", ",", "function", "(", "d", ")", "{", "var", "start", "=", "d", "*", "multipliers", "[", "0", "]", ";", "var", "end", "=", "start", "+", "multipliers", "[", "0", "]", ";", "indices", ".", "push", "(", "_", ".", "filter", "(", "_", ".", "range", "(", "start", ",", "end", ")", ",", "function", "(", "d", ",", "i", ")", "{", "return", "keepIdxs", "[", "i", "]", "===", "1", ";", "}", ")", ")", ";", "}", ")", ";", "indices", "=", "_", ".", "flatten", "(", "indices", ")", ";", "this", ".", "data", "=", "_", ".", "filter", "(", "this", ".", "data", ",", "function", "(", "d", ",", "i", ")", "{", "return", "_", ".", "indexOf", "(", "indices", ",", "i", ")", "!==", "-", "1", ";", "}", ")", ";", "}" ]
remove values and associated data from this object
[ "remove", "values", "and", "associated", "data", "from", "this", "object" ]
b7ed16d26fe1cf39ed32a63cdc4a9244d9423b41
https://github.com/fod/px.js/blob/b7ed16d26fe1cf39ed32a63cdc4a9244d9423b41/lib/px.js#L219-L273
44,797
feedhenry/fh-mbaas-client
lib/admin/services/services.js
deploy
function deploy(params, cb) { params.resourcePath = config.addURIParams(constants.SERVICES_BASE_PATH + "/:guid/deploy", params); params.method = "POST"; params.data = params.service; mbaasRequest.admin(params, cb); }
javascript
function deploy(params, cb) { params.resourcePath = config.addURIParams(constants.SERVICES_BASE_PATH + "/:guid/deploy", params); params.method = "POST"; params.data = params.service; mbaasRequest.admin(params, cb); }
[ "function", "deploy", "(", "params", ",", "cb", ")", "{", "params", ".", "resourcePath", "=", "config", ".", "addURIParams", "(", "constants", ".", "SERVICES_BASE_PATH", "+", "\"/:guid/deploy\"", ",", "params", ")", ";", "params", ".", "method", "=", "\"POST\"", ";", "params", ".", "data", "=", "params", ".", "service", ";", "mbaasRequest", ".", "admin", "(", "params", ",", "cb", ")", ";", "}" ]
Deploying A Service Definition To An Mbaas. @param params @param cb
[ "Deploying", "A", "Service", "Definition", "To", "An", "Mbaas", "." ]
2d5a9cbb32e1b2464d71ffa18513358fea388859
https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/services/services.js#L10-L16
44,798
termosa/qinu
qinu.js
qinu
function qinu (options, args) { const { dict, length, template, args: optArgs, random } = this instanceof Qinu ? options : normalizeOptions(options) if (!(args instanceof Array)) { args = Array.prototype.slice.call(arguments, 1) } if (optArgs instanceof Array) { args = optArgs.concat(args) } const key = !random && this instanceof Qinu ? this.next(dict, length) : generateKey(dict, length) return applyTemplate(template, key, args) }
javascript
function qinu (options, args) { const { dict, length, template, args: optArgs, random } = this instanceof Qinu ? options : normalizeOptions(options) if (!(args instanceof Array)) { args = Array.prototype.slice.call(arguments, 1) } if (optArgs instanceof Array) { args = optArgs.concat(args) } const key = !random && this instanceof Qinu ? this.next(dict, length) : generateKey(dict, length) return applyTemplate(template, key, args) }
[ "function", "qinu", "(", "options", ",", "args", ")", "{", "const", "{", "dict", ",", "length", ",", "template", ",", "args", ":", "optArgs", ",", "random", "}", "=", "this", "instanceof", "Qinu", "?", "options", ":", "normalizeOptions", "(", "options", ")", "if", "(", "!", "(", "args", "instanceof", "Array", ")", ")", "{", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", "}", "if", "(", "optArgs", "instanceof", "Array", ")", "{", "args", "=", "optArgs", ".", "concat", "(", "args", ")", "}", "const", "key", "=", "!", "random", "&&", "this", "instanceof", "Qinu", "?", "this", ".", "next", "(", "dict", ",", "length", ")", ":", "generateKey", "(", "dict", ",", "length", ")", "return", "applyTemplate", "(", "template", ",", "key", ",", "args", ")", "}" ]
Not an arrow function, cause it requires context
[ "Not", "an", "arrow", "function", "cause", "it", "requires", "context" ]
2f33b2b078f19af4404a67a3e2856b8070a83b86
https://github.com/termosa/qinu/blob/2f33b2b078f19af4404a67a3e2856b8070a83b86/qinu.js#L52-L65
44,799
onecommons/base
lib/app.js
brequire
function brequire(module) { var basepath = process.env.SRC_base ? path.resolve(process.env.SRC_base) : path.join(__dirname, '..'); if (module.charAt(0) == '.') return require(path.join(basepath, module)); else //by calling require() from this location we ensure base's copy of the module will get priority return require(module); }
javascript
function brequire(module) { var basepath = process.env.SRC_base ? path.resolve(process.env.SRC_base) : path.join(__dirname, '..'); if (module.charAt(0) == '.') return require(path.join(basepath, module)); else //by calling require() from this location we ensure base's copy of the module will get priority return require(module); }
[ "function", "brequire", "(", "module", ")", "{", "var", "basepath", "=", "process", ".", "env", ".", "SRC_base", "?", "path", ".", "resolve", "(", "process", ".", "env", ".", "SRC_base", ")", ":", "path", ".", "join", "(", "__dirname", ",", "'..'", ")", ";", "if", "(", "module", ".", "charAt", "(", "0", ")", "==", "'.'", ")", "return", "require", "(", "path", ".", "join", "(", "basepath", ",", "module", ")", ")", ";", "else", "//by calling require() from this location we ensure base's copy of the module will get priority", "return", "require", "(", "module", ")", ";", "}" ]
you can use interchangeably with require except if or 1) you want a instance of module loaded that is distinct from base's instance or 2) you need to load a module using a relative path to your module
[ "you", "can", "use", "interchangeably", "with", "require", "except", "if", "or", "1", ")", "you", "want", "a", "instance", "of", "module", "loaded", "that", "is", "distinct", "from", "base", "s", "instance", "or", "2", ")", "you", "need", "to", "load", "a", "module", "using", "a", "relative", "path", "to", "your", "module" ]
4f35d9f714d0367b0622a3504802363404290246
https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/lib/app.js#L708-L715