repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
elliot-a/grunt-git-batch-clone
tasks/batch_git_clone.js
performCmd
function performCmd(repoURL, path){ var deferred = Q.defer(); if(errorOccured === true){ deferred.reject(); return deferred.promise; } if(grunt.file.isDir(path) && options.overWrite === false){ deferred.resolve(false); return deferred.promise; } va...
javascript
function performCmd(repoURL, path){ var deferred = Q.defer(); if(errorOccured === true){ deferred.reject(); return deferred.promise; } if(grunt.file.isDir(path) && options.overWrite === false){ deferred.resolve(false); return deferred.promise; } va...
[ "function", "performCmd", "(", "repoURL", ",", "path", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "if", "(", "errorOccured", "===", "true", ")", "{", "deferred", ".", "reject", "(", ")", ";", "return", "deferred", ".", "promi...
performs the clone command
[ "performs", "the", "clone", "command" ]
3419d6366f78286e978f568783cbb5dabe8fd219
https://github.com/elliot-a/grunt-git-batch-clone/blob/3419d6366f78286e978f568783cbb5dabe8fd219/tasks/batch_git_clone.js#L91-L134
train
elliot-a/grunt-git-batch-clone
tasks/batch_git_clone.js
cloneRepo
function cloneRepo(item){ var deferred = Q.defer(); var repoURL = item.repo; var path = item.path; deleteOldFiles(path). then(function(){ return performCmd(repoURL, path); }).then(function(success){ return npmInstall(path, success); }).then(function(success){ ...
javascript
function cloneRepo(item){ var deferred = Q.defer(); var repoURL = item.repo; var path = item.path; deleteOldFiles(path). then(function(){ return performCmd(repoURL, path); }).then(function(success){ return npmInstall(path, success); }).then(function(success){ ...
[ "function", "cloneRepo", "(", "item", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "var", "repoURL", "=", "item", ".", "repo", ";", "var", "path", "=", "item", ".", "path", ";", "deleteOldFiles", "(", "path", ")", ".", "then"...
creates a spawn process and clones the repos
[ "creates", "a", "spawn", "process", "and", "clones", "the", "repos" ]
3419d6366f78286e978f568783cbb5dabe8fd219
https://github.com/elliot-a/grunt-git-batch-clone/blob/3419d6366f78286e978f568783cbb5dabe8fd219/tasks/batch_git_clone.js#L138-L157
train
elliot-a/grunt-git-batch-clone
tasks/batch_git_clone.js
getItemList
function getItemList(object, path){ for (var prop in object){ if(typeof object[prop] === 'object'){ var newPath = path + (prop+'/'); getItemList(object[prop], newPath); }else{ var item = { path : path+prop, repo : object[prop] ...
javascript
function getItemList(object, path){ for (var prop in object){ if(typeof object[prop] === 'object'){ var newPath = path + (prop+'/'); getItemList(object[prop], newPath); }else{ var item = { path : path+prop, repo : object[prop] ...
[ "function", "getItemList", "(", "object", ",", "path", ")", "{", "for", "(", "var", "prop", "in", "object", ")", "{", "if", "(", "typeof", "object", "[", "prop", "]", "===", "'object'", ")", "{", "var", "newPath", "=", "path", "+", "(", "prop", "+"...
converts the json object into an array of items with paths
[ "converts", "the", "json", "object", "into", "an", "array", "of", "items", "with", "paths" ]
3419d6366f78286e978f568783cbb5dabe8fd219
https://github.com/elliot-a/grunt-git-batch-clone/blob/3419d6366f78286e978f568783cbb5dabe8fd219/tasks/batch_git_clone.js#L160-L177
train
elliot-a/grunt-git-batch-clone
tasks/batch_git_clone.js
npmInstall
function npmInstall(path, success){ var deferred = Q.defer(); // 'success' is a flag passed from the perform cmd function which states whether the function ran if(success === false){ deferred.resolve(success); return deferred.promise; } var hasPackage = grunt.file.isFile...
javascript
function npmInstall(path, success){ var deferred = Q.defer(); // 'success' is a flag passed from the perform cmd function which states whether the function ran if(success === false){ deferred.resolve(success); return deferred.promise; } var hasPackage = grunt.file.isFile...
[ "function", "npmInstall", "(", "path", ",", "success", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "// 'success' is a flag passed from the perform cmd function which states whether the function ran", "if", "(", "success", "===", "false", ")", "...
checks for a package.json then runs npm install if there is one.
[ "checks", "for", "a", "package", ".", "json", "then", "runs", "npm", "install", "if", "there", "is", "one", "." ]
3419d6366f78286e978f568783cbb5dabe8fd219
https://github.com/elliot-a/grunt-git-batch-clone/blob/3419d6366f78286e978f568783cbb5dabe8fd219/tasks/batch_git_clone.js#L180-L225
train
henrytseng/argr
lib/argr.js
function(data, param, value) { if(_definition[param]) { var paramInstance = Param(param, value, _definition[param]); _definition[param].param.forEach(function(p) { data[p] = paramInstance; }); } else { // Unsupported if operating in strict mode if(_useStrict) { thr...
javascript
function(data, param, value) { if(_definition[param]) { var paramInstance = Param(param, value, _definition[param]); _definition[param].param.forEach(function(p) { data[p] = paramInstance; }); } else { // Unsupported if operating in strict mode if(_useStrict) { thr...
[ "function", "(", "data", ",", "param", ",", "value", ")", "{", "if", "(", "_definition", "[", "param", "]", ")", "{", "var", "paramInstance", "=", "Param", "(", "param", ",", "value", ",", "_definition", "[", "param", "]", ")", ";", "_definition", "[...
Associate a parameter with its short and long, if it exists @param {Object} data A data object to setup @param {String} param A short/long parameter name @param {Mixed} value A value object
[ "Associate", "a", "parameter", "with", "its", "short", "and", "long", "if", "it", "exists" ]
e082f099a60d73508fb6d68095849a71d4315dda
https://github.com/henrytseng/argr/blob/e082f099a60d73508fb6d68095849a71d4315dda/lib/argr.js#L54-L70
train
henrytseng/argr
lib/argr.js
function() { var options = []; Object.keys(_definition).forEach((key, i, list) => { if(options.indexOf(_definition[key]) == -1) { options.push(_definition[key]); } }); return options; }
javascript
function() { var options = []; Object.keys(_definition).forEach((key, i, list) => { if(options.indexOf(_definition[key]) == -1) { options.push(_definition[key]); } }); return options; }
[ "function", "(", ")", "{", "var", "options", "=", "[", "]", ";", "Object", ".", "keys", "(", "_definition", ")", ".", "forEach", "(", "(", "key", ",", "i", ",", "list", ")", "=>", "{", "if", "(", "options", ".", "indexOf", "(", "_definition", "["...
Get list of options @return {Array} List of options
[ "Get", "list", "of", "options" ]
e082f099a60d73508fb6d68095849a71d4315dda
https://github.com/henrytseng/argr/blob/e082f099a60d73508fb6d68095849a71d4315dda/lib/argr.js#L237-L245
train
henrytseng/argr
lib/argr.js
function(name) { // Parse once if(!_data) _data = _parse(_args); // Fallback to defaults var param = _data[name] || _definition[name]; // False for not provided return (!param) ? false : param.value(); }
javascript
function(name) { // Parse once if(!_data) _data = _parse(_args); // Fallback to defaults var param = _data[name] || _definition[name]; // False for not provided return (!param) ? false : param.value(); }
[ "function", "(", "name", ")", "{", "// Parse once", "if", "(", "!", "_data", ")", "_data", "=", "_parse", "(", "_args", ")", ";", "// Fallback to defaults", "var", "param", "=", "_data", "[", "name", "]", "||", "_definition", "[", "name", "]", ";", "//...
Get a value associated with argument @param {Mixed} name A parameter name (short or long) @return {Object} A data object associated with the value
[ "Get", "a", "value", "associated", "with", "argument" ]
e082f099a60d73508fb6d68095849a71d4315dda
https://github.com/henrytseng/argr/blob/e082f099a60d73508fb6d68095849a71d4315dda/lib/argr.js#L275-L284
train
marcojonker/data-elevator
lib/elevator-engine/elevator-engine.js
function(config, level, floor, callback) { var floors = []; var fromIdentifier = level ? level.identifier : null; var options = FloorSelectionOptions.createFromIdentifiers(fromIdentifier, floor); try{ floors = FloorController.getFloors(config.floorsDir, options); return...
javascript
function(config, level, floor, callback) { var floors = []; var fromIdentifier = level ? level.identifier : null; var options = FloorSelectionOptions.createFromIdentifiers(fromIdentifier, floor); try{ floors = FloorController.getFloors(config.floorsDir, options); return...
[ "function", "(", "config", ",", "level", ",", "floor", ",", "callback", ")", "{", "var", "floors", "=", "[", "]", ";", "var", "fromIdentifier", "=", "level", "?", "level", ".", "identifier", ":", "null", ";", "var", "options", "=", "FloorSelectionOptions...
Get floors for selected destination @param config @param level @param floor @param callback(error, floors)
[ "Get", "floors", "for", "selected", "destination" ]
7d56e5b2e8ca24b9576066e5265713db6452f289
https://github.com/marcojonker/data-elevator/blob/7d56e5b2e8ca24b9576066e5265713db6452f289/lib/elevator-engine/elevator-engine.js#L30-L41
train
marcojonker/data-elevator
lib/elevator-engine/elevator-engine.js
function(config, floors, ascending, logger, levelController, callback) { var self = this; //Itterate migrations files async.eachSeries(floors, function(floor, callback) { var parameters = new FloorWorkerParameters(config, logger, floor); var floorWorker = require(floor.filePath); va...
javascript
function(config, floors, ascending, logger, levelController, callback) { var self = this; //Itterate migrations files async.eachSeries(floors, function(floor, callback) { var parameters = new FloorWorkerParameters(config, logger, floor); var floorWorker = require(floor.filePath); va...
[ "function", "(", "config", ",", "floors", ",", "ascending", ",", "logger", ",", "levelController", ",", "callback", ")", "{", "var", "self", "=", "this", ";", "//Itterate migrations files", "async", ".", "eachSeries", "(", "floors", ",", "function", "(", "fl...
Migrate an array of migration files @param config @param floors @param ascending @param logger @param levelController - Object derived from BaseLevelController to do custom level storage @param callback(error)
[ "Migrate", "an", "array", "of", "migration", "files" ]
7d56e5b2e8ca24b9576066e5265713db6452f289
https://github.com/marcojonker/data-elevator/blob/7d56e5b2e8ca24b9576066e5265713db6452f289/lib/elevator-engine/elevator-engine.js#L52-L91
train
marcojonker/data-elevator
lib/elevator-engine/elevator-engine.js
function(level, callback) { _getFloors(config, level, floor, function(error, floors, options) { return callback(error, floors, options); }) }
javascript
function(level, callback) { _getFloors(config, level, floor, function(error, floors, options) { return callback(error, floors, options); }) }
[ "function", "(", "level", ",", "callback", ")", "{", "_getFloors", "(", "config", ",", "level", ",", "floor", ",", "function", "(", "error", ",", "floors", ",", "options", ")", "{", "return", "callback", "(", "error", ",", "floors", ",", "options", ")"...
Get the migration files that need to be applied
[ "Get", "the", "migration", "files", "that", "need", "to", "be", "applied" ]
7d56e5b2e8ca24b9576066e5265713db6452f289
https://github.com/marcojonker/data-elevator/blob/7d56e5b2e8ca24b9576066e5265713db6452f289/lib/elevator-engine/elevator-engine.js#L134-L138
train
marcojonker/data-elevator
lib/elevator-engine/elevator-engine.js
function(floors, options, callback) { if(floors != null && floors.length > 0) { _moveElevator(config, floors, options.ascending, logger, levelController, function(error) { return callback(error, floors, options); }); } else {...
javascript
function(floors, options, callback) { if(floors != null && floors.length > 0) { _moveElevator(config, floors, options.ascending, logger, levelController, function(error) { return callback(error, floors, options); }); } else {...
[ "function", "(", "floors", ",", "options", ",", "callback", ")", "{", "if", "(", "floors", "!=", "null", "&&", "floors", ".", "length", ">", "0", ")", "{", "_moveElevator", "(", "config", ",", "floors", ",", "options", ".", "ascending", ",", "logger", ...
Migrate the files
[ "Migrate", "the", "files" ]
7d56e5b2e8ca24b9576066e5265713db6452f289
https://github.com/marcojonker/data-elevator/blob/7d56e5b2e8ca24b9576066e5265713db6452f289/lib/elevator-engine/elevator-engine.js#L140-L148
train
marcojonker/data-elevator
lib/elevator-engine/elevator-engine.js
function(floors, options, callback) { if(floors && options && options.ascending === false) { levelController.saveCurrentLevel(Level.create(options.identifierRange.min), function(error) { if(error) { logger.error('>>>> Stuck at floor...
javascript
function(floors, options, callback) { if(floors && options && options.ascending === false) { levelController.saveCurrentLevel(Level.create(options.identifierRange.min), function(error) { if(error) { logger.error('>>>> Stuck at floor...
[ "function", "(", "floors", ",", "options", ",", "callback", ")", "{", "if", "(", "floors", "&&", "options", "&&", "options", ".", "ascending", "===", "false", ")", "{", "levelController", ".", "saveCurrentLevel", "(", "Level", ".", "create", "(", "options"...
Save the last level if going down, because the last level is not stored yet
[ "Save", "the", "last", "level", "if", "going", "down", "because", "the", "last", "level", "is", "not", "stored", "yet" ]
7d56e5b2e8ca24b9576066e5265713db6452f289
https://github.com/marcojonker/data-elevator/blob/7d56e5b2e8ca24b9576066e5265713db6452f289/lib/elevator-engine/elevator-engine.js#L150-L161
train
shippjs/shipp-server
lib/bundler.js
compile
function compile(emit) { self.bundler.run(function(err, stats) { // Error handling if (err || stats.compilation.errors.length) { // Over time we expect webpack's resolution system to change. We choose to attempt // package installations by catching errors so as to maximize forward-comp...
javascript
function compile(emit) { self.bundler.run(function(err, stats) { // Error handling if (err || stats.compilation.errors.length) { // Over time we expect webpack's resolution system to change. We choose to attempt // package installations by catching errors so as to maximize forward-comp...
[ "function", "compile", "(", "emit", ")", "{", "self", ".", "bundler", ".", "run", "(", "function", "(", "err", ",", "stats", ")", "{", "// Error handling", "if", "(", "err", "||", "stats", ".", "compilation", ".", "errors", ".", "length", ")", "{", "...
Wrap compilation in order to promisify and log bundling. We cannot use "promisify" since we require the "stats" object in our error callback.
[ "Wrap", "compilation", "in", "order", "to", "promisify", "and", "log", "bundling", ".", "We", "cannot", "use", "promisify", "since", "we", "require", "the", "stats", "object", "in", "our", "error", "callback", "." ]
7fdf1a96cc4e489f646f71bd3544b68f26ee16aa
https://github.com/shippjs/shipp-server/blob/7fdf1a96cc4e489f646f71bd3544b68f26ee16aa/lib/bundler.js#L84-L112
train
Eagerod/nodeunit-mock
lib/mock.js
mock
function mock(test, object, functionName, newFunction) { if (typeof object === "undefined") { throw Error("Attempting to mock function " + functionName + " of undefined.") } // Allow test writers to still let methods pass through, in case that's needed. var unmockedName = "unmocked_" + function...
javascript
function mock(test, object, functionName, newFunction) { if (typeof object === "undefined") { throw Error("Attempting to mock function " + functionName + " of undefined.") } // Allow test writers to still let methods pass through, in case that's needed. var unmockedName = "unmocked_" + function...
[ "function", "mock", "(", "test", ",", "object", ",", "functionName", ",", "newFunction", ")", "{", "if", "(", "typeof", "object", "===", "\"undefined\"", ")", "{", "throw", "Error", "(", "\"Attempting to mock function \"", "+", "functionName", "+", "\" of undefi...
Sets up a mocked function on the provided object that allows you to test things like the number of calls that were made on a function and the parameters that came into it. Should typically be used to prevent outgoing network calls, so that tests can be run in isolation without affecting any services.
[ "Sets", "up", "a", "mocked", "function", "on", "the", "provided", "object", "that", "allows", "you", "to", "test", "things", "like", "the", "number", "of", "calls", "that", "were", "made", "on", "a", "function", "and", "the", "parameters", "that", "came", ...
598282fc8b6218f8eefc3b247e476ab0543c1cd8
https://github.com/Eagerod/nodeunit-mock/blob/598282fc8b6218f8eefc3b247e476ab0543c1cd8/lib/mock.js#L10-L51
train
Layer3DLab/heimdallr-validator
lib/heimdallr-validator.js
validUUID
function validUUID(uuid) { // xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is a hexadecimal digit and // y is 8,9, A, or B var uuidRegex = /^[0-9a-f]{8}\-[0-9a-f]{4}\-4[0-9a-f]{3}\-[89ab][0-9a-f]{3}\-[0-9a-f]{12}$/i, result; result = uuidRegex.exec(uuid); return result !== null; }
javascript
function validUUID(uuid) { // xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is a hexadecimal digit and // y is 8,9, A, or B var uuidRegex = /^[0-9a-f]{8}\-[0-9a-f]{4}\-4[0-9a-f]{3}\-[89ab][0-9a-f]{3}\-[0-9a-f]{12}$/i, result; result = uuidRegex.exec(uuid); return result !== null; }
[ "function", "validUUID", "(", "uuid", ")", "{", "// xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is a hexadecimal digit and", "// y is 8,9, A, or B", "var", "uuidRegex", "=", "/", "^[0-9a-f]{8}\\-[0-9a-f]{4}\\-4[0-9a-f]{3}\\-[89ab][0-9a-f]{3}\\-[0-9a-f]{12}$", "/", "i", ",", "result"...
Verifies that the input string follows the RFC 4122 v4 UUID standard. @arg {string} uuid - The UUID to validate. @return {boolean} True if <tt>uuid</tt> is a valid v4 UUID.
[ "Verifies", "that", "the", "input", "string", "follows", "the", "RFC", "4122", "v4", "UUID", "standard", "." ]
fa9cbc332c10af836eba461a2f965267a8064e0a
https://github.com/Layer3DLab/heimdallr-validator/blob/fa9cbc332c10af836eba461a2f965267a8064e0a/lib/heimdallr-validator.js#L50-L59
train
Layer3DLab/heimdallr-validator
lib/heimdallr-validator.js
validTimestamp
function validTimestamp(timestamp) { // ^year-month-day(Thour:min:secms?timezone)?$ var year = /((?:[1-9][0-9]*)?[0-9]{4})/, month = /(1[0-2]|0[1-9])/, day = /(3[01]|0[1-9]|[12][0-9])/, hour = /(2[0-3]|[01][0-9])/, minute = /([0-5][0-9])/, second = /([0-5][0-9])/, ...
javascript
function validTimestamp(timestamp) { // ^year-month-day(Thour:min:secms?timezone)?$ var year = /((?:[1-9][0-9]*)?[0-9]{4})/, month = /(1[0-2]|0[1-9])/, day = /(3[01]|0[1-9]|[12][0-9])/, hour = /(2[0-3]|[01][0-9])/, minute = /([0-5][0-9])/, second = /([0-5][0-9])/, ...
[ "function", "validTimestamp", "(", "timestamp", ")", "{", "// ^year-month-day(Thour:min:secms?timezone)?$", "var", "year", "=", "/", "((?:[1-9][0-9]*)?[0-9]{4})", "/", ",", "month", "=", "/", "(1[0-2]|0[1-9])", "/", ",", "day", "=", "/", "(3[01]|0[1-9]|[12][0-9])", "/...
Verifies that the input string follows the ISO 8601 standard. @arg {string} timestamp - The timestamp to validate. @return {boolean} True if <tt>timestamp</tt> is a valid ISO 8601 string.
[ "Verifies", "that", "the", "input", "string", "follows", "the", "ISO", "8601", "standard", "." ]
fa9cbc332c10af836eba461a2f965267a8064e0a
https://github.com/Layer3DLab/heimdallr-validator/blob/fa9cbc332c10af836eba461a2f965267a8064e0a/lib/heimdallr-validator.js#L67-L89
train
Layer3DLab/heimdallr-validator
lib/heimdallr-validator.js
validatePacket
function validatePacket(type, packet, fn) { debug('Type:', type); debug('Packet:', packet); if (!tv4.validate(packet, defaultSchemas[type])) { return fn(tv4.error); } if (packet.hasOwnProperty('provider') && !validUUID(packet.provider)) { return fn(new E...
javascript
function validatePacket(type, packet, fn) { debug('Type:', type); debug('Packet:', packet); if (!tv4.validate(packet, defaultSchemas[type])) { return fn(tv4.error); } if (packet.hasOwnProperty('provider') && !validUUID(packet.provider)) { return fn(new E...
[ "function", "validatePacket", "(", "type", ",", "packet", ",", "fn", ")", "{", "debug", "(", "'Type:'", ",", "type", ")", ";", "debug", "(", "'Packet:'", ",", "packet", ")", ";", "if", "(", "!", "tv4", ".", "validate", "(", "packet", ",", "defaultSch...
Verifies that the packet conforms to the correct structure for the given type. It first checks if the packet violates the schema for the type then if there is a provider field and it is not a valid UUID then if there is a t field and it is not a valid ISO 8601 timestamp. @arg {string} type - The type of Heimdallr pack...
[ "Verifies", "that", "the", "packet", "conforms", "to", "the", "correct", "structure", "for", "the", "given", "type", ".", "It", "first", "checks", "if", "the", "packet", "violates", "the", "schema", "for", "the", "type", "then", "if", "there", "is", "a", ...
fa9cbc332c10af836eba461a2f965267a8064e0a
https://github.com/Layer3DLab/heimdallr-validator/blob/fa9cbc332c10af836eba461a2f965267a8064e0a/lib/heimdallr-validator.js#L104-L121
train
Layer3DLab/heimdallr-validator
lib/heimdallr-validator.js
validateData
function validateData(data, schema, fn) { debug('Schema:', schema); debug('Data:', data); if (!tv4.validate(data, schema)) { return fn(tv4.error); } return fn(null, true); }
javascript
function validateData(data, schema, fn) { debug('Schema:', schema); debug('Data:', data); if (!tv4.validate(data, schema)) { return fn(tv4.error); } return fn(null, true); }
[ "function", "validateData", "(", "data", ",", "schema", ",", "fn", ")", "{", "debug", "(", "'Schema:'", ",", "schema", ")", ";", "debug", "(", "'Data:'", ",", "data", ")", ";", "if", "(", "!", "tv4", ".", "validate", "(", "data", ",", "schema", ")"...
Verifies that the data conforms to the schema. @arg {} data - The data to validate. @arg {object} schema - Valid JSON schema. @arg {function} fn - Node-style callback that will be passed an error as the first argument if the packet is invalid.
[ "Verifies", "that", "the", "data", "conforms", "to", "the", "schema", "." ]
fa9cbc332c10af836eba461a2f965267a8064e0a
https://github.com/Layer3DLab/heimdallr-validator/blob/fa9cbc332c10af836eba461a2f965267a8064e0a/lib/heimdallr-validator.js#L131-L140
train
fin-hypergrid/client-module-wrapper
index.js
Wrapper
function Wrapper(manifest) { var header = manifest.header || '(function(require, module, exports) { // ${name}@${version}\n\n' + (manifest.isJSON ? 'module.exports = ' : ''); var footer = manifest.footer || (manifest.isJSON ? ';' : '') + '\n\n})(fin.Hypergrid.require, fin.Hyper...
javascript
function Wrapper(manifest) { var header = manifest.header || '(function(require, module, exports) { // ${name}@${version}\n\n' + (manifest.isJSON ? 'module.exports = ' : ''); var footer = manifest.footer || (manifest.isJSON ? ';' : '') + '\n\n})(fin.Hypergrid.require, fin.Hyper...
[ "function", "Wrapper", "(", "manifest", ")", "{", "var", "header", "=", "manifest", ".", "header", "||", "'(function(require, module, exports) { // ${name}@${version}\\n\\n'", "+", "(", "manifest", ".", "isJSON", "?", "'module.exports = '", ":", "''", ")", ";", "var...
Create wrapper strings. @param {object} manifest @param {string} manifest.name - module name @param {string} manifest.version - Merged into standard header and footer. @param {boolean} [manifest.isJSON] - If truthy, wraps contents in `module.exports=` and `;`. @param {string} [manifest.header] - Custom header (typicall...
[ "Create", "wrapper", "strings", "." ]
961f2fe1d037803f1647fa1c5dd9774e71de14ee
https://github.com/fin-hypergrid/client-module-wrapper/blob/961f2fe1d037803f1647fa1c5dd9774e71de14ee/index.js#L11-L35
train
tilmanjusten/inventory-object
index.js
getDefaultOptions
function getDefaultOptions() { const resources = { classnames: { root: '', body: '' }, meta: [], scriptsFoot: { files: [], inline: [] }, scriptsHead: { files: [], inline: [] }, sty...
javascript
function getDefaultOptions() { const resources = { classnames: { root: '', body: '' }, meta: [], scriptsFoot: { files: [], inline: [] }, scriptsHead: { files: [], inline: [] }, sty...
[ "function", "getDefaultOptions", "(", ")", "{", "const", "resources", "=", "{", "classnames", ":", "{", "root", ":", "''", ",", "body", ":", "''", "}", ",", "meta", ":", "[", "]", ",", "scriptsFoot", ":", "{", "files", ":", "[", "]", ",", "inline",...
get default options, scope as function instead of "public" property @returns {{indent: string, origin: string, resources: {classnames: {root: string, body: string}, meta: Array, scriptsFoot: {files: Array, inline: Array}, scriptsHead: {files: Array, inline: Array}, stylesHead: {files: Array, inline: Array}}, wrap: {be...
[ "get", "default", "options", "scope", "as", "function", "instead", "of", "public", "property" ]
8c746d88d4f4e9631085e918fe003c73f05ae0dd
https://github.com/tilmanjusten/inventory-object/blob/8c746d88d4f4e9631085e918fe003c73f05ae0dd/index.js#L13-L40
train
tilmanjusten/inventory-object
index.js
raiseIndent
function raiseIndent(lines, offset) { offset = offset || ' '; return lines.map((line) => offset + line); }
javascript
function raiseIndent(lines, offset) { offset = offset || ' '; return lines.map((line) => offset + line); }
[ "function", "raiseIndent", "(", "lines", ",", "offset", ")", "{", "offset", "=", "offset", "||", "' '", ";", "return", "lines", ".", "map", "(", "(", "line", ")", "=>", "offset", "+", "line", ")", ";", "}" ]
raise offset in lines @param lines @param offset @returns {Array|*|{}}
[ "raise", "offset", "in", "lines" ]
8c746d88d4f4e9631085e918fe003c73f05ae0dd
https://github.com/tilmanjusten/inventory-object/blob/8c746d88d4f4e9631085e918fe003c73f05ae0dd/index.js#L82-L86
train
tilmanjusten/inventory-object
index.js
formalizeWrap
function formalizeWrap(wrap) { const result = {before: '', after: ''}; if ((typeof wrap === 'string' && wrap.length > 0) || typeof wrap === 'number') { result.before = result.after = wrap; } else if (Array.isArray(wrap) && wrap.length > 0) { result.before = [].slice.call(wrap, 0, 1)[0]; ...
javascript
function formalizeWrap(wrap) { const result = {before: '', after: ''}; if ((typeof wrap === 'string' && wrap.length > 0) || typeof wrap === 'number') { result.before = result.after = wrap; } else if (Array.isArray(wrap) && wrap.length > 0) { result.before = [].slice.call(wrap, 0, 1)[0]; ...
[ "function", "formalizeWrap", "(", "wrap", ")", "{", "const", "result", "=", "{", "before", ":", "''", ",", "after", ":", "''", "}", ";", "if", "(", "(", "typeof", "wrap", "===", "'string'", "&&", "wrap", ".", "length", ">", "0", ")", "||", "typeof"...
Formalize any given value as wrap object @param wrap @returns {{before: '', after: ''}}
[ "Formalize", "any", "given", "value", "as", "wrap", "object" ]
8c746d88d4f4e9631085e918fe003c73f05ae0dd
https://github.com/tilmanjusten/inventory-object/blob/8c746d88d4f4e9631085e918fe003c73f05ae0dd/index.js#L94-L123
train
tilmanjusten/inventory-object
index.js
getBlockOptions
function getBlockOptions(annotation, defaults) { const optionValues = annotation.split(/\w+\:/) .map((item) => item.replace(/<!--\s?|\s?-->|^\s+|\s+$/, '')) .filter((item) => !!item.length); const optionKeys = annotation.match(/(\w+)\:/gi).map((item) => item.replace(/[^\w]/, '')); defaults ...
javascript
function getBlockOptions(annotation, defaults) { const optionValues = annotation.split(/\w+\:/) .map((item) => item.replace(/<!--\s?|\s?-->|^\s+|\s+$/, '')) .filter((item) => !!item.length); const optionKeys = annotation.match(/(\w+)\:/gi).map((item) => item.replace(/[^\w]/, '')); defaults ...
[ "function", "getBlockOptions", "(", "annotation", ",", "defaults", ")", "{", "const", "optionValues", "=", "annotation", ".", "split", "(", "/", "\\w+\\:", "/", ")", ".", "map", "(", "(", "item", ")", "=>", "item", ".", "replace", "(", "/", "<!--\\s?|\\s...
read options from annotation e.g.: <!-- extract:content/element.html wrap:<div class="wrapper-element">:</div> --> becomes: { extract: 'content/element.html', wrap: {before: '<div class="wrapper-element">', after: '</div>'} } @param annotation @param defaults @returns {{}}
[ "read", "options", "from", "annotation" ]
8c746d88d4f4e9631085e918fe003c73f05ae0dd
https://github.com/tilmanjusten/inventory-object/blob/8c746d88d4f4e9631085e918fe003c73f05ae0dd/index.js#L139-L173
train
stuartpb/endex
index.js
convertResponse
function convertResponse(response) { var results = {tables: [], indexes: []}; var i=0; var start=0; if (dbName) { results.db = response[0]; start++; i++; } while (i < start + tableNames.length) { tableName = tableNames[i-start]; results.tables[...
javascript
function convertResponse(response) { var results = {tables: [], indexes: []}; var i=0; var start=0; if (dbName) { results.db = response[0]; start++; i++; } while (i < start + tableNames.length) { tableName = tableNames[i-start]; results.tables[...
[ "function", "convertResponse", "(", "response", ")", "{", "var", "results", "=", "{", "tables", ":", "[", "]", ",", "indexes", ":", "[", "]", "}", ";", "var", "i", "=", "0", ";", "var", "start", "=", "0", ";", "if", "(", "dbName", ")", "{", "re...
Convert the expr response to something simpler
[ "Convert", "the", "expr", "response", "to", "something", "simpler" ]
ca5af19e2511d9461bd219e6c117b1206b1ae0f8
https://github.com/stuartpb/endex/blob/ca5af19e2511d9461bd219e6c117b1206b1ae0f8/index.js#L92-L126
train
SandJS/riak
lib/Client.js
delegate
function delegate(client, fn) { // Add this function to the current client // and wrap with a connection check client[fn] = function(...args) { let self = this; let p = null; if (sand.profiler && sand.profiler.enabled) { // Build the profiler request let req = `riak ${fn} `; if (args...
javascript
function delegate(client, fn) { // Add this function to the current client // and wrap with a connection check client[fn] = function(...args) { let self = this; let p = null; if (sand.profiler && sand.profiler.enabled) { // Build the profiler request let req = `riak ${fn} `; if (args...
[ "function", "delegate", "(", "client", ",", "fn", ")", "{", "// Add this function to the current client", "// and wrap with a connection check", "client", "[", "fn", "]", "=", "function", "(", "...", "args", ")", "{", "let", "self", "=", "this", ";", "let", "p",...
Delegate the function to the client, but add a connection check first @param {Client} client - the sand-riak client @param {string} fn - function name
[ "Delegate", "the", "function", "to", "the", "client", "but", "add", "a", "connection", "check", "first" ]
9a45ce3bebb91a1bd85ff89f56574dd7ac0876ab
https://github.com/SandJS/riak/blob/9a45ce3bebb91a1bd85ff89f56574dd7ac0876ab/lib/Client.js#L84-L130
train
wallacegibbon/newredis-node
lib/conn.js
adjustCommandArgument
function adjustCommandArgument(argObj) { if (typeof argObj === "number") { return argObj.toString() } else if (typeof argObj === "string") { return argObj } else if (!argObj) { return "" } else { throw new RedisCommandError(`Argument: ${inspect(argObj)}`) } }
javascript
function adjustCommandArgument(argObj) { if (typeof argObj === "number") { return argObj.toString() } else if (typeof argObj === "string") { return argObj } else if (!argObj) { return "" } else { throw new RedisCommandError(`Argument: ${inspect(argObj)}`) } }
[ "function", "adjustCommandArgument", "(", "argObj", ")", "{", "if", "(", "typeof", "argObj", "===", "\"number\"", ")", "{", "return", "argObj", ".", "toString", "(", ")", "}", "else", "if", "(", "typeof", "argObj", "===", "\"string\"", ")", "{", "return", ...
Only strings and numbers are valid redis arguments, other type of data will be treated as error.
[ "Only", "strings", "and", "numbers", "are", "valid", "redis", "arguments", "other", "type", "of", "data", "will", "be", "treated", "as", "error", "." ]
c4d6ae78bc80cfd545ab8ff6606e8c88fc6dd24b
https://github.com/wallacegibbon/newredis-node/blob/c4d6ae78bc80cfd545ab8ff6606e8c88fc6dd24b/lib/conn.js#L175-L185
train
espadrine/travel-scrapper
main.js
combineSearch
function combineSearch(tp1, tp2) { return tp1.map(travelPlan => { let arrival = new Date(travelPlan.legs[travelPlan.legs.length - 1].arrival) let bestWaitTime = Infinity let bestTravelPlan2 = tp2[0] // Find the most appropriate corresponding second travel plan. for (let i = 0; i < tp2.length; i++)...
javascript
function combineSearch(tp1, tp2) { return tp1.map(travelPlan => { let arrival = new Date(travelPlan.legs[travelPlan.legs.length - 1].arrival) let bestWaitTime = Infinity let bestTravelPlan2 = tp2[0] // Find the most appropriate corresponding second travel plan. for (let i = 0; i < tp2.length; i++)...
[ "function", "combineSearch", "(", "tp1", ",", "tp2", ")", "{", "return", "tp1", ".", "map", "(", "travelPlan", "=>", "{", "let", "arrival", "=", "new", "Date", "(", "travelPlan", ".", "legs", "[", "travelPlan", ".", "legs", ".", "length", "-", "1", "...
Take two travel plans, combine them so that one is the first part of the journey of the other. We assume that the last station of the first travel plans is the first station of the second travel plans.
[ "Take", "two", "travel", "plans", "combine", "them", "so", "that", "one", "is", "the", "first", "part", "of", "the", "journey", "of", "the", "other", ".", "We", "assume", "that", "the", "last", "station", "of", "the", "first", "travel", "plans", "is", ...
5ed137e967a8a2de67f988922ec66222f464ea96
https://github.com/espadrine/travel-scrapper/blob/5ed137e967a8a2de67f988922ec66222f464ea96/main.js#L55-L77
train
PeerioTechnologies/peerio-updater
size.js
verifySize
function verifySize(correctSize, filepath) { return calculateSize(filepath).then(size => { if (size !== correctSize) { throw new Error(`Incorrect file size: expected ${correctSize}, got ${size}`); } return true; }); }
javascript
function verifySize(correctSize, filepath) { return calculateSize(filepath).then(size => { if (size !== correctSize) { throw new Error(`Incorrect file size: expected ${correctSize}, got ${size}`); } return true; }); }
[ "function", "verifySize", "(", "correctSize", ",", "filepath", ")", "{", "return", "calculateSize", "(", "filepath", ")", ".", "then", "(", "size", "=>", "{", "if", "(", "size", "!==", "correctSize", ")", "{", "throw", "new", "Error", "(", "`", "${", "...
Calculates file size and compares it to the provided one. Returns a promise which rejects if the size is incorrect, otherwise resolves to true. @param {number} correctSize expected file size @param {string} filepath file path @returns {Promise<boolean>}
[ "Calculates", "file", "size", "and", "compares", "it", "to", "the", "provided", "one", "." ]
9d6fedeec727f16a31653e4bbd4efe164e0957cb
https://github.com/PeerioTechnologies/peerio-updater/blob/9d6fedeec727f16a31653e4bbd4efe164e0957cb/size.js#L15-L22
train
PeerioTechnologies/peerio-updater
size.js
calculateSize
function calculateSize(filepath) { return new Promise((fulfill, reject) => { fs.stat(filepath, (err, stats) => { if (err) return reject(err); fulfill(stats.size); }); }); }
javascript
function calculateSize(filepath) { return new Promise((fulfill, reject) => { fs.stat(filepath, (err, stats) => { if (err) return reject(err); fulfill(stats.size); }); }); }
[ "function", "calculateSize", "(", "filepath", ")", "{", "return", "new", "Promise", "(", "(", "fulfill", ",", "reject", ")", "=>", "{", "fs", ".", "stat", "(", "filepath", ",", "(", "err", ",", "stats", ")", "=>", "{", "if", "(", "err", ")", "retur...
Calculates size of the file at the given path. @param {string} filepath @returns Promise<number> hex encoded hash
[ "Calculates", "size", "of", "the", "file", "at", "the", "given", "path", "." ]
9d6fedeec727f16a31653e4bbd4efe164e0957cb
https://github.com/PeerioTechnologies/peerio-updater/blob/9d6fedeec727f16a31653e4bbd4efe164e0957cb/size.js#L30-L37
train
pattern-library/pattern-library-utilities
lib/gulp-tasks/file-glob-inject.js
function () { 'use strict'; var options = { config: { relative: true }, src: './index.html', // source file with types of files to be glob-injected files: [// relative paths to files to be globbed '!./node_modules/**/*', '!./_gulp/*', './**/*' ], dest: './', // desti...
javascript
function () { 'use strict'; var options = { config: { relative: true }, src: './index.html', // source file with types of files to be glob-injected files: [// relative paths to files to be globbed '!./node_modules/**/*', '!./_gulp/*', './**/*' ], dest: './', // desti...
[ "function", "(", ")", "{", "'use strict'", ";", "var", "options", "=", "{", "config", ":", "{", "relative", ":", "true", "}", ",", "src", ":", "'./index.html'", ",", "// source file with types of files to be glob-injected", "files", ":", "[", "// relative paths to...
Function to get default options for an implementation of gulp-inject @return {Object} options an object of options
[ "Function", "to", "get", "default", "options", "for", "an", "implementation", "of", "gulp", "-", "inject" ]
a0198f7bb698eb5b859576b11afa3d0ebd3e5911
https://github.com/pattern-library/pattern-library-utilities/blob/a0198f7bb698eb5b859576b11afa3d0ebd3e5911/lib/gulp-tasks/file-glob-inject.js#L35-L54
train
pattern-library/pattern-library-utilities
lib/gulp-tasks/file-glob-inject.js
function () { 'use strict'; var options = { config: { starttag: '// inject:{{ext}}', endtag: '// endinject', addRootSlash: false, relative: true, transform: function (filepath) { return '@import \'' + filepath + '\';'; } }, src: './styles/style.scss', file...
javascript
function () { 'use strict'; var options = { config: { starttag: '// inject:{{ext}}', endtag: '// endinject', addRootSlash: false, relative: true, transform: function (filepath) { return '@import \'' + filepath + '\';'; } }, src: './styles/style.scss', file...
[ "function", "(", ")", "{", "'use strict'", ";", "var", "options", "=", "{", "config", ":", "{", "starttag", ":", "'// inject:{{ext}}'", ",", "endtag", ":", "'// endinject'", ",", "addRootSlash", ":", "false", ",", "relative", ":", "true", ",", "transform", ...
Function to get default options for globbing scss files with gulp-inject @return {Object} options an object of default options
[ "Function", "to", "get", "default", "options", "for", "globbing", "scss", "files", "with", "gulp", "-", "inject" ]
a0198f7bb698eb5b859576b11afa3d0ebd3e5911
https://github.com/pattern-library/pattern-library-utilities/blob/a0198f7bb698eb5b859576b11afa3d0ebd3e5911/lib/gulp-tasks/file-glob-inject.js#L81-L105
train
iLib-js/ilib-webpack-plugin
ilib-webpack-plugin.js
toArray
function toArray(set) { var ret = []; set.forEach(function(element) { ret.push(element); }); return ret; }
javascript
function toArray(set) { var ret = []; set.forEach(function(element) { ret.push(element); }); return ret; }
[ "function", "toArray", "(", "set", ")", "{", "var", "ret", "=", "[", "]", ";", "set", ".", "forEach", "(", "function", "(", "element", ")", "{", "ret", ".", "push", "(", "element", ")", ";", "}", ")", ";", "return", "ret", ";", "}" ]
Convert a set to an array. @param {Set} set to convert @returns an array with the contents of the set
[ "Convert", "a", "set", "to", "an", "array", "." ]
ba31ce1175bbf36c139c0fbde1c5bbe6674c941c
https://github.com/iLib-js/ilib-webpack-plugin/blob/ba31ce1175bbf36c139c0fbde1c5bbe6674c941c/ilib-webpack-plugin.js#L73-L79
train
lyfeyaj/ovt
lib/types/alternatives.js
function() { let schemas = utils.parseArg(arguments); schemas.forEach(function(schema) { utils.assert(schema.isOvt, `${utils.obj2Str(schema)} is not a valid ovt schema`); }); }
javascript
function() { let schemas = utils.parseArg(arguments); schemas.forEach(function(schema) { utils.assert(schema.isOvt, `${utils.obj2Str(schema)} is not a valid ovt schema`); }); }
[ "function", "(", ")", "{", "let", "schemas", "=", "utils", ".", "parseArg", "(", "arguments", ")", ";", "schemas", ".", "forEach", "(", "function", "(", "schema", ")", "{", "utils", ".", "assert", "(", "schema", ".", "isOvt", ",", "`", "${", "utils",...
Using chainingBehaviour to check whether schemas are valid
[ "Using", "chainingBehaviour", "to", "check", "whether", "schemas", "are", "valid" ]
ebd50a3531f1504cd356c869dda91200ad2f6539
https://github.com/lyfeyaj/ovt/blob/ebd50a3531f1504cd356c869dda91200ad2f6539/lib/types/alternatives.js#L49-L54
train
artdecocode/idio
build/index.js
_default
async function _default(config, routesConfig) { const res = await (0, _startApp.default)(config); const { url, app, router, middleware, connect } = res; let methods; if (routesConfig) { methods = await (0, _routes.initRoutes2)(routesConfig, middleware, router); const routes = rout...
javascript
async function _default(config, routesConfig) { const res = await (0, _startApp.default)(config); const { url, app, router, middleware, connect } = res; let methods; if (routesConfig) { methods = await (0, _routes.initRoutes2)(routesConfig, middleware, router); const routes = rout...
[ "async", "function", "_default", "(", "config", ",", "routesConfig", ")", "{", "const", "res", "=", "await", "(", "0", ",", "_startApp", ".", "default", ")", "(", "config", ")", ";", "const", "{", "url", ",", "app", ",", "router", ",", "middleware", ...
eslint-disable-line eslint-disable-line Start the server. @param {Config} config A configuration object. @param {RoutesConfig} [routesConfig] A configuration object for the router.
[ "eslint", "-", "disable", "-", "line", "eslint", "-", "disable", "-", "line", "Start", "the", "server", "." ]
6fbf9bbd63eafe609e550532801ea33910ff95c7
https://github.com/artdecocode/idio/blob/6fbf9bbd63eafe609e550532801ea33910ff95c7/build/index.js#L38-L62
train
hex7c0/logger-request-cli
lib/out.js
ip
function ip(input, output) { var i = 0; var event = input[0]; var out = [ output ]; for ( var ips in event) { ++i; out.push([ ips, cyan + event[ips].counter + close ]); } if (i === 0) { return []; } out.push('', [ 'unique ip', ansi.underline.open + i + ansi.underline.close ], ''); ret...
javascript
function ip(input, output) { var i = 0; var event = input[0]; var out = [ output ]; for ( var ips in event) { ++i; out.push([ ips, cyan + event[ips].counter + close ]); } if (i === 0) { return []; } out.push('', [ 'unique ip', ansi.underline.open + i + ansi.underline.close ], ''); ret...
[ "function", "ip", "(", "input", ",", "output", ")", "{", "var", "i", "=", "0", ";", "var", "event", "=", "input", "[", "0", "]", ";", "var", "out", "=", "[", "output", "]", ";", "for", "(", "var", "ips", "in", "event", ")", "{", "++", "i", ...
output for ip @function ip @param {Array} input - line parsed @param {String} output - header @return {Array}
[ "output", "for", "ip" ]
b1110592dd62e673561a1a4e1c4e122a2a93890a
https://github.com/hex7c0/logger-request-cli/blob/b1110592dd62e673561a1a4e1c4e122a2a93890a/lib/out.js#L64-L79
train
hex7c0/logger-request-cli
lib/out.js
cc
function cc(input, output) { var event = input[0]; var out = [ output ]; for ( var a in event) { if (a != 'undefined') { out.push([ a, cyan + event[a].counter + close ]); } } if (out.length < 2) { return []; } out.push(''); return out; }
javascript
function cc(input, output) { var event = input[0]; var out = [ output ]; for ( var a in event) { if (a != 'undefined') { out.push([ a, cyan + event[a].counter + close ]); } } if (out.length < 2) { return []; } out.push(''); return out; }
[ "function", "cc", "(", "input", ",", "output", ")", "{", "var", "event", "=", "input", "[", "0", "]", ";", "var", "out", "=", "[", "output", "]", ";", "for", "(", "var", "a", "in", "event", ")", "{", "if", "(", "a", "!=", "'undefined'", ")", ...
output for counter @function cc @param {Array} input - line parsed @param {String} output - header @return {Array}
[ "output", "for", "counter" ]
b1110592dd62e673561a1a4e1c4e122a2a93890a
https://github.com/hex7c0/logger-request-cli/blob/b1110592dd62e673561a1a4e1c4e122a2a93890a/lib/out.js#L89-L103
train
hex7c0/logger-request-cli
lib/out.js
avg
function avg(input, output) { var event = input[0]; if (event.what === 0 && event.total === 0) { return []; } return [ output, [ 'total', cyan + event.what.toFixed(3) + close ], [ 'average', cyan + (event.what / event.total).toFixed(3) + close ], [ 'max', cyan + event.max.toFixed(3) + close ], ...
javascript
function avg(input, output) { var event = input[0]; if (event.what === 0 && event.total === 0) { return []; } return [ output, [ 'total', cyan + event.what.toFixed(3) + close ], [ 'average', cyan + (event.what / event.total).toFixed(3) + close ], [ 'max', cyan + event.max.toFixed(3) + close ], ...
[ "function", "avg", "(", "input", ",", "output", ")", "{", "var", "event", "=", "input", "[", "0", "]", ";", "if", "(", "event", ".", "what", "===", "0", "&&", "event", ".", "total", "===", "0", ")", "{", "return", "[", "]", ";", "}", "return", ...
output for average @function avg @param {Array} input - line parsed @param {String} output - header @return {Array}
[ "output", "for", "average" ]
b1110592dd62e673561a1a4e1c4e122a2a93890a
https://github.com/hex7c0/logger-request-cli/blob/b1110592dd62e673561a1a4e1c4e122a2a93890a/lib/out.js#L113-L123
train
nattreid/tracking
assets/nTracker.js
addParameter
function addParameter(data, parameter) { var regex = '(' + parameter + '=[a-z0-9-]+)'; var search = window.location.search.match(regex); if (search) { data.push(search[1]); } var hash = window.location.hash.match(regex); if (hash) {...
javascript
function addParameter(data, parameter) { var regex = '(' + parameter + '=[a-z0-9-]+)'; var search = window.location.search.match(regex); if (search) { data.push(search[1]); } var hash = window.location.hash.match(regex); if (hash) {...
[ "function", "addParameter", "(", "data", ",", "parameter", ")", "{", "var", "regex", "=", "'('", "+", "parameter", "+", "'=[a-z0-9-]+)'", ";", "var", "search", "=", "window", ".", "location", ".", "search", ".", "match", "(", "regex", ")", ";", "if", "...
Add parameter from window.search do data @param {array} data @param {string} parameter
[ "Add", "parameter", "from", "window", ".", "search", "do", "data" ]
5fc7c993c08774945405c79a393584ef2ed589f7
https://github.com/nattreid/tracking/blob/5fc7c993c08774945405c79a393584ef2ed589f7/assets/nTracker.js#L67-L77
train
nattreid/tracking
assets/nTracker.js
getClickDataset
function getClickDataset(path) { var el; for (var i = 0; i < path.length; i++) { el = path[i]; if (el.dataset.nctr !== undefined) { return el.dataset; } } return null; }
javascript
function getClickDataset(path) { var el; for (var i = 0; i < path.length; i++) { el = path[i]; if (el.dataset.nctr !== undefined) { return el.dataset; } } return null; }
[ "function", "getClickDataset", "(", "path", ")", "{", "var", "el", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "path", ".", "length", ";", "i", "++", ")", "{", "el", "=", "path", "[", "i", "]", ";", "if", "(", "el", ".", "dataset", ...
Get click dataset @param {array} path @returns {array|null}
[ "Get", "click", "dataset" ]
5fc7c993c08774945405c79a393584ef2ed589f7
https://github.com/nattreid/tracking/blob/5fc7c993c08774945405c79a393584ef2ed589f7/assets/nTracker.js#L106-L115
train
nattreid/tracking
assets/nTracker.js
leave
function leave() { var data = []; data.push('leave=' + Math.floor(Math.random() * 10000)); post(data.join('&'), trackingUrl); }
javascript
function leave() { var data = []; data.push('leave=' + Math.floor(Math.random() * 10000)); post(data.join('&'), trackingUrl); }
[ "function", "leave", "(", ")", "{", "var", "data", "=", "[", "]", ";", "data", ".", "push", "(", "'leave='", "+", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "10000", ")", ")", ";", "post", "(", "data", ".", "join", "(", ...
Track leave page
[ "Track", "leave", "page" ]
5fc7c993c08774945405c79a393584ef2ed589f7
https://github.com/nattreid/tracking/blob/5fc7c993c08774945405c79a393584ef2ed589f7/assets/nTracker.js#L149-L154
train
nattreid/tracking
assets/nTracker.js
initOnClick
function initOnClick() { var clicks = document.querySelectorAll('[data-nctr]'); for (var i = 0; i < clicks.length; i++) { var tag = clicks[i]; if (tag.addEventListener) { tag.addEventListener("click", clickTrack, false); } else...
javascript
function initOnClick() { var clicks = document.querySelectorAll('[data-nctr]'); for (var i = 0; i < clicks.length; i++) { var tag = clicks[i]; if (tag.addEventListener) { tag.addEventListener("click", clickTrack, false); } else...
[ "function", "initOnClick", "(", ")", "{", "var", "clicks", "=", "document", ".", "querySelectorAll", "(", "'[data-nctr]'", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "clicks", ".", "length", ";", "i", "++", ")", "{", "var", "tag", "...
Click Track on click to element
[ "Click", "Track", "on", "click", "to", "element" ]
5fc7c993c08774945405c79a393584ef2ed589f7
https://github.com/nattreid/tracking/blob/5fc7c993c08774945405c79a393584ef2ed589f7/assets/nTracker.js#L159-L173
train
nattreid/tracking
assets/nTracker.js
clickTrack
function clickTrack(event) { var dataset = getClickDataset(event.path); var data = []; data.push('click=' + dataset.nctr); data.push('browser=' + getBrowser()); if (dataset.ncval !== undefined) { data.push('value=' + dataset.ncval); ...
javascript
function clickTrack(event) { var dataset = getClickDataset(event.path); var data = []; data.push('click=' + dataset.nctr); data.push('browser=' + getBrowser()); if (dataset.ncval !== undefined) { data.push('value=' + dataset.ncval); ...
[ "function", "clickTrack", "(", "event", ")", "{", "var", "dataset", "=", "getClickDataset", "(", "event", ".", "path", ")", ";", "var", "data", "=", "[", "]", ";", "data", ".", "push", "(", "'click='", "+", "dataset", ".", "nctr", ")", ";", "data", ...
Handler for click event @param event
[ "Handler", "for", "click", "event" ]
5fc7c993c08774945405c79a393584ef2ed589f7
https://github.com/nattreid/tracking/blob/5fc7c993c08774945405c79a393584ef2ed589f7/assets/nTracker.js#L179-L196
train
eliranmal/npm-package-env
lib/npm-package-env.js
init
function init(obj = {}, prevName = '') { return new Proxy(obj, { get (target, name) { if (typeof name === 'symbol' || deflectedProperties.includes(name)) { return Reflect.get(target, name); } ns.resetTo(prevName); ns.push(name); let...
javascript
function init(obj = {}, prevName = '') { return new Proxy(obj, { get (target, name) { if (typeof name === 'symbol' || deflectedProperties.includes(name)) { return Reflect.get(target, name); } ns.resetTo(prevName); ns.push(name); let...
[ "function", "init", "(", "obj", "=", "{", "}", ",", "prevName", "=", "''", ")", "{", "return", "new", "Proxy", "(", "obj", ",", "{", "get", "(", "target", ",", "name", ")", "{", "if", "(", "typeof", "name", "===", "'symbol'", "||", "deflectedProper...
empty prevName indicates the first access in the chain
[ "empty", "prevName", "indicates", "the", "first", "access", "in", "the", "chain" ]
4af33e9e388f72b895b27c00bbbe29407715b7b5
https://github.com/eliranmal/npm-package-env/blob/4af33e9e388f72b895b27c00bbbe29407715b7b5/lib/npm-package-env.js#L13-L37
train
jonschlinkert/digits
index.js
digits
function digits(val, num, ch) { return pad(val, num - val.length, ch); }
javascript
function digits(val, num, ch) { return pad(val, num - val.length, ch); }
[ "function", "digits", "(", "val", ",", "num", ",", "ch", ")", "{", "return", "pad", "(", "val", ",", "num", "-", "val", ".", "length", ",", "ch", ")", ";", "}" ]
Left pad the given `value` with the specified `number` of zeros or alternate `character`. ```js digits('abc', 10); //=> '0000000000abc' digits('abc', 10, '~'); //=> '~~~~~~~~~~abc' ``` @param {String} `value` @param {String} `number` @return {String} `character` @api public
[ "Left", "pad", "the", "given", "value", "with", "the", "specified", "number", "of", "zeros", "or", "alternate", "character", "." ]
81bc93f76999df57fc5da45cb5933fb331d0d8e5
https://github.com/jonschlinkert/digits/blob/81bc93f76999df57fc5da45cb5933fb331d0d8e5/index.js#L37-L39
train
tobkle/create-graphql-server-authorization
src/generator/getCode.js
compile
function compile(templates) { templates.forEach(partial => { partials[partial.name] = Handlebars.compile(partial.source); Handlebars.registerPartial(partial.name, partials[partial.name]); }); }
javascript
function compile(templates) { templates.forEach(partial => { partials[partial.name] = Handlebars.compile(partial.source); Handlebars.registerPartial(partial.name, partials[partial.name]); }); }
[ "function", "compile", "(", "templates", ")", "{", "templates", ".", "forEach", "(", "partial", "=>", "{", "partials", "[", "partial", ".", "name", "]", "=", "Handlebars", ".", "compile", "(", "partial", ".", "source", ")", ";", "Handlebars", ".", "regis...
define the compiler
[ "define", "the", "compiler" ]
d40718907f6d2bfb76fdcb4d2e0ae8ede5701456
https://github.com/tobkle/create-graphql-server-authorization/blob/d40718907f6d2bfb76fdcb4d2e0ae8ede5701456/src/generator/getCode.js#L76-L81
train
tobkle/create-graphql-server-authorization
src/generator/getCode.js
registerHandlebarsHelpers
function registerHandlebarsHelpers() { Handlebars.registerHelper('foreach', function(arr, options) { if (options.inverse && !arr.length) { return options.inverse(this); } return arr .map(function(item, index) { item.$index = index; item.$first = index === 0; item.$last ...
javascript
function registerHandlebarsHelpers() { Handlebars.registerHelper('foreach', function(arr, options) { if (options.inverse && !arr.length) { return options.inverse(this); } return arr .map(function(item, index) { item.$index = index; item.$first = index === 0; item.$last ...
[ "function", "registerHandlebarsHelpers", "(", ")", "{", "Handlebars", ".", "registerHelper", "(", "'foreach'", ",", "function", "(", "arr", ",", "options", ")", "{", "if", "(", "options", ".", "inverse", "&&", "!", "arr", ".", "length", ")", "{", "return",...
registers a helper, which could be used in the templates @example {{#foreach}} {{#if $last}} console.log('this was the last element') {{/if}} {{#if $notLast}} console.log('this was not the last one') {{/if}} {{/foreach}}
[ "registers", "a", "helper", "which", "could", "be", "used", "in", "the", "templates" ]
d40718907f6d2bfb76fdcb4d2e0ae8ede5701456
https://github.com/tobkle/create-graphql-server-authorization/blob/d40718907f6d2bfb76fdcb4d2e0ae8ede5701456/src/generator/getCode.js#L179-L195
train
yoo2001818/r6rs
src/parser.js
wrapData
function wrapData(entry, data, token) { let symbol = wrapSymbols[entry.special]; if (!symbol) return data; let symbolVal = new SymbolValue(symbol); if (token) { symbolVal.line = token.line; symbolVal.column = token.column; } let result = new PairValue(symbolVal, new PairValue(data)); entry.special...
javascript
function wrapData(entry, data, token) { let symbol = wrapSymbols[entry.special]; if (!symbol) return data; let symbolVal = new SymbolValue(symbol); if (token) { symbolVal.line = token.line; symbolVal.column = token.column; } let result = new PairValue(symbolVal, new PairValue(data)); entry.special...
[ "function", "wrapData", "(", "entry", ",", "data", ",", "token", ")", "{", "let", "symbol", "=", "wrapSymbols", "[", "entry", ".", "special", "]", ";", "if", "(", "!", "symbol", ")", "return", "data", ";", "let", "symbolVal", "=", "new", "SymbolValue",...
Wrap the data if special flag is on. COMMENT_IGNORE should be handled differently, though.
[ "Wrap", "the", "data", "if", "special", "flag", "is", "on", ".", "COMMENT_IGNORE", "should", "be", "handled", "differently", "though", "." ]
11dd18e451f7ccde6fbe31da7eac1825e3e9a439
https://github.com/yoo2001818/r6rs/blob/11dd18e451f7ccde6fbe31da7eac1825e3e9a439/src/parser.js#L41-L52
train
yoo2001818/r6rs
src/parser.js
pushData
function pushData(entry, data, token) { if (entry.con === 2) { throw injectError(new Error('Finished pair cannot have more values'), token); } if (token) { data.line = token.line; data.column = token.column; } let wrappedData = wrapData(entry, data, token); if (entry.comment) { entry.c...
javascript
function pushData(entry, data, token) { if (entry.con === 2) { throw injectError(new Error('Finished pair cannot have more values'), token); } if (token) { data.line = token.line; data.column = token.column; } let wrappedData = wrapData(entry, data, token); if (entry.comment) { entry.c...
[ "function", "pushData", "(", "entry", ",", "data", ",", "token", ")", "{", "if", "(", "entry", ".", "con", "===", "2", ")", "{", "throw", "injectError", "(", "new", "Error", "(", "'Finished pair cannot have more values'", ")", ",", "token", ")", ";", "}"...
Pushes the data into the stack entry. Note that this doesn't push the data into the stack..
[ "Pushes", "the", "data", "into", "the", "stack", "entry", ".", "Note", "that", "this", "doesn", "t", "push", "the", "data", "into", "the", "stack", ".." ]
11dd18e451f7ccde6fbe31da7eac1825e3e9a439
https://github.com/yoo2001818/r6rs/blob/11dd18e451f7ccde6fbe31da7eac1825e3e9a439/src/parser.js#L56-L95
train
tolokoban/ToloFrameWork
ker/com/x-latex/x-latex.com.js
parseGroup
function parseGroup(tokenizer) { // Group this functon will return. var mrow = {tag: 'mrow', children: []}; // Last child of mrow. var lastItem; // Current token. var tkn; // Current tag. var tag; // Macro. This is a function with this prototype: (tokenizer, mrow). var macro; for(;;) { tkn = ...
javascript
function parseGroup(tokenizer) { // Group this functon will return. var mrow = {tag: 'mrow', children: []}; // Last child of mrow. var lastItem; // Current token. var tkn; // Current tag. var tag; // Macro. This is a function with this prototype: (tokenizer, mrow). var macro; for(;;) { tkn = ...
[ "function", "parseGroup", "(", "tokenizer", ")", "{", "// Group this functon will return.", "var", "mrow", "=", "{", "tag", ":", "'mrow'", ",", "children", ":", "[", "]", "}", ";", "// Last child of mrow.", "var", "lastItem", ";", "// Current token.", "var", "tk...
Read tokens from a Tokenizer and return a group. The end of a group is when ye reach to last token or if we encounter the char '}'.
[ "Read", "tokens", "from", "a", "Tokenizer", "and", "return", "a", "group", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/com/x-latex/x-latex.com.js#L226-L293
train
andrewscwei/requiem
src/dom/hasAttribute.js
hasAttribute
function hasAttribute(element, name) { assertType(element, Node, false, 'Invalid element specified'); let value = element.getAttribute(name); if (value === '') return true; return !noval(value); }
javascript
function hasAttribute(element, name) { assertType(element, Node, false, 'Invalid element specified'); let value = element.getAttribute(name); if (value === '') return true; return !noval(value); }
[ "function", "hasAttribute", "(", "element", ",", "name", ")", "{", "assertType", "(", "element", ",", "Node", ",", "false", ",", "'Invalid element specified'", ")", ";", "let", "value", "=", "element", ".", "getAttribute", "(", "name", ")", ";", "if", "(",...
Checks to see if an element has the attribute of the specified name. @param {Node} element - Target element. @param {string} name - Attribute name. @return {boolean} True if attribute with said name exists, false otherwise. @alias module:requiem~dom.hasAttribute
[ "Checks", "to", "see", "if", "an", "element", "has", "the", "attribute", "of", "the", "specified", "name", "." ]
c4182bfffc9841c6de5718f689ad3c2060511777
https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/hasAttribute.js#L18-L23
train
codekirei/multiline-billboard
lib/index.js
handleStrs
function handleStrs(strs, opts) { const len = longest(strs) const text = strs .map(pad(len, opts.justify)) .map(wrap(opts)) .join('') return {len, text} }
javascript
function handleStrs(strs, opts) { const len = longest(strs) const text = strs .map(pad(len, opts.justify)) .map(wrap(opts)) .join('') return {len, text} }
[ "function", "handleStrs", "(", "strs", ",", "opts", ")", "{", "const", "len", "=", "longest", "(", "strs", ")", "const", "text", "=", "strs", ".", "map", "(", "pad", "(", "len", ",", "opts", ".", "justify", ")", ")", ".", "map", "(", "wrap", "(",...
Builds middle of billboard from an array of strings. @param {String[]} strs - text to put on billboard @param {Object} opts - options for this billboard @returns {String} formatted string for middle of billboard
[ "Builds", "middle", "of", "billboard", "from", "an", "array", "of", "strings", "." ]
7b1e446993bd76ac26652107c0cf01eb88d5365a
https://github.com/codekirei/multiline-billboard/blob/7b1e446993bd76ac26652107c0cf01eb88d5365a/lib/index.js#L134-L141
train
crishernandezmaps/liqen-scrapper
src/parseDom.js
getBodyObject
function getBodyObject ($) { const container = getContainer($) // Convert the root element into an array const children = [] container .children() .map((i, el) => { children.push(convertToNode($(el)[0])) }) return { children: children .filter(child => child !== null), name: '...
javascript
function getBodyObject ($) { const container = getContainer($) // Convert the root element into an array const children = [] container .children() .map((i, el) => { children.push(convertToNode($(el)[0])) }) return { children: children .filter(child => child !== null), name: '...
[ "function", "getBodyObject", "(", "$", ")", "{", "const", "container", "=", "getContainer", "(", "$", ")", "// Convert the root element into an array", "const", "children", "=", "[", "]", "container", ".", "children", "(", ")", ".", "map", "(", "(", "i", ","...
Get the Body of the DOM. Return it as plain JS object
[ "Get", "the", "Body", "of", "the", "DOM", ".", "Return", "it", "as", "plain", "JS", "object" ]
0462d25359ed13fc8321e85cb6a0d87abece7218
https://github.com/crishernandezmaps/liqen-scrapper/blob/0462d25359ed13fc8321e85cb6a0d87abece7218/src/parseDom.js#L4-L21
train
crishernandezmaps/liqen-scrapper
src/parseDom.js
getMetadata
function getMetadata ($) { const image = ($('figure[representativeofpage=true] img').attr('src') || $('meta[property="og:image"]').attr('content') || '') const dateStr = ($('meta[property="article:modified_time"]').attr('content') || $('meta[property="article:pu...
javascript
function getMetadata ($) { const image = ($('figure[representativeofpage=true] img').attr('src') || $('meta[property="og:image"]').attr('content') || '') const dateStr = ($('meta[property="article:modified_time"]').attr('content') || $('meta[property="article:pu...
[ "function", "getMetadata", "(", "$", ")", "{", "const", "image", "=", "(", "$", "(", "'figure[representativeofpage=true] img'", ")", ".", "attr", "(", "'src'", ")", "||", "$", "(", "'meta[property=\"og:image\"]'", ")", ".", "attr", "(", "'content'", ")", "||...
Get the metadata from the DOM. Return it as object
[ "Get", "the", "metadata", "from", "the", "DOM", ".", "Return", "it", "as", "object" ]
0462d25359ed13fc8321e85cb6a0d87abece7218
https://github.com/crishernandezmaps/liqen-scrapper/blob/0462d25359ed13fc8321e85cb6a0d87abece7218/src/parseDom.js#L30-L72
train
crishernandezmaps/liqen-scrapper
src/parseDom.js
convertToNode
function convertToNode (element) { switch (element.type) { case 'tag': return ['a', 'p', 'strong', 'em', 'b', 'em'].indexOf(element.name) !== -1 ? { name: element.name, attrs: filterAttributes(element.name, element.attribs), children: element ...
javascript
function convertToNode (element) { switch (element.type) { case 'tag': return ['a', 'p', 'strong', 'em', 'b', 'em'].indexOf(element.name) !== -1 ? { name: element.name, attrs: filterAttributes(element.name, element.attribs), children: element ...
[ "function", "convertToNode", "(", "element", ")", "{", "switch", "(", "element", ".", "type", ")", "{", "case", "'tag'", ":", "return", "[", "'a'", ",", "'p'", ",", "'strong'", ",", "'em'", ",", "'b'", ",", "'em'", "]", ".", "indexOf", "(", "element"...
private convert a cheerio element into a JS object representing a node
[ "private", "convert", "a", "cheerio", "element", "into", "a", "JS", "object", "representing", "a", "node" ]
0462d25359ed13fc8321e85cb6a0d87abece7218
https://github.com/crishernandezmaps/liqen-scrapper/blob/0462d25359ed13fc8321e85cb6a0d87abece7218/src/parseDom.js#L105-L125
train
crishernandezmaps/liqen-scrapper
src/parseDom.js
convertToText
function convertToText (object) { switch (typeof object) { case 'string': return object case 'object': const attrs = toPairs(object.attrs) .map(([name, value]) => `${name}="${value}"`) const tag = [object.name].concat(attrs) .join(' ') const ch...
javascript
function convertToText (object) { switch (typeof object) { case 'string': return object case 'object': const attrs = toPairs(object.attrs) .map(([name, value]) => `${name}="${value}"`) const tag = [object.name].concat(attrs) .join(' ') const ch...
[ "function", "convertToText", "(", "object", ")", "{", "switch", "(", "typeof", "object", ")", "{", "case", "'string'", ":", "return", "object", "case", "'object'", ":", "const", "attrs", "=", "toPairs", "(", "object", ".", "attrs", ")", ".", "map", "(", ...
private convert a JS object node into a text
[ "private", "convert", "a", "JS", "object", "node", "into", "a", "text" ]
0462d25359ed13fc8321e85cb6a0d87abece7218
https://github.com/crishernandezmaps/liqen-scrapper/blob/0462d25359ed13fc8321e85cb6a0d87abece7218/src/parseDom.js#L129-L149
train
crishernandezmaps/liqen-scrapper
src/parseDom.js
filterAttributes
function filterAttributes (name, attributes) { const filtered = {} if (attributes.href) { filtered.href = attributes.href } return filtered }
javascript
function filterAttributes (name, attributes) { const filtered = {} if (attributes.href) { filtered.href = attributes.href } return filtered }
[ "function", "filterAttributes", "(", "name", ",", "attributes", ")", "{", "const", "filtered", "=", "{", "}", "if", "(", "attributes", ".", "href", ")", "{", "filtered", ".", "href", "=", "attributes", ".", "href", "}", "return", "filtered", "}" ]
Filter the html attributes Return only the relevant ones
[ "Filter", "the", "html", "attributes", "Return", "only", "the", "relevant", "ones" ]
0462d25359ed13fc8321e85cb6a0d87abece7218
https://github.com/crishernandezmaps/liqen-scrapper/blob/0462d25359ed13fc8321e85cb6a0d87abece7218/src/parseDom.js#L153-L161
train
contexttesting/reducer
build/lib/index.js
_evaluateContexts
async function _evaluateContexts(contexts = []) { const c = Array.isArray(contexts) ? contexts : [contexts] const ep = c.map(evaluateContext) const res = await Promise.all(ep) return res }
javascript
async function _evaluateContexts(contexts = []) { const c = Array.isArray(contexts) ? contexts : [contexts] const ep = c.map(evaluateContext) const res = await Promise.all(ep) return res }
[ "async", "function", "_evaluateContexts", "(", "contexts", "=", "[", "]", ")", "{", "const", "c", "=", "Array", ".", "isArray", "(", "contexts", ")", "?", "contexts", ":", "[", "contexts", "]", "const", "ep", "=", "c", ".", "map", "(", "evaluateContext...
Evaluate a context or contexts in parallel. @param {!Array<_contextTesting.ContextConstructor>} [contexts] The context constructors (class, function, object).
[ "Evaluate", "a", "context", "or", "contexts", "in", "parallel", "." ]
cb5a9b80bba38fecbe44d552f2d160e6f7ad29ea
https://github.com/contexttesting/reducer/blob/cb5a9b80bba38fecbe44d552f2d160e6f7ad29ea/build/lib/index.js#L5-L10
train
Orgun109uk/sort-by-key
lib/SortByKey.js
arraySortByKey
function arraySortByKey(data, key, reverse) { data.sort((a, b) => { const aw = a[key] !== undefined ? ( typeof a[key] === 'function' ? parseInt(a[key](), 10) : parseInt(a[key], 10) ) : 0; const bw = b[key] !== undefined ? ( typeof b[key] === 'f...
javascript
function arraySortByKey(data, key, reverse) { data.sort((a, b) => { const aw = a[key] !== undefined ? ( typeof a[key] === 'function' ? parseInt(a[key](), 10) : parseInt(a[key], 10) ) : 0; const bw = b[key] !== undefined ? ( typeof b[key] === 'f...
[ "function", "arraySortByKey", "(", "data", ",", "key", ",", "reverse", ")", "{", "data", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "{", "const", "aw", "=", "a", "[", "key", "]", "!==", "undefined", "?", "(", "typeof", "a", "[", "key", "]...
Sort an array by the provided key. @param {Array} data The array to sort. @param {string} key The key to use for sorting. @param {boolean} [reverse=false] - Reverse the order.
[ "Sort", "an", "array", "by", "the", "provided", "key", "." ]
615fe5be9cb7f0af60152e7b5ddef16d69412210
https://github.com/Orgun109uk/sort-by-key/blob/615fe5be9cb7f0af60152e7b5ddef16d69412210/lib/SortByKey.js#L17-L36
train
Orgun109uk/sort-by-key
lib/SortByKey.js
objectSortByKey
function objectSortByKey(data, key, reverse) { let keys = Object.keys(data); keys.sort((a, b) => { const aw = data[a][key] !== undefined ? parseInt(data[a][key], 10) : 0; const bw = data[b][key] !== undefined ? parseInt(data[b][key], 10) : 0; if (aw === bw) { return 0; ...
javascript
function objectSortByKey(data, key, reverse) { let keys = Object.keys(data); keys.sort((a, b) => { const aw = data[a][key] !== undefined ? parseInt(data[a][key], 10) : 0; const bw = data[b][key] !== undefined ? parseInt(data[b][key], 10) : 0; if (aw === bw) { return 0; ...
[ "function", "objectSortByKey", "(", "data", ",", "key", ",", "reverse", ")", "{", "let", "keys", "=", "Object", ".", "keys", "(", "data", ")", ";", "keys", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "{", "const", "aw", "=", "data", "[", "...
Sort an object by the provided key. @param {Array} data The object to sort. @param {String} key The key to use for sorting. @param {boolean} [reverse=false] Reverse the order.
[ "Sort", "an", "object", "by", "the", "provided", "key", "." ]
615fe5be9cb7f0af60152e7b5ddef16d69412210
https://github.com/Orgun109uk/sort-by-key/blob/615fe5be9cb7f0af60152e7b5ddef16d69412210/lib/SortByKey.js#L45-L62
train
kevinoid/promised-read
lib/abort-error.js
AbortError
function AbortError(message) { // Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message if (!(this instanceof AbortError)) { return new AbortError(message); } Error.captureStackTrace(this, AbortError); if (message !== undefined) { Object.defineProperty(this, 'message', { value: String...
javascript
function AbortError(message) { // Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message if (!(this instanceof AbortError)) { return new AbortError(message); } Error.captureStackTrace(this, AbortError); if (message !== undefined) { Object.defineProperty(this, 'message', { value: String...
[ "function", "AbortError", "(", "message", ")", "{", "// Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message", "if", "(", "!", "(", "this", "instanceof", "AbortError", ")", ")", "{", "return", "new", "AbortError", "(", "message", ")", ";", "}", "Er...
Constructs an AbortError. @class Represents an error caused by an action being aborted. @constructor @param {string=} message Human-readable description of the error.
[ "Constructs", "an", "AbortError", "." ]
c6adf477f4a64d5142363d84f7f83f5f07b8f682
https://github.com/kevinoid/promised-read/blob/c6adf477f4a64d5142363d84f7f83f5f07b8f682/lib/abort-error.js#L16-L27
train
buunguyen/starx
lib/index.js
starx
function starx(obj) { if (!isGenerator(obj) && !isIterator(obj)) throw new TypeError('obj must be a generator or iterator') return function executor(done) { var self = this, done = once(done || noop), iterator = isGenerator(obj) ? obj.call(self) : obj process.nextTick(next) ...
javascript
function starx(obj) { if (!isGenerator(obj) && !isIterator(obj)) throw new TypeError('obj must be a generator or iterator') return function executor(done) { var self = this, done = once(done || noop), iterator = isGenerator(obj) ? obj.call(self) : obj process.nextTick(next) ...
[ "function", "starx", "(", "obj", ")", "{", "if", "(", "!", "isGenerator", "(", "obj", ")", "&&", "!", "isIterator", "(", "obj", ")", ")", "throw", "new", "TypeError", "(", "'obj must be a generator or iterator'", ")", "return", "function", "executor", "(", ...
Creates an executor for the provided generator or iterator
[ "Creates", "an", "executor", "for", "the", "provided", "generator", "or", "iterator" ]
015653c93622012a81644dc19c9dcbc4ec897564
https://github.com/buunguyen/starx/blob/015653c93622012a81644dc19c9dcbc4ec897564/lib/index.js#L10-L39
train
shama/willitmerge
lib/willitmerge.js
execSeries
function execSeries(cmds, done) { var out = []; async.forEachSeries(cmds, function(cmd, next) { exec(cmd, function(err, stdout, stderr) { out.push({ stdout: stdout, stderr: stderr, err: err }); next(); }); }, function() { done(null, out); }); }
javascript
function execSeries(cmds, done) { var out = []; async.forEachSeries(cmds, function(cmd, next) { exec(cmd, function(err, stdout, stderr) { out.push({ stdout: stdout, stderr: stderr, err: err }); next(); }); }, function() { done(null, out); }); }
[ "function", "execSeries", "(", "cmds", ",", "done", ")", "{", "var", "out", "=", "[", "]", ";", "async", ".", "forEachSeries", "(", "cmds", ",", "function", "(", "cmd", ",", "next", ")", "{", "exec", "(", "cmd", ",", "function", "(", "err", ",", ...
exec commands in a series and retun the results
[ "exec", "commands", "in", "a", "series", "and", "retun", "the", "results" ]
2fe91d05191fb05ac6da685828d109a3a5885028
https://github.com/shama/willitmerge/blob/2fe91d05191fb05ac6da685828d109a3a5885028/lib/willitmerge.js#L273-L287
train
shama/willitmerge
lib/willitmerge.js
parseImpact
function parseImpact(data) { var impact = /([0-9]+) insertions\(\+\), ([0-9]+) deletions\(\-\)/i.exec(data); if (impact) { return Number(impact[1]) + Number(impact[2]); } return 0; }
javascript
function parseImpact(data) { var impact = /([0-9]+) insertions\(\+\), ([0-9]+) deletions\(\-\)/i.exec(data); if (impact) { return Number(impact[1]) + Number(impact[2]); } return 0; }
[ "function", "parseImpact", "(", "data", ")", "{", "var", "impact", "=", "/", "([0-9]+) insertions\\(\\+\\), ([0-9]+) deletions\\(\\-\\)", "/", "i", ".", "exec", "(", "data", ")", ";", "if", "(", "impact", ")", "{", "return", "Number", "(", "impact", "[", "1"...
parse the insertions + deletions
[ "parse", "the", "insertions", "+", "deletions" ]
2fe91d05191fb05ac6da685828d109a3a5885028
https://github.com/shama/willitmerge/blob/2fe91d05191fb05ac6da685828d109a3a5885028/lib/willitmerge.js#L290-L296
train
derdesign/protos
storages/mongodb.js
MongoStorage
function MongoStorage(config) { var self = this; this.events = new EventEmitter(); config = protos.extend({ host: 'localhost', port: 27017, database: 'store', collection: 'keyvalue', username: '', password: '', safe: true }, config); if (typeof config.por...
javascript
function MongoStorage(config) { var self = this; this.events = new EventEmitter(); config = protos.extend({ host: 'localhost', port: 27017, database: 'store', collection: 'keyvalue', username: '', password: '', safe: true }, config); if (typeof config.por...
[ "function", "MongoStorage", "(", "config", ")", "{", "var", "self", "=", "this", ";", "this", ".", "events", "=", "new", "EventEmitter", "(", ")", ";", "config", "=", "protos", ".", "extend", "(", "{", "host", ":", "'localhost'", ",", "port", ":", "2...
MongoDB Storage class @class MongoStorage @extends Storage @constructor @param {object} app Application instance @param {object} config Storage configuration
[ "MongoDB", "Storage", "class" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/storages/mongodb.js#L23-L110
train
Mozu/mozu-theme-helpers
lib/utils/compiler/themes.js
getThemeFromPath
function getThemeFromPath(dir, program, cb) { var configPath = path.resolve(dir, "theme.json"); program.log(2, constants.LOG_SEV_INFO, "Attempting to read " + configPath); fs.readFile(configPath, { encoding: 'utf-8' }, function (err, data) { if (err) { program.log(1, ...
javascript
function getThemeFromPath(dir, program, cb) { var configPath = path.resolve(dir, "theme.json"); program.log(2, constants.LOG_SEV_INFO, "Attempting to read " + configPath); fs.readFile(configPath, { encoding: 'utf-8' }, function (err, data) { if (err) { program.log(1, ...
[ "function", "getThemeFromPath", "(", "dir", ",", "program", ",", "cb", ")", "{", "var", "configPath", "=", "path", ".", "resolve", "(", "dir", ",", "\"theme.json\"", ")", ";", "program", ".", "log", "(", "2", ",", "constants", ".", "LOG_SEV_INFO", ",", ...
requires absolute path
[ "requires", "absolute", "path" ]
2cb42851298d01e668d2d4ffa8f46d52043066c8
https://github.com/Mozu/mozu-theme-helpers/blob/2cb42851298d01e668d2d4ffa8f46d52043066c8/lib/utils/compiler/themes.js#L48-L74
train
redisjs/jsr-server
lib/server.js
Server
function Server(options) { //TcpServer.call(this, options); var onError = onFatalError.bind(this); /* istanbul ignore next: always in test env */ if(process.env.NODE_ENV !== Constants.TEST) { process .on('error', onError) .on('uncaughtException', onError); } this._tcp = null; this._unix...
javascript
function Server(options) { //TcpServer.call(this, options); var onError = onFatalError.bind(this); /* istanbul ignore next: always in test env */ if(process.env.NODE_ENV !== Constants.TEST) { process .on('error', onError) .on('uncaughtException', onError); } this._tcp = null; this._unix...
[ "function", "Server", "(", "options", ")", "{", "//TcpServer.call(this, options);", "var", "onError", "=", "onFatalError", ".", "bind", "(", "this", ")", ";", "/* istanbul ignore next: always in test env */", "if", "(", "process", ".", "env", ".", "NODE_ENV", "!==",...
Redis server.
[ "Redis", "server", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/server.js#L37-L78
train
redisjs/jsr-server
lib/server.js
connection
function connection(socket, server) { var conn = new Connection(socket) , tcp = (server instanceof TcpServer); var maxclients = this.conf.get(ConfigKey.MAXCLIENTS); if(maxclients && (this.state.length + 1 > maxclients)) { this.state.emit('rejected', conn.client.addr, maxclients); this.log.debug('re...
javascript
function connection(socket, server) { var conn = new Connection(socket) , tcp = (server instanceof TcpServer); var maxclients = this.conf.get(ConfigKey.MAXCLIENTS); if(maxclients && (this.state.length + 1 > maxclients)) { this.state.emit('rejected', conn.client.addr, maxclients); this.log.debug('re...
[ "function", "connection", "(", "socket", ",", "server", ")", "{", "var", "conn", "=", "new", "Connection", "(", "socket", ")", ",", "tcp", "=", "(", "server", "instanceof", "TcpServer", ")", ";", "var", "maxclients", "=", "this", ".", "conf", ".", "get...
Handle a connection event. @param socket The underlying client socket. @param server The TCP or UNIX server.
[ "Handle", "a", "connection", "event", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/server.js#L88-L129
train
redisjs/jsr-server
lib/server.js
monitor
function monitor(req, res) { var socket = req.conn.socket , args = [req.cmd].concat(req.args) , t = systime() , str; // quote command and args args = args.map(function(arg) { return '"' + arg + '"'; }) // TODO: figure out meaning of ip/host prefix: [0 // build up the monitor simple string...
javascript
function monitor(req, res) { var socket = req.conn.socket , args = [req.cmd].concat(req.args) , t = systime() , str; // quote command and args args = args.map(function(arg) { return '"' + arg + '"'; }) // TODO: figure out meaning of ip/host prefix: [0 // build up the monitor simple string...
[ "function", "monitor", "(", "req", ",", "res", ")", "{", "var", "socket", "=", "req", ".", "conn", ".", "socket", ",", "args", "=", "[", "req", ".", "cmd", "]", ".", "concat", "(", "req", ".", "args", ")", ",", "t", "=", "systime", "(", ")", ...
Emit the monitor event string.
[ "Emit", "the", "monitor", "event", "string", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/server.js#L134-L156
train
redisjs/jsr-server
lib/server.js
publish
function publish(conn, channel, indices, message) { var i , conn; for(i = 0;i < indices.length;i++) { conn = this._state.getClient(indices[i]); if(conn) { conn.write(message); } } }
javascript
function publish(conn, channel, indices, message) { var i , conn; for(i = 0;i < indices.length;i++) { conn = this._state.getClient(indices[i]); if(conn) { conn.write(message); } } }
[ "function", "publish", "(", "conn", ",", "channel", ",", "indices", ",", "message", ")", "{", "var", "i", ",", "conn", ";", "for", "(", "i", "=", "0", ";", "i", "<", "indices", ".", "length", ";", "i", "++", ")", "{", "conn", "=", "this", ".", ...
Dispatches publish messages to target clients.
[ "Dispatches", "publish", "messages", "to", "target", "clients", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/server.js#L161-L170
train
redisjs/jsr-server
lib/server.js
delegate
function delegate(req, res) { var cmd = req.info.command , method; if(!cmd.sub) { throw new Error('attempt to delegate with no subcommand info'); } method = req.exec[cmd.sub.cmd]; // subcommand is declared but the command exec handler // has not declared the method and is attempting to delegate ...
javascript
function delegate(req, res) { var cmd = req.info.command , method; if(!cmd.sub) { throw new Error('attempt to delegate with no subcommand info'); } method = req.exec[cmd.sub.cmd]; // subcommand is declared but the command exec handler // has not declared the method and is attempting to delegate ...
[ "function", "delegate", "(", "req", ",", "res", ")", "{", "var", "cmd", "=", "req", ".", "info", ".", "command", ",", "method", ";", "if", "(", "!", "cmd", ".", "sub", ")", "{", "throw", "new", "Error", "(", "'attempt to delegate with no subcommand info'...
Delegate a subcommand to a method declared on the exec instance.
[ "Delegate", "a", "subcommand", "to", "a", "method", "declared", "on", "the", "exec", "instance", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/server.js#L175-L198
train
redisjs/jsr-server
lib/server.js
command
function command(req, res) { this.stats.commands++; //console.dir(this); // guaranteed to have a string command by connection var cmd = req.cmd // guaranteed to have an arguments array by connection , args = req.args // select implementation should guarantee a valid db index // on the connec...
javascript
function command(req, res) { this.stats.commands++; //console.dir(this); // guaranteed to have a string command by connection var cmd = req.cmd // guaranteed to have an arguments array by connection , args = req.args // select implementation should guarantee a valid db index // on the connec...
[ "function", "command", "(", "req", ",", "res", ")", "{", "this", ".", "stats", ".", "commands", "++", ";", "//console.dir(this);", "// guaranteed to have a string command by connection", "var", "cmd", "=", "req", ".", "cmd", "// guaranteed to have an arguments array by ...
Process an incoming command. @param req The connection request. @param res The connection response.
[ "Process", "an", "incoming", "command", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/server.js#L206-L288
train
redisjs/jsr-server
lib/server.js
disconnect
function disconnect(conn, socket, err) { //console.dir('disconnect'); // clean monitor listeners if(this._monitor[conn.id]) { this.removeListener('monitor', this._monitor[conn.id]); delete this._monitor[conn.id]; } this._state.removeConnection(conn); }
javascript
function disconnect(conn, socket, err) { //console.dir('disconnect'); // clean monitor listeners if(this._monitor[conn.id]) { this.removeListener('monitor', this._monitor[conn.id]); delete this._monitor[conn.id]; } this._state.removeConnection(conn); }
[ "function", "disconnect", "(", "conn", ",", "socket", ",", "err", ")", "{", "//console.dir('disconnect');", "// clean monitor listeners", "if", "(", "this", ".", "_monitor", "[", "conn", ".", "id", "]", ")", "{", "this", ".", "removeListener", "(", "'monitor'"...
Listener for the connection disconnect event triggered by the socket close event. @param conn The connection. @param socket The underlying socket. @param err Boolean indicating if a transmission error occured.
[ "Listener", "for", "the", "connection", "disconnect", "event", "triggered", "by", "the", "socket", "close", "event", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/server.js#L335-L345
train
redisjs/jsr-server
lib/server.js
load
function load(opts, cb) { if(typeof opts === 'function') { cb = opts; opts = null; } var args = opts && opts.args ? opts.args : null , defaults = path.normalize(path.join(__dirname, 'command')); opts = opts || argv(args); if(opts.commands === undefined) { opts.commands = [defaults]; }else ...
javascript
function load(opts, cb) { if(typeof opts === 'function') { cb = opts; opts = null; } var args = opts && opts.args ? opts.args : null , defaults = path.normalize(path.join(__dirname, 'command')); opts = opts || argv(args); if(opts.commands === undefined) { opts.commands = [defaults]; }else ...
[ "function", "load", "(", "opts", ",", "cb", ")", "{", "if", "(", "typeof", "opts", "===", "'function'", ")", "{", "cb", "=", "opts", ";", "opts", "=", "null", ";", "}", "var", "args", "=", "opts", "&&", "opts", ".", "args", "?", "opts", ".", "a...
Loads command definitions.
[ "Loads", "command", "definitions", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/server.js#L350-L440
train
redisjs/jsr-server
lib/server.js
listen
function listen() { var args = [] , port = this.conf.get(ConfigKey.PORT) , socket = this.conf.get(ConfigKey.UNIXSOCKET) , perm = this.conf.get(ConfigKey.UNIXSOCKETPERM) , backlog = this.conf.get(ConfigKey.TCP_BACKLOG) , cb = typeof arguments[arguments.length - 1] === 'function' ? arguments[a...
javascript
function listen() { var args = [] , port = this.conf.get(ConfigKey.PORT) , socket = this.conf.get(ConfigKey.UNIXSOCKET) , perm = this.conf.get(ConfigKey.UNIXSOCKETPERM) , backlog = this.conf.get(ConfigKey.TCP_BACKLOG) , cb = typeof arguments[arguments.length - 1] === 'function' ? arguments[a...
[ "function", "listen", "(", ")", "{", "var", "args", "=", "[", "]", ",", "port", "=", "this", ".", "conf", ".", "get", "(", "ConfigKey", ".", "PORT", ")", ",", "socket", "=", "this", ".", "conf", ".", "get", "(", "ConfigKey", ".", "UNIXSOCKET", ")...
Listen on a port or socket.
[ "Listen", "on", "a", "port", "or", "socket", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/server.js#L445-L506
train
redisjs/jsr-server
lib/server.js
shutdown
function shutdown(opts, cb) { if(typeof opts === 'function') { cb = opts; opts = null; } opts = opts || {}; var code = opts.code || 0 , i = -1 , snapshots = this.state.conf.get(ConfigKey.SAVE) , save = typeof opts.save === 'boolean' ? opts.save : null; if(save === null) { save = snaps...
javascript
function shutdown(opts, cb) { if(typeof opts === 'function') { cb = opts; opts = null; } opts = opts || {}; var code = opts.code || 0 , i = -1 , snapshots = this.state.conf.get(ConfigKey.SAVE) , save = typeof opts.save === 'boolean' ? opts.save : null; if(save === null) { save = snaps...
[ "function", "shutdown", "(", "opts", ",", "cb", ")", "{", "if", "(", "typeof", "opts", "===", "'function'", ")", "{", "cb", "=", "opts", ";", "opts", "=", "null", ";", "}", "opts", "=", "opts", "||", "{", "}", ";", "var", "code", "=", "opts", "...
Graceful shutdown stop accepting new connections.
[ "Graceful", "shutdown", "stop", "accepting", "new", "connections", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/server.js#L511-L600
train
redisjs/jsr-server
lib/server.js
createConnection
function createConnection() { // create the internal socket object var server = new Socket() , client = new Socket(); // pair the sockets client.pair = server; server.pair = client; // register the server side so it is wrapped // in a connection and stored as an active connection this.connection(...
javascript
function createConnection() { // create the internal socket object var server = new Socket() , client = new Socket(); // pair the sockets client.pair = server; server.pair = client; // register the server side so it is wrapped // in a connection and stored as an active connection this.connection(...
[ "function", "createConnection", "(", ")", "{", "// create the internal socket object", "var", "server", "=", "new", "Socket", "(", ")", ",", "client", "=", "new", "Socket", "(", ")", ";", "// pair the sockets", "client", ".", "pair", "=", "server", ";", "serve...
Creates a socket object to be used by a client within this process.
[ "Creates", "a", "socket", "object", "to", "be", "used", "by", "a", "client", "within", "this", "process", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/server.js#L613-L629
train
wshager/xvnode
lib/xvnode.js
serialize
function serialize(node, indent) { indent = indent || 0; var type = node._type; var v; if (type < 3 || type == 7) { var name = node.name(); if (type == 1) { var children = node; var ret = ""; var attrs = ""; var hasChildNodes = false; children.forEach(function (child, i) { var type = child._t...
javascript
function serialize(node, indent) { indent = indent || 0; var type = node._type; var v; if (type < 3 || type == 7) { var name = node.name(); if (type == 1) { var children = node; var ret = ""; var attrs = ""; var hasChildNodes = false; children.forEach(function (child, i) { var type = child._t...
[ "function", "serialize", "(", "node", ",", "indent", ")", "{", "indent", "=", "indent", "||", "0", ";", "var", "type", "=", "node", ".", "_type", ";", "var", "v", ";", "if", "(", "type", "<", "3", "||", "type", "==", "7", ")", "{", "var", "name...
children is a no-op because it's equal to the node
[ "children", "is", "a", "no", "-", "op", "because", "it", "s", "equal", "to", "the", "node" ]
01b1a72da3065da19e4397bcb67a5937bf49fdfc
https://github.com/wshager/xvnode/blob/01b1a72da3065da19e4397bcb67a5937bf49fdfc/lib/xvnode.js#L93-L137
train
andrewscwei/requiem
src/utils/getRect.js
getRect
function getRect(element, reference) { if (element === window) return getViewportRect(); if (!reference) reference = window; let elements = [].concat(element); let n = elements.length; if (n <= 0) return null; let refRect = getRect(reference); if (!assert(refRect, 'Cannot determine reference FOV.')) ...
javascript
function getRect(element, reference) { if (element === window) return getViewportRect(); if (!reference) reference = window; let elements = [].concat(element); let n = elements.length; if (n <= 0) return null; let refRect = getRect(reference); if (!assert(refRect, 'Cannot determine reference FOV.')) ...
[ "function", "getRect", "(", "element", ",", "reference", ")", "{", "if", "(", "element", "===", "window", ")", "return", "getViewportRect", "(", ")", ";", "if", "(", "!", "reference", ")", "reference", "=", "window", ";", "let", "elements", "=", "[", "...
Gets the rect of a given element or the overall rect of an array of elements. @param {Node|Node[]} element @param {Object} [reference=window] @return {Object} Object containing top, left, bottom, right, width, height. @alias module:requiem~utils.getRect
[ "Gets", "the", "rect", "of", "a", "given", "element", "or", "the", "overall", "rect", "of", "an", "array", "of", "elements", "." ]
c4182bfffc9841c6de5718f689ad3c2060511777
https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/utils/getRect.js#L18-L58
train
Lindurion/closure-pro-build
3p/closure-library-20130212/closure/goog/result/resultutil.js
function(res) { var results = /** @type {Array.<!goog.result.Result>} */ ( res.getValue()); if (goog.array.every(results, resolvedSuccessfully)) { combinedResult.setValue(results); } else { combinedResult.setError(results); } }
javascript
function(res) { var results = /** @type {Array.<!goog.result.Result>} */ ( res.getValue()); if (goog.array.every(results, resolvedSuccessfully)) { combinedResult.setValue(results); } else { combinedResult.setError(results); } }
[ "function", "(", "res", ")", "{", "var", "results", "=", "/** @type {Array.<!goog.result.Result>} */", "(", "res", ".", "getValue", "(", ")", ")", ";", "if", "(", "goog", ".", "array", ".", "every", "(", "results", ",", "resolvedSuccessfully", ")", ")", "{...
The combined result never ERRORs
[ "The", "combined", "result", "never", "ERRORs" ]
c279d0fcc3a65969d2fe965f55e627b074792f1a
https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/3p/closure-library-20130212/closure/goog/result/resultutil.js#L451-L459
train
pupipipu/botbuilder-proxy
Node/core/lib/dialogs/PromptRecognizers.js
matchAll
function matchAll(exp, text) { exp.lastIndex = 0; var matches = []; var match; while ((match = exp.exec(text)) != null) { matches.push(match[0]); } return matches; }
javascript
function matchAll(exp, text) { exp.lastIndex = 0; var matches = []; var match; while ((match = exp.exec(text)) != null) { matches.push(match[0]); } return matches; }
[ "function", "matchAll", "(", "exp", ",", "text", ")", "{", "exp", ".", "lastIndex", "=", "0", ";", "var", "matches", "=", "[", "]", ";", "var", "match", ";", "while", "(", "(", "match", "=", "exp", ".", "exec", "(", "text", ")", ")", "!=", "nul...
Matches all occurences of an expression in a string.
[ "Matches", "all", "occurences", "of", "an", "expression", "in", "a", "string", "." ]
4c2e9dddddcd579de98280bbceb011c357bfca1c
https://github.com/pupipipu/botbuilder-proxy/blob/4c2e9dddddcd579de98280bbceb011c357bfca1c/Node/core/lib/dialogs/PromptRecognizers.js#L345-L353
train
pupipipu/botbuilder-proxy
Node/core/lib/dialogs/PromptRecognizers.js
tokenize
function tokenize(text) { var tokens = []; if (text && text.length > 0) { var token = ''; for (var i = 0; i < text.length; i++) { var chr = text[i]; if (breakingChars.indexOf(chr) >= 0) { if (token.length > 0) { tokens.push(token); ...
javascript
function tokenize(text) { var tokens = []; if (text && text.length > 0) { var token = ''; for (var i = 0; i < text.length; i++) { var chr = text[i]; if (breakingChars.indexOf(chr) >= 0) { if (token.length > 0) { tokens.push(token); ...
[ "function", "tokenize", "(", "text", ")", "{", "var", "tokens", "=", "[", "]", ";", "if", "(", "text", "&&", "text", ".", "length", ">", "0", ")", "{", "var", "token", "=", "''", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "text", ...
Breaks a string of text into an array of tokens.
[ "Breaks", "a", "string", "of", "text", "into", "an", "array", "of", "tokens", "." ]
4c2e9dddddcd579de98280bbceb011c357bfca1c
https://github.com/pupipipu/botbuilder-proxy/blob/4c2e9dddddcd579de98280bbceb011c357bfca1c/Node/core/lib/dialogs/PromptRecognizers.js#L355-L376
train
unkelpehr/qbus
lib/index.js
normalizePath
function normalizePath (path) { // Remove double slashes if (path.indexOf('//') !== -1) { path = path.replace(/\/+/g, '/'); } // Shift slash if (path[0] === '/') { path = path.substr(1); } // Pop slash if (path[path.length - 1] === '/') { path = path.substr(0, path.length - 1); } retur...
javascript
function normalizePath (path) { // Remove double slashes if (path.indexOf('//') !== -1) { path = path.replace(/\/+/g, '/'); } // Shift slash if (path[0] === '/') { path = path.substr(1); } // Pop slash if (path[path.length - 1] === '/') { path = path.substr(0, path.length - 1); } retur...
[ "function", "normalizePath", "(", "path", ")", "{", "// Remove double slashes", "if", "(", "path", ".", "indexOf", "(", "'//'", ")", "!==", "-", "1", ")", "{", "path", "=", "path", ".", "replace", "(", "/", "\\/+", "/", "g", ",", "'/'", ")", ";", "...
Normalizes given path by converting double frontslashes to singles and removing the slashes from the beginning and end of the string. @param {String} path The path to normalize @return {String} Normalized path
[ "Normalizes", "given", "path", "by", "converting", "double", "frontslashes", "to", "singles", "and", "removing", "the", "slashes", "from", "the", "beginning", "and", "end", "of", "the", "string", "." ]
95f1e1a9579ada651608dc84681f15a2f6fd0248
https://github.com/unkelpehr/qbus/blob/95f1e1a9579ada651608dc84681f15a2f6fd0248/lib/index.js#L14-L31
train
unkelpehr/qbus
lib/index.js
execQuery
function execQuery (query) { var match, i, arr; if ((match = this.exec(query))) { arr = new Array(match.length - 1); for (i = 1; i < match.length; ++i) { arr[i - 1] = match[i]; } return arr; } return match; }
javascript
function execQuery (query) { var match, i, arr; if ((match = this.exec(query))) { arr = new Array(match.length - 1); for (i = 1; i < match.length; ++i) { arr[i - 1] = match[i]; } return arr; } return match; }
[ "function", "execQuery", "(", "query", ")", "{", "var", "match", ",", "i", ",", "arr", ";", "if", "(", "(", "match", "=", "this", ".", "exec", "(", "query", ")", ")", ")", "{", "arr", "=", "new", "Array", "(", "match", ".", "length", "-", "1", ...
Passes given query to 'this.exec' and shifts the first, mandatory, full match. This function is added as a property to all RegExp-objects that passes Qbus.parse. @method execQuery @param {String} query String execute @return {Null|Array>} Null if it does not match, otherwise Array.
[ "Passes", "given", "query", "to", "this", ".", "exec", "and", "shifts", "the", "first", "mandatory", "full", "match", ".", "This", "function", "is", "added", "as", "a", "property", "to", "all", "RegExp", "-", "objects", "that", "passes", "Qbus", ".", "pa...
95f1e1a9579ada651608dc84681f15a2f6fd0248
https://github.com/unkelpehr/qbus/blob/95f1e1a9579ada651608dc84681f15a2f6fd0248/lib/index.js#L64-L78
train
unkelpehr/qbus
lib/index.js
parse
function parse (expr) { var finalRegexp, strSlashPref; if (typeof expr !== 'string') { // Handle RegExp `expr` if (expr instanceof RegExp) { finalRegexp = new RegExp(expr); finalRegexp.query = execQuery; return finalRegexp; } throw new TypeError( 'Usage: qbus.parse(<`query` = Strin...
javascript
function parse (expr) { var finalRegexp, strSlashPref; if (typeof expr !== 'string') { // Handle RegExp `expr` if (expr instanceof RegExp) { finalRegexp = new RegExp(expr); finalRegexp.query = execQuery; return finalRegexp; } throw new TypeError( 'Usage: qbus.parse(<`query` = Strin...
[ "function", "parse", "(", "expr", ")", "{", "var", "finalRegexp", ",", "strSlashPref", ";", "if", "(", "typeof", "expr", "!==", "'string'", ")", "{", "// Handle RegExp `expr`", "if", "(", "expr", "instanceof", "RegExp", ")", "{", "finalRegexp", "=", "new", ...
Converts given expression to RegExp. If a RegExp is given it will copy it and add 'execQuery' to its properties. @method emit @param {String|RegExp} expr The string to convert or RegExp to add 'execQuery'. @return {RegExp}
[ "Converts", "given", "expression", "to", "RegExp", ".", "If", "a", "RegExp", "is", "given", "it", "will", "copy", "it", "and", "add", "execQuery", "to", "its", "properties", "." ]
95f1e1a9579ada651608dc84681f15a2f6fd0248
https://github.com/unkelpehr/qbus/blob/95f1e1a9579ada651608dc84681f15a2f6fd0248/lib/index.js#L88-L167
train
tjmehta/native-types
index.js
isNative
function isNative (val) { if (isPrimitive(val)) { return true } return natives.some(function (Class) { return val === Class || directInstanceOf(val, Class) }) }
javascript
function isNative (val) { if (isPrimitive(val)) { return true } return natives.some(function (Class) { return val === Class || directInstanceOf(val, Class) }) }
[ "function", "isNative", "(", "val", ")", "{", "if", "(", "isPrimitive", "(", "val", ")", ")", "{", "return", "true", "}", "return", "natives", ".", "some", "(", "function", "(", "Class", ")", "{", "return", "val", "===", "Class", "||", "directInstanceO...
returns if a value is an instance of native type @param ctx.{*} ctx.val ctx.value to check if is native @return {Boolean} ctx.true if val is native, else false
[ "returns", "if", "a", "value", "is", "an", "instance", "of", "native", "type" ]
8e100d2b77f530d62817864235577ff9a8cd5db5
https://github.com/tjmehta/native-types/blob/8e100d2b77f530d62817864235577ff9a8cd5db5/index.js#L98-L105
train
tjmehta/native-types
index.js
isPrimitive
function isPrimitive (val) { if (val === null || val === undefined || val === Infinity || isLiterallyNaN(val)) { return true } return primitives.some(function (Class) { return val === Class || directInstanceOf(val, Class) }) }
javascript
function isPrimitive (val) { if (val === null || val === undefined || val === Infinity || isLiterallyNaN(val)) { return true } return primitives.some(function (Class) { return val === Class || directInstanceOf(val, Class) }) }
[ "function", "isPrimitive", "(", "val", ")", "{", "if", "(", "val", "===", "null", "||", "val", "===", "undefined", "||", "val", "===", "Infinity", "||", "isLiterallyNaN", "(", "val", ")", ")", "{", "return", "true", "}", "return", "primitives", ".", "s...
returns if a value is an instance of a primitive type @param {*} thing value to check if is primitive @return {Boolean} true if val is primitive, else false
[ "returns", "if", "a", "value", "is", "an", "instance", "of", "a", "primitive", "type" ]
8e100d2b77f530d62817864235577ff9a8cd5db5
https://github.com/tjmehta/native-types/blob/8e100d2b77f530d62817864235577ff9a8cd5db5/index.js#L112-L119
train
base-apps/base-apps-router
dist/index.js
transform
function transform(file, enc, cb, opts) { if (file.isNull()) { cb(null, file); } if (file.isStream()) { cb(new PluginError('base-apps-router', 'Streams not supported.')); } if (file.isBuffer()) { var frontMatter = fm(file.contents.toString()); if (frontMat...
javascript
function transform(file, enc, cb, opts) { if (file.isNull()) { cb(null, file); } if (file.isStream()) { cb(new PluginError('base-apps-router', 'Streams not supported.')); } if (file.isBuffer()) { var frontMatter = fm(file.contents.toString()); if (frontMat...
[ "function", "transform", "(", "file", ",", "enc", ",", "cb", ",", "opts", ")", "{", "if", "(", "file", ".", "isNull", "(", ")", ")", "{", "cb", "(", "null", ",", "file", ")", ";", "}", "if", "(", "file", ".", "isStream", "(", ")", ")", "{", ...
Pulls the Front Matter from an HTML file, adds it to the route list, and returns a modified file without the Front Matter. @prop {File} file - Vinyl file. @prop {String} enc - File encoding. @prop {Function} cb - Callback to return modified file or errors. @prop {PluginOptions} opts - Plugin options.
[ "Pulls", "the", "Front", "Matter", "from", "an", "HTML", "file", "adds", "it", "to", "the", "route", "list", "and", "returns", "a", "modified", "file", "without", "the", "Front", "Matter", "." ]
bf5e99987003635fbac0144c0be35d5a863065d9
https://github.com/base-apps/base-apps-router/blob/bf5e99987003635fbac0144c0be35d5a863065d9/dist/index.js#L43-L61
train
goliatone/core.io-data-manager
lib/manager.js
_getIdentityFields
function _getIdentityFields(Model, record, identityFields = []) { /* * Definition holds the schema * inforamtion of your model. */ let schema = Model.definition; let definition; /* * Collect all unique keys in schema. * We can check record and see if we have * any present...
javascript
function _getIdentityFields(Model, record, identityFields = []) { /* * Definition holds the schema * inforamtion of your model. */ let schema = Model.definition; let definition; /* * Collect all unique keys in schema. * We can check record and see if we have * any present...
[ "function", "_getIdentityFields", "(", "Model", ",", "record", ",", "identityFields", "=", "[", "]", ")", "{", "/*\n * Definition holds the schema\n * inforamtion of your model.\n */", "let", "schema", "=", "Model", ".", "definition", ";", "let", "definition",...
Get the fields from a model attributes that we will use to make our query's criteria. @param {Object} Model Waterline collection @param {Object} record Instance attributes @param {Array} [identityFields=[]] Default fields @return {Array} Complete l...
[ "Get", "the", "fields", "from", "a", "model", "attributes", "that", "we", "will", "use", "to", "make", "our", "query", "s", "criteria", "." ]
fec79704249884290f14a2b8690f7e30288f8d55
https://github.com/goliatone/core.io-data-manager/blob/fec79704249884290f14a2b8690f7e30288f8d55/lib/manager.js#L364-L390
train
jloveric/Helper
Base.js
function () { let usingNode = false; if (typeof process === 'object') { if (typeof process.versions === 'object') { if (typeof process.versions.node !== 'undefined') { usingNode = true; } } } return usingNode; ...
javascript
function () { let usingNode = false; if (typeof process === 'object') { if (typeof process.versions === 'object') { if (typeof process.versions.node !== 'undefined') { usingNode = true; } } } return usingNode; ...
[ "function", "(", ")", "{", "let", "usingNode", "=", "false", ";", "if", "(", "typeof", "process", "===", "'object'", ")", "{", "if", "(", "typeof", "process", ".", "versions", "===", "'object'", ")", "{", "if", "(", "typeof", "process", ".", "versions"...
Find out if you are using node or the browser. This approach should work for both nwjs and node and the browser.
[ "Find", "out", "if", "you", "are", "using", "node", "or", "the", "browser", ".", "This", "approach", "should", "work", "for", "both", "nwjs", "and", "node", "and", "the", "browser", "." ]
96afcfa87eb58fffe3078cf573347c3e97dbc57f
https://github.com/jloveric/Helper/blob/96afcfa87eb58fffe3078cf573347c3e97dbc57f/Base.js#L12-L23
train
nearform/docker-container
lib/docker.js
function() { var split; var opts = {}; if (process.env.DOCKER_HOST) { split = /tcp:\/\/([0-9.]+):([0-9]+)/g.exec(process.env.DOCKER_HOST); if (process.env.DOCKER_TLS_VERIFY === '1') { opts.protocol = 'https'; } else { opts.protocol = 'http'; } opts.host = split[1]; if (...
javascript
function() { var split; var opts = {}; if (process.env.DOCKER_HOST) { split = /tcp:\/\/([0-9.]+):([0-9]+)/g.exec(process.env.DOCKER_HOST); if (process.env.DOCKER_TLS_VERIFY === '1') { opts.protocol = 'https'; } else { opts.protocol = 'http'; } opts.host = split[1]; if (...
[ "function", "(", ")", "{", "var", "split", ";", "var", "opts", "=", "{", "}", ";", "if", "(", "process", ".", "env", ".", "DOCKER_HOST", ")", "{", "split", "=", "/", "tcp:\\/\\/([0-9.]+):([0-9]+)", "/", "g", ".", "exec", "(", "process", ".", "env", ...
instantiates dockerode in one of two forms new Docker({socketPath: '/var/run/docker.sock'}); - for linux hosts new Docker({host: 'http://192.168.1.10', port: 3000}); - for mac hosts
[ "instantiates", "dockerode", "in", "one", "of", "two", "forms" ]
724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17
https://github.com/nearform/docker-container/blob/724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17/lib/docker.js#L30-L59
train
chrisns/sails-linking-controllers
lib/index.js
matchPaths
function matchPaths(pageLinks, path) { let result; path = _.compact(path.split('/')); result = _.filter(_.keys(pageLinks), key => { const path2 = _.compact(key.split('/')); const noMatch = _.filter(path2, fragment => { return fragment.substring(0, 1) !== ':' && _.indexOf(path, fragment) !== _.indexO...
javascript
function matchPaths(pageLinks, path) { let result; path = _.compact(path.split('/')); result = _.filter(_.keys(pageLinks), key => { const path2 = _.compact(key.split('/')); const noMatch = _.filter(path2, fragment => { return fragment.substring(0, 1) !== ':' && _.indexOf(path, fragment) !== _.indexO...
[ "function", "matchPaths", "(", "pageLinks", ",", "path", ")", "{", "let", "result", ";", "path", "=", "_", ".", "compact", "(", "path", ".", "split", "(", "'/'", ")", ")", ";", "result", "=", "_", ".", "filter", "(", "_", ".", "keys", "(", "pageL...
Match paths, skipping arguments. @param path1 @param path2 @returns {boolean}
[ "Match", "paths", "skipping", "arguments", "." ]
ed4ed5c2baa9b6ea64cf8bcd9f96020149fb2ec5
https://github.com/chrisns/sails-linking-controllers/blob/ed4ed5c2baa9b6ea64cf8bcd9f96020149fb2ec5/lib/index.js#L36-L47
train
chrisns/sails-linking-controllers
lib/index.js
controllerLinks
function controllerLinks(route, controllerAction, reverseRouteService) { const controllers = sails.controllers; const controller = _.first(controllerAction.split('.')); const path = route.path; const actions = _.get(controllers[controller], '_config.links') || []; let result = {}; result[path] = []; _.eac...
javascript
function controllerLinks(route, controllerAction, reverseRouteService) { const controllers = sails.controllers; const controller = _.first(controllerAction.split('.')); const path = route.path; const actions = _.get(controllers[controller], '_config.links') || []; let result = {}; result[path] = []; _.eac...
[ "function", "controllerLinks", "(", "route", ",", "controllerAction", ",", "reverseRouteService", ")", "{", "const", "controllers", "=", "sails", ".", "controllers", ";", "const", "controller", "=", "_", ".", "first", "(", "controllerAction", ".", "split", "(", ...
Create an array of pagelinks. @param controllers @param reverseRoute @param controllerAction @returns {Promise.<Function>}
[ "Create", "an", "array", "of", "pagelinks", "." ]
ed4ed5c2baa9b6ea64cf8bcd9f96020149fb2ec5
https://github.com/chrisns/sails-linking-controllers/blob/ed4ed5c2baa9b6ea64cf8bcd9f96020149fb2ec5/lib/index.js#L56-L70
train
nearit/Cordova-SDK
hooks/lib.js
function (rootdir, configData, platform) { var configFiles = lib.getConfigFilesByTargetAndParent(rootdir, platform), type = 'configFile'; for (var key in configFiles) { if (configFiles.hasOwnProperty(key)) { var configFile = configFiles[key]; var...
javascript
function (rootdir, configData, platform) { var configFiles = lib.getConfigFilesByTargetAndParent(rootdir, platform), type = 'configFile'; for (var key in configFiles) { if (configFiles.hasOwnProperty(key)) { var configFile = configFiles[key]; var...
[ "function", "(", "rootdir", ",", "configData", ",", "platform", ")", "{", "var", "configFiles", "=", "lib", ".", "getConfigFilesByTargetAndParent", "(", "rootdir", ",", "platform", ")", ",", "type", "=", "'configFile'", ";", "for", "(", "var", "key", "in", ...
Retrieves the config.xml's config-file elements for a given platform and parses them into JSON data @param configData @param platform
[ "Retrieves", "the", "config", ".", "xml", "s", "config", "-", "file", "elements", "for", "a", "given", "platform", "and", "parses", "them", "into", "JSON", "data" ]
f232d7db0afed1c8474eaec6f1d45a5ca6d6b3bd
https://github.com/nearit/Cordova-SDK/blob/f232d7db0afed1c8474eaec6f1d45a5ca6d6b3bd/hooks/lib.js#L160-L185
train
FriendCode/qplus
index.js
retry
function retry(fn, N, retryTimeout, canContinue) { if(typeof N === "function" && retryTimeout === canContinue === undefined) { canContinue = N; N = retryTimeout = undefined; } else if(typeof retryTimeout === "function") { canContinue = retryTimeout; retryTimeout = undefined; ...
javascript
function retry(fn, N, retryTimeout, canContinue) { if(typeof N === "function" && retryTimeout === canContinue === undefined) { canContinue = N; N = retryTimeout = undefined; } else if(typeof retryTimeout === "function") { canContinue = retryTimeout; retryTimeout = undefined; ...
[ "function", "retry", "(", "fn", ",", "N", ",", "retryTimeout", ",", "canContinue", ")", "{", "if", "(", "typeof", "N", "===", "\"function\"", "&&", "retryTimeout", "===", "canContinue", "===", "undefined", ")", "{", "canContinue", "=", "N", ";", "N", "="...
Retry a function a maximum of N times the function must use promises and will always be executed once
[ "Retry", "a", "function", "a", "maximum", "of", "N", "times", "the", "function", "must", "use", "promises", "and", "will", "always", "be", "executed", "once" ]
8325d89c43cbec7df9caf91a7de571e8355d459e
https://github.com/FriendCode/qplus/blob/8325d89c43cbec7df9caf91a7de571e8355d459e/index.js#L6-L74
train
FriendCode/qplus
index.js
_try
function _try() { // Call function Q.invoke(f) .then(function(result) { // Success d.resolve(result); }, function(err) { // Failure // Decrement remainingTries -= 1; // No t...
javascript
function _try() { // Call function Q.invoke(f) .then(function(result) { // Success d.resolve(result); }, function(err) { // Failure // Decrement remainingTries -= 1; // No t...
[ "function", "_try", "(", ")", "{", "// Call function", "Q", ".", "invoke", "(", "f", ")", ".", "then", "(", "function", "(", "result", ")", "{", "// Success", "d", ".", "resolve", "(", "result", ")", ";", "}", ",", "function", "(", "err", ")", "{",...
The function with the try logic
[ "The", "function", "with", "the", "try", "logic" ]
8325d89c43cbec7df9caf91a7de571e8355d459e
https://github.com/FriendCode/qplus/blob/8325d89c43cbec7df9caf91a7de571e8355d459e/index.js#L39-L66
train
francium/highlight-page
dist/highlight-page.js
defaults
function defaults(obj, source) { obj = obj || {}; for (var prop in source) { if (source.hasOwnProperty(prop) && obj[prop] === void 0) { obj[prop] = source[prop]; } } return obj; }
javascript
function defaults(obj, source) { obj = obj || {}; for (var prop in source) { if (source.hasOwnProperty(prop) && obj[prop] === void 0) { obj[prop] = source[prop]; } } return obj; }
[ "function", "defaults", "(", "obj", ",", "source", ")", "{", "obj", "=", "obj", "||", "{", "}", ";", "for", "(", "var", "prop", "in", "source", ")", "{", "if", "(", "source", ".", "hasOwnProperty", "(", "prop", ")", "&&", "obj", "[", "prop", "]",...
Fills undefined values in obj with default properties with the same name from source object. @param {object} obj - target object @param {object} source - source object with default values @returns {object}
[ "Fills", "undefined", "values", "in", "obj", "with", "default", "properties", "with", "the", "same", "name", "from", "source", "object", "." ]
4e67fc531321f9987397dc247abba59b9d5ee521
https://github.com/francium/highlight-page/blob/4e67fc531321f9987397dc247abba59b9d5ee521/dist/highlight-page.js#L48-L58
train
francium/highlight-page
dist/highlight-page.js
unique
function unique(arr) { return arr.filter(function (value, idx, self) { return self.indexOf(value) === idx; }); }
javascript
function unique(arr) { return arr.filter(function (value, idx, self) { return self.indexOf(value) === idx; }); }
[ "function", "unique", "(", "arr", ")", "{", "return", "arr", ".", "filter", "(", "function", "(", "value", ",", "idx", ",", "self", ")", "{", "return", "self", ".", "indexOf", "(", "value", ")", "===", "idx", ";", "}", ")", ";", "}" ]
Returns array without duplicated values. @param {Array} arr @returns {Array}
[ "Returns", "array", "without", "duplicated", "values", "." ]
4e67fc531321f9987397dc247abba59b9d5ee521
https://github.com/francium/highlight-page/blob/4e67fc531321f9987397dc247abba59b9d5ee521/dist/highlight-page.js#L65-L69
train
francium/highlight-page
dist/highlight-page.js
sortByDepth
function sortByDepth(arr, descending) { arr.sort(function (a, b) { return dom(descending ? b : a).parents().length - dom(descending ? a : b).parents().length; }); }
javascript
function sortByDepth(arr, descending) { arr.sort(function (a, b) { return dom(descending ? b : a).parents().length - dom(descending ? a : b).parents().length; }); }
[ "function", "sortByDepth", "(", "arr", ",", "descending", ")", "{", "arr", ".", "sort", "(", "function", "(", "a", ",", "b", ")", "{", "return", "dom", "(", "descending", "?", "b", ":", "a", ")", ".", "parents", "(", ")", ".", "length", "-", "dom...
Sorts array of DOM elements by its depth in DOM tree. @param {HTMLElement[]} arr - array to sort. @param {boolean} descending - order of sort.
[ "Sorts", "array", "of", "DOM", "elements", "by", "its", "depth", "in", "DOM", "tree", "." ]
4e67fc531321f9987397dc247abba59b9d5ee521
https://github.com/francium/highlight-page/blob/4e67fc531321f9987397dc247abba59b9d5ee521/dist/highlight-page.js#L122-L126
train
francium/highlight-page
dist/highlight-page.js
removeClass
function removeClass(className) { if (el.classList) { el.classList.remove(className); } else { el.className = el.className.replace(new RegExp('(^|\\b)' + className + '(\\b|$)', 'gi'), ' '); } }
javascript
function removeClass(className) { if (el.classList) { el.classList.remove(className); } else { el.className = el.className.replace(new RegExp('(^|\\b)' + className + '(\\b|$)', 'gi'), ' '); } }
[ "function", "removeClass", "(", "className", ")", "{", "if", "(", "el", ".", "classList", ")", "{", "el", ".", "classList", ".", "remove", "(", "className", ")", ";", "}", "else", "{", "el", ".", "className", "=", "el", ".", "className", ".", "replac...
Removes class from element. @param {string} className
[ "Removes", "class", "from", "element", "." ]
4e67fc531321f9987397dc247abba59b9d5ee521
https://github.com/francium/highlight-page/blob/4e67fc531321f9987397dc247abba59b9d5ee521/dist/highlight-page.js#L191-L197
train
francium/highlight-page
dist/highlight-page.js
prepend
function prepend(nodesToPrepend) { var nodes = Array.prototype.slice.call(nodesToPrepend), i = nodes.length; while (i--) { el.insertBefore(nodes[i], el.firstChild); } }
javascript
function prepend(nodesToPrepend) { var nodes = Array.prototype.slice.call(nodesToPrepend), i = nodes.length; while (i--) { el.insertBefore(nodes[i], el.firstChild); } }
[ "function", "prepend", "(", "nodesToPrepend", ")", "{", "var", "nodes", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "nodesToPrepend", ")", ",", "i", "=", "nodes", ".", "length", ";", "while", "(", "i", "--", ")", "{", "el", ".", ...
Prepends child nodes to base element. @param {Node[]} nodesToPrepend
[ "Prepends", "child", "nodes", "to", "base", "element", "." ]
4e67fc531321f9987397dc247abba59b9d5ee521
https://github.com/francium/highlight-page/blob/4e67fc531321f9987397dc247abba59b9d5ee521/dist/highlight-page.js#L203-L210
train