id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
36,100
oskosk/node-wms-client
index.js
function( queryOptions, callback ) { var _this = this; if ( typeof queryOptions === 'function' ) { callback = queryOptions; this.capabilities( function( err, capabilities ) { if ( err ) { debug( 'Error getting layers: %j', err ); return callback( err ); } if ( _this.version === '1.3.0' ) { callback( null, capabilities.capability.layer.crs ); } else { callback( null, capabilities.capability.layer.srs ); } } ); } else if ( typeof callback === 'function' ) { this.capabilities( queryOptions, function( err, capabilities ) { if ( err ) { debug( 'Error getting layers: %j', err ); return callback( err ); } if ( _this.version === '1.3.0' ) { callback( null, capabilities.capability.layer.crs ); } else { callback( null, capabilities.capability.layer.srs ); } } ); } }
javascript
function( queryOptions, callback ) { var _this = this; if ( typeof queryOptions === 'function' ) { callback = queryOptions; this.capabilities( function( err, capabilities ) { if ( err ) { debug( 'Error getting layers: %j', err ); return callback( err ); } if ( _this.version === '1.3.0' ) { callback( null, capabilities.capability.layer.crs ); } else { callback( null, capabilities.capability.layer.srs ); } } ); } else if ( typeof callback === 'function' ) { this.capabilities( queryOptions, function( err, capabilities ) { if ( err ) { debug( 'Error getting layers: %j', err ); return callback( err ); } if ( _this.version === '1.3.0' ) { callback( null, capabilities.capability.layer.crs ); } else { callback( null, capabilities.capability.layer.srs ); } } ); } }
[ "function", "(", "queryOptions", ",", "callback", ")", "{", "var", "_this", "=", "this", ";", "if", "(", "typeof", "queryOptions", "===", "'function'", ")", "{", "callback", "=", "queryOptions", ";", "this", ".", "capabilities", "(", "function", "(", "err", ",", "capabilities", ")", "{", "if", "(", "err", ")", "{", "debug", "(", "'Error getting layers: %j'", ",", "err", ")", ";", "return", "callback", "(", "err", ")", ";", "}", "if", "(", "_this", ".", "version", "===", "'1.3.0'", ")", "{", "callback", "(", "null", ",", "capabilities", ".", "capability", ".", "layer", ".", "crs", ")", ";", "}", "else", "{", "callback", "(", "null", ",", "capabilities", ".", "capability", ".", "layer", ".", "srs", ")", ";", "}", "}", ")", ";", "}", "else", "if", "(", "typeof", "callback", "===", "'function'", ")", "{", "this", ".", "capabilities", "(", "queryOptions", ",", "function", "(", "err", ",", "capabilities", ")", "{", "if", "(", "err", ")", "{", "debug", "(", "'Error getting layers: %j'", ",", "err", ")", ";", "return", "callback", "(", "err", ")", ";", "}", "if", "(", "_this", ".", "version", "===", "'1.3.0'", ")", "{", "callback", "(", "null", ",", "capabilities", ".", "capability", ".", "layer", ".", "crs", ")", ";", "}", "else", "{", "callback", "(", "null", ",", "capabilities", ".", "capability", ".", "layer", ".", "srs", ")", ";", "}", "}", ")", ";", "}", "}" ]
Gets the WMS supported Coordinate reference systems reported in the capabilities as an array @param {Object} [Optional] queryOptions. Options passed as GET parameters @param {Function} callback. - {Error} null if nothing bad happened - {Array} CRSs as an array strings
[ "Gets", "the", "WMS", "supported", "Coordinate", "reference", "systems", "reported", "in", "the", "capabilities", "as", "an", "array" ]
86aaa8ed7eedbed7fb33c72a8607387a2b130933
https://github.com/oskosk/node-wms-client/blob/86aaa8ed7eedbed7fb33c72a8607387a2b130933/index.js#L117-L145
36,101
oskosk/node-wms-client
index.js
function( queryOptions, callback ) { if ( typeof queryOptions === 'function' ) { callback = queryOptions; queryOptions = {}; } this.capabilities( queryOptions, function( err, capabilities ) { if ( err ) { debug( 'Error getting service metadata: %j', err ); return callback( err ); } callback( null, capabilities.service ); } ); }
javascript
function( queryOptions, callback ) { if ( typeof queryOptions === 'function' ) { callback = queryOptions; queryOptions = {}; } this.capabilities( queryOptions, function( err, capabilities ) { if ( err ) { debug( 'Error getting service metadata: %j', err ); return callback( err ); } callback( null, capabilities.service ); } ); }
[ "function", "(", "queryOptions", ",", "callback", ")", "{", "if", "(", "typeof", "queryOptions", "===", "'function'", ")", "{", "callback", "=", "queryOptions", ";", "queryOptions", "=", "{", "}", ";", "}", "this", ".", "capabilities", "(", "queryOptions", ",", "function", "(", "err", ",", "capabilities", ")", "{", "if", "(", "err", ")", "{", "debug", "(", "'Error getting service metadata: %j'", ",", "err", ")", ";", "return", "callback", "(", "err", ")", ";", "}", "callback", "(", "null", ",", "capabilities", ".", "service", ")", ";", "}", ")", ";", "}" ]
Gets the WMS service metadata reported in the capabilities as a plain object @param {Object} [Optional] queryOptions. Options passed as GET parameters @param {Function} callback. - {Error} null if nothing bad happened - {Array} WMS Service metadata as a Plain Object
[ "Gets", "the", "WMS", "service", "metadata", "reported", "in", "the", "capabilities", "as", "a", "plain", "object" ]
86aaa8ed7eedbed7fb33c72a8607387a2b130933
https://github.com/oskosk/node-wms-client/blob/86aaa8ed7eedbed7fb33c72a8607387a2b130933/index.js#L154-L166
36,102
oskosk/node-wms-client
index.js
function( wmsBaseUrl, queryOptions ) { queryOptions = extend( { request: 'GetCapabilities', version: this.version, service: 'WMS' }, queryOptions ); // Append user provided GET parameters in the URL to required queryOptions var urlQueryParams = new urijs( wmsBaseUrl ).search( true ); queryOptions = extend( queryOptions, urlQueryParams ); // Merge queryOptions GET parameters to the URL var url = new urijs( wmsBaseUrl ).search( queryOptions ); debug( 'Using capabilities URL: %s', url ); return url.toString(); }
javascript
function( wmsBaseUrl, queryOptions ) { queryOptions = extend( { request: 'GetCapabilities', version: this.version, service: 'WMS' }, queryOptions ); // Append user provided GET parameters in the URL to required queryOptions var urlQueryParams = new urijs( wmsBaseUrl ).search( true ); queryOptions = extend( queryOptions, urlQueryParams ); // Merge queryOptions GET parameters to the URL var url = new urijs( wmsBaseUrl ).search( queryOptions ); debug( 'Using capabilities URL: %s', url ); return url.toString(); }
[ "function", "(", "wmsBaseUrl", ",", "queryOptions", ")", "{", "queryOptions", "=", "extend", "(", "{", "request", ":", "'GetCapabilities'", ",", "version", ":", "this", ".", "version", ",", "service", ":", "'WMS'", "}", ",", "queryOptions", ")", ";", "// Append user provided GET parameters in the URL to required queryOptions", "var", "urlQueryParams", "=", "new", "urijs", "(", "wmsBaseUrl", ")", ".", "search", "(", "true", ")", ";", "queryOptions", "=", "extend", "(", "queryOptions", ",", "urlQueryParams", ")", ";", "// Merge queryOptions GET parameters to the URL", "var", "url", "=", "new", "urijs", "(", "wmsBaseUrl", ")", ".", "search", "(", "queryOptions", ")", ";", "debug", "(", "'Using capabilities URL: %s'", ",", "url", ")", ";", "return", "url", ".", "toString", "(", ")", ";", "}" ]
Formats an URL to include specific GET parameters required for a GETCAPABILITIES WMS method request
[ "Formats", "an", "URL", "to", "include", "specific", "GET", "parameters", "required", "for", "a", "GETCAPABILITIES", "WMS", "method", "request" ]
86aaa8ed7eedbed7fb33c72a8607387a2b130933
https://github.com/oskosk/node-wms-client/blob/86aaa8ed7eedbed7fb33c72a8607387a2b130933/index.js#L318-L331
36,103
oskosk/node-wms-client
index.js
function( minx, miny, maxx, maxy ) { var bbox = ''; if ( this.version === '1.3.0' ) { bbox = [minx, miny, maxx, maxy].join( ',' ); } else { bbox = [miny, minx, maxy, maxx].join( ',' ); } return bbox; }
javascript
function( minx, miny, maxx, maxy ) { var bbox = ''; if ( this.version === '1.3.0' ) { bbox = [minx, miny, maxx, maxy].join( ',' ); } else { bbox = [miny, minx, maxy, maxx].join( ',' ); } return bbox; }
[ "function", "(", "minx", ",", "miny", ",", "maxx", ",", "maxy", ")", "{", "var", "bbox", "=", "''", ";", "if", "(", "this", ".", "version", "===", "'1.3.0'", ")", "{", "bbox", "=", "[", "minx", ",", "miny", ",", "maxx", ",", "maxy", "]", ".", "join", "(", "','", ")", ";", "}", "else", "{", "bbox", "=", "[", "miny", ",", "minx", ",", "maxy", ",", "maxx", "]", ".", "join", "(", "','", ")", ";", "}", "return", "bbox", ";", "}" ]
Returns a bbox WMS string. @param {Float} minx left bound of the bounding box in CRS units @param {Float} miny lower bound of the bounding box in CRUS units @param {Float} maxx right bound of the bounding box in CRUS units @param {Float} maxy upper bound of the bounding box in CRUS units
[ "Returns", "a", "bbox", "WMS", "string", "." ]
86aaa8ed7eedbed7fb33c72a8607387a2b130933
https://github.com/oskosk/node-wms-client/blob/86aaa8ed7eedbed7fb33c72a8607387a2b130933/index.js#L371-L379
36,104
rricard/koa-swagger
lib/checkers.js
checkParameter
function checkParameter(validator, def, context) { var value = match.fromContext(def.name, def.in, context); // Check requirement if(def.required && !value) { throw new ValidationError(def.name + " is required"); } else if(!value) { return def.default; } // Select the right schema according to the spec var schema; if(def.in === "body") { schema = def.schema; // TODO: clean and sanitize recursively } else { // TODO: coerce other types if(def.type === "integer") { value = parseInt(value); } else if(def.type === "number") { value = parseFloat(value); } else if(def.type === "file") { def.type = "object"; } if (def.in === "query" && def.type === "array") { if(!def.collectionFormat || def.collectionFormat === "csv") { value = value.split(","); } else if (def.collectionFormat === "tsv") { value = value.split("\t"); } else if (def.collectionFormat === "ssv") { value = value.split(" "); } else if (def.collectionFormat === "psv") { value = value.split("|"); } else if (def.collectionFormat === "multi") { throw new ValidationError("multi collectionFormat query parameters currently unsupported"); } else { throw new ValidationError("unknown collectionFormat " + def.collectionFormat); } } schema = def; } var err = validator(value, schema); if(err.length > 0) { throw new ValidationError(def.name + " has an invalid format: " + JSON.stringify(err)); } return value; }
javascript
function checkParameter(validator, def, context) { var value = match.fromContext(def.name, def.in, context); // Check requirement if(def.required && !value) { throw new ValidationError(def.name + " is required"); } else if(!value) { return def.default; } // Select the right schema according to the spec var schema; if(def.in === "body") { schema = def.schema; // TODO: clean and sanitize recursively } else { // TODO: coerce other types if(def.type === "integer") { value = parseInt(value); } else if(def.type === "number") { value = parseFloat(value); } else if(def.type === "file") { def.type = "object"; } if (def.in === "query" && def.type === "array") { if(!def.collectionFormat || def.collectionFormat === "csv") { value = value.split(","); } else if (def.collectionFormat === "tsv") { value = value.split("\t"); } else if (def.collectionFormat === "ssv") { value = value.split(" "); } else if (def.collectionFormat === "psv") { value = value.split("|"); } else if (def.collectionFormat === "multi") { throw new ValidationError("multi collectionFormat query parameters currently unsupported"); } else { throw new ValidationError("unknown collectionFormat " + def.collectionFormat); } } schema = def; } var err = validator(value, schema); if(err.length > 0) { throw new ValidationError(def.name + " has an invalid format: " + JSON.stringify(err)); } return value; }
[ "function", "checkParameter", "(", "validator", ",", "def", ",", "context", ")", "{", "var", "value", "=", "match", ".", "fromContext", "(", "def", ".", "name", ",", "def", ".", "in", ",", "context", ")", ";", "// Check requirement", "if", "(", "def", ".", "required", "&&", "!", "value", ")", "{", "throw", "new", "ValidationError", "(", "def", ".", "name", "+", "\" is required\"", ")", ";", "}", "else", "if", "(", "!", "value", ")", "{", "return", "def", ".", "default", ";", "}", "// Select the right schema according to the spec", "var", "schema", ";", "if", "(", "def", ".", "in", "===", "\"body\"", ")", "{", "schema", "=", "def", ".", "schema", ";", "// TODO: clean and sanitize recursively", "}", "else", "{", "// TODO: coerce other types", "if", "(", "def", ".", "type", "===", "\"integer\"", ")", "{", "value", "=", "parseInt", "(", "value", ")", ";", "}", "else", "if", "(", "def", ".", "type", "===", "\"number\"", ")", "{", "value", "=", "parseFloat", "(", "value", ")", ";", "}", "else", "if", "(", "def", ".", "type", "===", "\"file\"", ")", "{", "def", ".", "type", "=", "\"object\"", ";", "}", "if", "(", "def", ".", "in", "===", "\"query\"", "&&", "def", ".", "type", "===", "\"array\"", ")", "{", "if", "(", "!", "def", ".", "collectionFormat", "||", "def", ".", "collectionFormat", "===", "\"csv\"", ")", "{", "value", "=", "value", ".", "split", "(", "\",\"", ")", ";", "}", "else", "if", "(", "def", ".", "collectionFormat", "===", "\"tsv\"", ")", "{", "value", "=", "value", ".", "split", "(", "\"\\t\"", ")", ";", "}", "else", "if", "(", "def", ".", "collectionFormat", "===", "\"ssv\"", ")", "{", "value", "=", "value", ".", "split", "(", "\" \"", ")", ";", "}", "else", "if", "(", "def", ".", "collectionFormat", "===", "\"psv\"", ")", "{", "value", "=", "value", ".", "split", "(", "\"|\"", ")", ";", "}", "else", "if", "(", "def", ".", "collectionFormat", "===", "\"multi\"", ")", "{", "throw", "new", "ValidationError", "(", "\"multi collectionFormat query parameters currently unsupported\"", ")", ";", "}", "else", "{", "throw", "new", "ValidationError", "(", "\"unknown collectionFormat \"", "+", "def", ".", "collectionFormat", ")", ";", "}", "}", "schema", "=", "def", ";", "}", "var", "err", "=", "validator", "(", "value", ",", "schema", ")", ";", "if", "(", "err", ".", "length", ">", "0", ")", "{", "throw", "new", "ValidationError", "(", "def", ".", "name", "+", "\" has an invalid format: \"", "+", "JSON", ".", "stringify", "(", "err", ")", ")", ";", "}", "return", "value", ";", "}" ]
Check if the context carries the parameter correctly @param validator {function(object, Schema)} JSON-Schema validator function @param def {Parameter} The parameter's definition @param context {Context} A koa context @return {*} The cleaned value @throws {ValidationError} A possible validation error
[ "Check", "if", "the", "context", "carries", "the", "parameter", "correctly" ]
1c2d6cef6fa594a4b5a7697192b28df512c0ed73
https://github.com/rricard/koa-swagger/blob/1c2d6cef6fa594a4b5a7697192b28df512c0ed73/lib/checkers.js#L41-L91
36,105
cb1kenobi/cli-kit
src/lib/errors.js
createError
function createError(code, type, desc) { errors[code] = function (msg, meta) { const err = new type(msg); if (desc) { if (!meta) { meta = {}; } meta.desc = desc; } return Object.defineProperties(err, { code: { configurable: true, enumerable: true, writable: true, value: `ERR_${code}` }, meta: { configurable: true, value: meta || undefined, writable: true } }); }; Object.defineProperties(errors[code], { name: { configurable: true, value: code, writable: true }, toString: { configurable: true, value: function toString() { return `ERR_${code}`; }, writable: true } }); }
javascript
function createError(code, type, desc) { errors[code] = function (msg, meta) { const err = new type(msg); if (desc) { if (!meta) { meta = {}; } meta.desc = desc; } return Object.defineProperties(err, { code: { configurable: true, enumerable: true, writable: true, value: `ERR_${code}` }, meta: { configurable: true, value: meta || undefined, writable: true } }); }; Object.defineProperties(errors[code], { name: { configurable: true, value: code, writable: true }, toString: { configurable: true, value: function toString() { return `ERR_${code}`; }, writable: true } }); }
[ "function", "createError", "(", "code", ",", "type", ",", "desc", ")", "{", "errors", "[", "code", "]", "=", "function", "(", "msg", ",", "meta", ")", "{", "const", "err", "=", "new", "type", "(", "msg", ")", ";", "if", "(", "desc", ")", "{", "if", "(", "!", "meta", ")", "{", "meta", "=", "{", "}", ";", "}", "meta", ".", "desc", "=", "desc", ";", "}", "return", "Object", ".", "defineProperties", "(", "err", ",", "{", "code", ":", "{", "configurable", ":", "true", ",", "enumerable", ":", "true", ",", "writable", ":", "true", ",", "value", ":", "`", "${", "code", "}", "`", "}", ",", "meta", ":", "{", "configurable", ":", "true", ",", "value", ":", "meta", "||", "undefined", ",", "writable", ":", "true", "}", "}", ")", ";", "}", ";", "Object", ".", "defineProperties", "(", "errors", "[", "code", "]", ",", "{", "name", ":", "{", "configurable", ":", "true", ",", "value", ":", "code", ",", "writable", ":", "true", "}", ",", "toString", ":", "{", "configurable", ":", "true", ",", "value", ":", "function", "toString", "(", ")", "{", "return", "`", "${", "code", "}", "`", ";", "}", ",", "writable", ":", "true", "}", "}", ")", ";", "}" ]
Creates an the error object and populates the message, code, and metadata. @param {String} code - The error code. @param {Error|RangeError|TypeError} type - An instantiable error object. @param {String} desc - A generic error description.
[ "Creates", "an", "the", "error", "object", "and", "populates", "the", "message", "code", "and", "metadata", "." ]
6d0d5ebb17cfbd11a8ec25ce8e4251f72cdc7734
https://github.com/cb1kenobi/cli-kit/blob/6d0d5ebb17cfbd11a8ec25ce8e4251f72cdc7734/src/lib/errors.js#L39-L79
36,106
cb1kenobi/cli-kit
site/semantic/tasks/config/project/config.js
function(config) { config = config || extend(false, {}, defaults); /*-------------- File Paths ---------------*/ var configPath = this.getPath(), sourcePaths = {}, outputPaths = {}, folder ; // resolve paths (config location + base + path) for(folder in config.paths.source) { if(config.paths.source.hasOwnProperty(folder)) { sourcePaths[folder] = path.resolve(path.join(configPath, config.base, config.paths.source[folder])); } } for(folder in config.paths.output) { if(config.paths.output.hasOwnProperty(folder)) { outputPaths[folder] = path.resolve(path.join(configPath, config.base, config.paths.output[folder])); } } // set config paths to full paths config.paths.source = sourcePaths; config.paths.output = outputPaths; // resolve "clean" command path config.paths.clean = path.resolve( path.join(configPath, config.base, config.paths.clean) ); /*-------------- CSS URLs ---------------*/ // determine asset paths in css by finding relative path between themes and output // force forward slashes config.paths.assets = { source : '../../themes', // source asset path is always the same uncompressed : './' + path.relative(config.paths.output.uncompressed, config.paths.output.themes).replace(/\\/g, '/'), compressed : './' + path.relative(config.paths.output.compressed, config.paths.output.themes).replace(/\\/g, '/'), packaged : './' + path.relative(config.paths.output.packaged, config.paths.output.themes).replace(/\\/g, '/') }; /*-------------- Permission ---------------*/ if(config.permission) { config.hasPermissions = true; } else { // pass blank object to avoid causing errors config.permission = {}; config.hasPermissions = false; } /*-------------- Globs ---------------*/ if(!config.globs) { config.globs = {}; } // remove duplicates from component array if(config.components instanceof Array) { config.components = config.components.filter(function(component, index) { return config.components.indexOf(component) == index; }); } // takes component object and creates file glob matching selected components config.globs.components = (typeof config.components == 'object') ? (config.components.length > 1) ? '{' + config.components.join(',') + '}' : config.components[0] : '{' + defaults.components.join(',') + '}' ; return config; }
javascript
function(config) { config = config || extend(false, {}, defaults); /*-------------- File Paths ---------------*/ var configPath = this.getPath(), sourcePaths = {}, outputPaths = {}, folder ; // resolve paths (config location + base + path) for(folder in config.paths.source) { if(config.paths.source.hasOwnProperty(folder)) { sourcePaths[folder] = path.resolve(path.join(configPath, config.base, config.paths.source[folder])); } } for(folder in config.paths.output) { if(config.paths.output.hasOwnProperty(folder)) { outputPaths[folder] = path.resolve(path.join(configPath, config.base, config.paths.output[folder])); } } // set config paths to full paths config.paths.source = sourcePaths; config.paths.output = outputPaths; // resolve "clean" command path config.paths.clean = path.resolve( path.join(configPath, config.base, config.paths.clean) ); /*-------------- CSS URLs ---------------*/ // determine asset paths in css by finding relative path between themes and output // force forward slashes config.paths.assets = { source : '../../themes', // source asset path is always the same uncompressed : './' + path.relative(config.paths.output.uncompressed, config.paths.output.themes).replace(/\\/g, '/'), compressed : './' + path.relative(config.paths.output.compressed, config.paths.output.themes).replace(/\\/g, '/'), packaged : './' + path.relative(config.paths.output.packaged, config.paths.output.themes).replace(/\\/g, '/') }; /*-------------- Permission ---------------*/ if(config.permission) { config.hasPermissions = true; } else { // pass blank object to avoid causing errors config.permission = {}; config.hasPermissions = false; } /*-------------- Globs ---------------*/ if(!config.globs) { config.globs = {}; } // remove duplicates from component array if(config.components instanceof Array) { config.components = config.components.filter(function(component, index) { return config.components.indexOf(component) == index; }); } // takes component object and creates file glob matching selected components config.globs.components = (typeof config.components == 'object') ? (config.components.length > 1) ? '{' + config.components.join(',') + '}' : config.components[0] : '{' + defaults.components.join(',') + '}' ; return config; }
[ "function", "(", "config", ")", "{", "config", "=", "config", "||", "extend", "(", "false", ",", "{", "}", ",", "defaults", ")", ";", "/*--------------\n File Paths\n ---------------*/", "var", "configPath", "=", "this", ".", "getPath", "(", ")", ",", "sourcePaths", "=", "{", "}", ",", "outputPaths", "=", "{", "}", ",", "folder", ";", "// resolve paths (config location + base + path)", "for", "(", "folder", "in", "config", ".", "paths", ".", "source", ")", "{", "if", "(", "config", ".", "paths", ".", "source", ".", "hasOwnProperty", "(", "folder", ")", ")", "{", "sourcePaths", "[", "folder", "]", "=", "path", ".", "resolve", "(", "path", ".", "join", "(", "configPath", ",", "config", ".", "base", ",", "config", ".", "paths", ".", "source", "[", "folder", "]", ")", ")", ";", "}", "}", "for", "(", "folder", "in", "config", ".", "paths", ".", "output", ")", "{", "if", "(", "config", ".", "paths", ".", "output", ".", "hasOwnProperty", "(", "folder", ")", ")", "{", "outputPaths", "[", "folder", "]", "=", "path", ".", "resolve", "(", "path", ".", "join", "(", "configPath", ",", "config", ".", "base", ",", "config", ".", "paths", ".", "output", "[", "folder", "]", ")", ")", ";", "}", "}", "// set config paths to full paths", "config", ".", "paths", ".", "source", "=", "sourcePaths", ";", "config", ".", "paths", ".", "output", "=", "outputPaths", ";", "// resolve \"clean\" command path", "config", ".", "paths", ".", "clean", "=", "path", ".", "resolve", "(", "path", ".", "join", "(", "configPath", ",", "config", ".", "base", ",", "config", ".", "paths", ".", "clean", ")", ")", ";", "/*--------------\n CSS URLs\n ---------------*/", "// determine asset paths in css by finding relative path between themes and output", "// force forward slashes", "config", ".", "paths", ".", "assets", "=", "{", "source", ":", "'../../themes'", ",", "// source asset path is always the same", "uncompressed", ":", "'./'", "+", "path", ".", "relative", "(", "config", ".", "paths", ".", "output", ".", "uncompressed", ",", "config", ".", "paths", ".", "output", ".", "themes", ")", ".", "replace", "(", "/", "\\\\", "/", "g", ",", "'/'", ")", ",", "compressed", ":", "'./'", "+", "path", ".", "relative", "(", "config", ".", "paths", ".", "output", ".", "compressed", ",", "config", ".", "paths", ".", "output", ".", "themes", ")", ".", "replace", "(", "/", "\\\\", "/", "g", ",", "'/'", ")", ",", "packaged", ":", "'./'", "+", "path", ".", "relative", "(", "config", ".", "paths", ".", "output", ".", "packaged", ",", "config", ".", "paths", ".", "output", ".", "themes", ")", ".", "replace", "(", "/", "\\\\", "/", "g", ",", "'/'", ")", "}", ";", "/*--------------\n Permission\n ---------------*/", "if", "(", "config", ".", "permission", ")", "{", "config", ".", "hasPermissions", "=", "true", ";", "}", "else", "{", "// pass blank object to avoid causing errors", "config", ".", "permission", "=", "{", "}", ";", "config", ".", "hasPermissions", "=", "false", ";", "}", "/*--------------\n Globs\n ---------------*/", "if", "(", "!", "config", ".", "globs", ")", "{", "config", ".", "globs", "=", "{", "}", ";", "}", "// remove duplicates from component array", "if", "(", "config", ".", "components", "instanceof", "Array", ")", "{", "config", ".", "components", "=", "config", ".", "components", ".", "filter", "(", "function", "(", "component", ",", "index", ")", "{", "return", "config", ".", "components", ".", "indexOf", "(", "component", ")", "==", "index", ";", "}", ")", ";", "}", "// takes component object and creates file glob matching selected components", "config", ".", "globs", ".", "components", "=", "(", "typeof", "config", ".", "components", "==", "'object'", ")", "?", "(", "config", ".", "components", ".", "length", ">", "1", ")", "?", "'{'", "+", "config", ".", "components", ".", "join", "(", "','", ")", "+", "'}'", ":", "config", ".", "components", "[", "0", "]", ":", "'{'", "+", "defaults", ".", "components", ".", "join", "(", "','", ")", "+", "'}'", ";", "return", "config", ";", "}" ]
adds additional derived values to a config object
[ "adds", "additional", "derived", "values", "to", "a", "config", "object" ]
6d0d5ebb17cfbd11a8ec25ce8e4251f72cdc7734
https://github.com/cb1kenobi/cli-kit/blob/6d0d5ebb17cfbd11a8ec25ce8e4251f72cdc7734/site/semantic/tasks/config/project/config.js#L52-L138
36,107
jtrussell/svn-npm-crutch
lib/svn-npm-crutch.js
function(exists, cb) { if(!exists) { fs.mkdir(rootDir + '/node_modules', function(error) { cb(error); }); } else { cb(null); } }
javascript
function(exists, cb) { if(!exists) { fs.mkdir(rootDir + '/node_modules', function(error) { cb(error); }); } else { cb(null); } }
[ "function", "(", "exists", ",", "cb", ")", "{", "if", "(", "!", "exists", ")", "{", "fs", ".", "mkdir", "(", "rootDir", "+", "'/node_modules'", ",", "function", "(", "error", ")", "{", "cb", "(", "error", ")", ";", "}", ")", ";", "}", "else", "{", "cb", "(", "null", ")", ";", "}", "}" ]
Make the node_modules folder if we need to
[ "Make", "the", "node_modules", "folder", "if", "we", "need", "to" ]
162df18cbb1c20a75bd3d30e73beb4839f10154a
https://github.com/jtrussell/svn-npm-crutch/blob/162df18cbb1c20a75bd3d30e73beb4839f10154a/lib/svn-npm-crutch.js#L40-L48
36,108
keymetrics/trassingue
src/span-data.js
SpanData
function SpanData(agent, trace, name, parentSpanId, isRoot, skipFrames) { var spanId = uid++; this.agent = agent; var spanName = traceUtil.truncate(name, constants.TRACE_SERVICE_SPAN_NAME_LIMIT); this.span = new TraceSpan(spanName, spanId, parentSpanId); this.trace = trace; this.isRoot = isRoot; trace.spans.push(this.span); if (agent.config().stackTraceLimit > 0) { // This is a mechanism to get the structured stack trace out of V8. // prepareStackTrace is called th first time the Error#stack property is // accessed. The original behavior is to format the stack as an exception // throw, which is not what we like. We customize it. // // See: https://code.google.com/p/v8-wiki/wiki/JavaScriptStackTraceApi // var origLimit = Error.stackTraceLimit; Error.stackTraceLimit = agent.config().stackTraceLimit + skipFrames; var origPrepare = Error.prepareStackTrace; Error.prepareStackTrace = function(error, structured) { return structured; }; var e = {}; Error.captureStackTrace(e, SpanData); var stackFrames = []; e.stack.forEach(function(callSite, i) { if (i < skipFrames) { return; } var functionName = callSite.getFunctionName(); var methodName = callSite.getMethodName(); var name = (methodName && functionName) ? functionName + ' [as ' + methodName + ']' : functionName || methodName || '<anonymous function>'; stackFrames.push(new StackFrame(undefined, name, callSite.getFileName(), callSite.getLineNumber(), callSite.getColumnNumber())); }); // Set the label on the trace span directly to bypass truncation to // config.maxLabelValueSize. this.span.setLabel(TraceLabels.STACK_TRACE_DETAILS_KEY, traceUtil.truncate(JSON.stringify({stack_frame: stackFrames}), constants.TRACE_SERVICE_LABEL_VALUE_LIMIT)); Error.stackTraceLimit = origLimit; Error.prepareStackTrace = origPrepare; } }
javascript
function SpanData(agent, trace, name, parentSpanId, isRoot, skipFrames) { var spanId = uid++; this.agent = agent; var spanName = traceUtil.truncate(name, constants.TRACE_SERVICE_SPAN_NAME_LIMIT); this.span = new TraceSpan(spanName, spanId, parentSpanId); this.trace = trace; this.isRoot = isRoot; trace.spans.push(this.span); if (agent.config().stackTraceLimit > 0) { // This is a mechanism to get the structured stack trace out of V8. // prepareStackTrace is called th first time the Error#stack property is // accessed. The original behavior is to format the stack as an exception // throw, which is not what we like. We customize it. // // See: https://code.google.com/p/v8-wiki/wiki/JavaScriptStackTraceApi // var origLimit = Error.stackTraceLimit; Error.stackTraceLimit = agent.config().stackTraceLimit + skipFrames; var origPrepare = Error.prepareStackTrace; Error.prepareStackTrace = function(error, structured) { return structured; }; var e = {}; Error.captureStackTrace(e, SpanData); var stackFrames = []; e.stack.forEach(function(callSite, i) { if (i < skipFrames) { return; } var functionName = callSite.getFunctionName(); var methodName = callSite.getMethodName(); var name = (methodName && functionName) ? functionName + ' [as ' + methodName + ']' : functionName || methodName || '<anonymous function>'; stackFrames.push(new StackFrame(undefined, name, callSite.getFileName(), callSite.getLineNumber(), callSite.getColumnNumber())); }); // Set the label on the trace span directly to bypass truncation to // config.maxLabelValueSize. this.span.setLabel(TraceLabels.STACK_TRACE_DETAILS_KEY, traceUtil.truncate(JSON.stringify({stack_frame: stackFrames}), constants.TRACE_SERVICE_LABEL_VALUE_LIMIT)); Error.stackTraceLimit = origLimit; Error.prepareStackTrace = origPrepare; } }
[ "function", "SpanData", "(", "agent", ",", "trace", ",", "name", ",", "parentSpanId", ",", "isRoot", ",", "skipFrames", ")", "{", "var", "spanId", "=", "uid", "++", ";", "this", ".", "agent", "=", "agent", ";", "var", "spanName", "=", "traceUtil", ".", "truncate", "(", "name", ",", "constants", ".", "TRACE_SERVICE_SPAN_NAME_LIMIT", ")", ";", "this", ".", "span", "=", "new", "TraceSpan", "(", "spanName", ",", "spanId", ",", "parentSpanId", ")", ";", "this", ".", "trace", "=", "trace", ";", "this", ".", "isRoot", "=", "isRoot", ";", "trace", ".", "spans", ".", "push", "(", "this", ".", "span", ")", ";", "if", "(", "agent", ".", "config", "(", ")", ".", "stackTraceLimit", ">", "0", ")", "{", "// This is a mechanism to get the structured stack trace out of V8.", "// prepareStackTrace is called th first time the Error#stack property is", "// accessed. The original behavior is to format the stack as an exception", "// throw, which is not what we like. We customize it.", "//", "// See: https://code.google.com/p/v8-wiki/wiki/JavaScriptStackTraceApi", "//", "var", "origLimit", "=", "Error", ".", "stackTraceLimit", ";", "Error", ".", "stackTraceLimit", "=", "agent", ".", "config", "(", ")", ".", "stackTraceLimit", "+", "skipFrames", ";", "var", "origPrepare", "=", "Error", ".", "prepareStackTrace", ";", "Error", ".", "prepareStackTrace", "=", "function", "(", "error", ",", "structured", ")", "{", "return", "structured", ";", "}", ";", "var", "e", "=", "{", "}", ";", "Error", ".", "captureStackTrace", "(", "e", ",", "SpanData", ")", ";", "var", "stackFrames", "=", "[", "]", ";", "e", ".", "stack", ".", "forEach", "(", "function", "(", "callSite", ",", "i", ")", "{", "if", "(", "i", "<", "skipFrames", ")", "{", "return", ";", "}", "var", "functionName", "=", "callSite", ".", "getFunctionName", "(", ")", ";", "var", "methodName", "=", "callSite", ".", "getMethodName", "(", ")", ";", "var", "name", "=", "(", "methodName", "&&", "functionName", ")", "?", "functionName", "+", "' [as '", "+", "methodName", "+", "']'", ":", "functionName", "||", "methodName", "||", "'<anonymous function>'", ";", "stackFrames", ".", "push", "(", "new", "StackFrame", "(", "undefined", ",", "name", ",", "callSite", ".", "getFileName", "(", ")", ",", "callSite", ".", "getLineNumber", "(", ")", ",", "callSite", ".", "getColumnNumber", "(", ")", ")", ")", ";", "}", ")", ";", "// Set the label on the trace span directly to bypass truncation to", "// config.maxLabelValueSize.", "this", ".", "span", ".", "setLabel", "(", "TraceLabels", ".", "STACK_TRACE_DETAILS_KEY", ",", "traceUtil", ".", "truncate", "(", "JSON", ".", "stringify", "(", "{", "stack_frame", ":", "stackFrames", "}", ")", ",", "constants", ".", "TRACE_SERVICE_LABEL_VALUE_LIMIT", ")", ")", ";", "Error", ".", "stackTraceLimit", "=", "origLimit", ";", "Error", ".", "prepareStackTrace", "=", "origPrepare", ";", "}", "}" ]
Creates a trace context object. @param {Trace} trace The object holding the spans comprising this trace. @param {string} name The name of the span. @param {number} parentSpanId The id of the parent span, 0 for root spans. @param {boolean} isRoot Whether this is a root span. @param {number} skipFrames the number of frames to remove from the top of the stack. @constructor
[ "Creates", "a", "trace", "context", "object", "." ]
1d283858b45e5fb42519dc1f39cffaaade601931
https://github.com/keymetrics/trassingue/blob/1d283858b45e5fb42519dc1f39cffaaade601931/src/span-data.js#L38-L87
36,109
keymetrics/trassingue
src/plugins/plugin-mongodb-core.js
wrapCallback
function wrapCallback(api, span, done) { var fn = function(err, res) { if (api.enhancedDatabaseReportingEnabled()) { if (err) { // Errors may contain sensitive query parameters. span.addLabel('mongoError', err); } if (res) { var result = res.result ? res.result : res; span.addLabel('result', result); } } span.endSpan(); if (done) { done(err, res); } }; return api.wrap(fn); }
javascript
function wrapCallback(api, span, done) { var fn = function(err, res) { if (api.enhancedDatabaseReportingEnabled()) { if (err) { // Errors may contain sensitive query parameters. span.addLabel('mongoError', err); } if (res) { var result = res.result ? res.result : res; span.addLabel('result', result); } } span.endSpan(); if (done) { done(err, res); } }; return api.wrap(fn); }
[ "function", "wrapCallback", "(", "api", ",", "span", ",", "done", ")", "{", "var", "fn", "=", "function", "(", "err", ",", "res", ")", "{", "if", "(", "api", ".", "enhancedDatabaseReportingEnabled", "(", ")", ")", "{", "if", "(", "err", ")", "{", "// Errors may contain sensitive query parameters.", "span", ".", "addLabel", "(", "'mongoError'", ",", "err", ")", ";", "}", "if", "(", "res", ")", "{", "var", "result", "=", "res", ".", "result", "?", "res", ".", "result", ":", "res", ";", "span", ".", "addLabel", "(", "'result'", ",", "result", ")", ";", "}", "}", "span", ".", "endSpan", "(", ")", ";", "if", "(", "done", ")", "{", "done", "(", "err", ",", "res", ")", ";", "}", "}", ";", "return", "api", ".", "wrap", "(", "fn", ")", ";", "}" ]
Wraps the provided callback so that the provided span will be closed immediately after the callback is invoked. @param {Span} span The span to be closed. @param {Function} done The callback to be wrapped. @return {Function} The wrapped function.
[ "Wraps", "the", "provided", "callback", "so", "that", "the", "provided", "span", "will", "be", "closed", "immediately", "after", "the", "callback", "is", "invoked", "." ]
1d283858b45e5fb42519dc1f39cffaaade601931
https://github.com/keymetrics/trassingue/blob/1d283858b45e5fb42519dc1f39cffaaade601931/src/plugins/plugin-mongodb-core.js#L68-L86
36,110
keymetrics/trassingue
src/trace-span.js
TraceSpan
function TraceSpan(name, spanId, parentSpanId) { this.name = name; this.parentSpanId = parentSpanId; this.spanId = spanId; this.kind = 'RPC_CLIENT'; this.labels = {}; this.startTime = (new Date()).toISOString(); this.endTime = ''; }
javascript
function TraceSpan(name, spanId, parentSpanId) { this.name = name; this.parentSpanId = parentSpanId; this.spanId = spanId; this.kind = 'RPC_CLIENT'; this.labels = {}; this.startTime = (new Date()).toISOString(); this.endTime = ''; }
[ "function", "TraceSpan", "(", "name", ",", "spanId", ",", "parentSpanId", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "parentSpanId", "=", "parentSpanId", ";", "this", ".", "spanId", "=", "spanId", ";", "this", ".", "kind", "=", "'RPC_CLIENT'", ";", "this", ".", "labels", "=", "{", "}", ";", "this", ".", "startTime", "=", "(", "new", "Date", "(", ")", ")", ".", "toISOString", "(", ")", ";", "this", ".", "endTime", "=", "''", ";", "}" ]
Creates a trace span object. @constructor
[ "Creates", "a", "trace", "span", "object", "." ]
1d283858b45e5fb42519dc1f39cffaaade601931
https://github.com/keymetrics/trassingue/blob/1d283858b45e5fb42519dc1f39cffaaade601931/src/trace-span.js#L23-L31
36,111
psiphi75/compass-hmc5883l
example.js
printHeadingCB
function printHeadingCB(err, heading) { if (err) { console.log(err); return; } console.log(heading * 180 / Math.PI); }
javascript
function printHeadingCB(err, heading) { if (err) { console.log(err); return; } console.log(heading * 180 / Math.PI); }
[ "function", "printHeadingCB", "(", "err", ",", "heading", ")", "{", "if", "(", "err", ")", "{", "console", ".", "log", "(", "err", ")", ";", "return", ";", "}", "console", ".", "log", "(", "heading", "*", "180", "/", "Math", ".", "PI", ")", ";", "}" ]
Gets called every time we get the values.
[ "Gets", "called", "every", "time", "we", "get", "the", "values", "." ]
72b25ef2c2d2a8c0d67ab14befea93a346b9086f
https://github.com/psiphi75/compass-hmc5883l/blob/72b25ef2c2d2a8c0d67ab14befea93a346b9086f/example.js#L30-L36
36,112
keymetrics/trassingue
src/trace-api.js
ChildSpan
function ChildSpan(agent, span) { this.agent_ = agent; this.span_ = span; this.serializedTraceContext_ = agent.generateTraceContext(span, true); }
javascript
function ChildSpan(agent, span) { this.agent_ = agent; this.span_ = span; this.serializedTraceContext_ = agent.generateTraceContext(span, true); }
[ "function", "ChildSpan", "(", "agent", ",", "span", ")", "{", "this", ".", "agent_", "=", "agent", ";", "this", ".", "span_", "=", "span", ";", "this", ".", "serializedTraceContext_", "=", "agent", ".", "generateTraceContext", "(", "span", ",", "true", ")", ";", "}" ]
This file describes an interface for third-party plugins to enable tracing for arbitrary modules. An object that represents a single child span. It exposes functions for adding labels to or closing the span. @param {TraceAgent} agent The underlying trace agent object. @param {SpanData} span The internal data structure backing the child span.
[ "This", "file", "describes", "an", "interface", "for", "third", "-", "party", "plugins", "to", "enable", "tracing", "for", "arbitrary", "modules", ".", "An", "object", "that", "represents", "a", "single", "child", "span", ".", "It", "exposes", "functions", "for", "adding", "labels", "to", "or", "closing", "the", "span", "." ]
1d283858b45e5fb42519dc1f39cffaaade601931
https://github.com/keymetrics/trassingue/blob/1d283858b45e5fb42519dc1f39cffaaade601931/src/trace-api.js#L35-L39
36,113
keymetrics/trassingue
src/trace-api.js
RootSpan
function RootSpan(agent, span) { this.agent_ = agent; this.span_ = span; this.serializedTraceContext_ = agent.generateTraceContext(span, true); }
javascript
function RootSpan(agent, span) { this.agent_ = agent; this.span_ = span; this.serializedTraceContext_ = agent.generateTraceContext(span, true); }
[ "function", "RootSpan", "(", "agent", ",", "span", ")", "{", "this", ".", "agent_", "=", "agent", ";", "this", ".", "span_", "=", "span", ";", "this", ".", "serializedTraceContext_", "=", "agent", ".", "generateTraceContext", "(", "span", ",", "true", ")", ";", "}" ]
An object that represents a single root span. It exposes functions for adding labels to or closing the span. @param {TraceAgent} agent The underlying trace agent object. @param {SpanData} span The internal data structure backing the root span.
[ "An", "object", "that", "represents", "a", "single", "root", "span", ".", "It", "exposes", "functions", "for", "adding", "labels", "to", "or", "closing", "the", "span", "." ]
1d283858b45e5fb42519dc1f39cffaaade601931
https://github.com/keymetrics/trassingue/blob/1d283858b45e5fb42519dc1f39cffaaade601931/src/trace-api.js#L72-L76
36,114
keymetrics/trassingue
src/trace-api.js
TraceApiImplementation
function TraceApiImplementation(agent, pluginName) { this.agent_ = agent; this.logger_ = agent.logger; this.pluginName_ = pluginName; }
javascript
function TraceApiImplementation(agent, pluginName) { this.agent_ = agent; this.logger_ = agent.logger; this.pluginName_ = pluginName; }
[ "function", "TraceApiImplementation", "(", "agent", ",", "pluginName", ")", "{", "this", ".", "agent_", "=", "agent", ";", "this", ".", "logger_", "=", "agent", ".", "logger", ";", "this", ".", "pluginName_", "=", "pluginName", ";", "}" ]
The functional implementation of the Trace API
[ "The", "functional", "implementation", "of", "the", "Trace", "API" ]
1d283858b45e5fb42519dc1f39cffaaade601931
https://github.com/keymetrics/trassingue/blob/1d283858b45e5fb42519dc1f39cffaaade601931/src/trace-api.js#L109-L113
36,115
keymetrics/trassingue
src/trace-api.js
createRootSpan_
function createRootSpan_(api, options, skipFrames) { options = options || {}; // If the options object passed in has the getTraceContext field set, // try to retrieve the header field containing incoming trace metadata. var incomingTraceContext; if (is.string(options.traceContext)) { incomingTraceContext = api.agent_.parseContextFromHeader(options.traceContext); } incomingTraceContext = incomingTraceContext || {}; if (!api.agent_.shouldTrace(options, incomingTraceContext.options)) { cls.setRootContext(nullSpan); return null; } var rootContext = api.agent_.createRootSpanData(options.name, incomingTraceContext.traceId, incomingTraceContext.spanId, skipFrames + 1); return new RootSpan(api.agent_, rootContext); }
javascript
function createRootSpan_(api, options, skipFrames) { options = options || {}; // If the options object passed in has the getTraceContext field set, // try to retrieve the header field containing incoming trace metadata. var incomingTraceContext; if (is.string(options.traceContext)) { incomingTraceContext = api.agent_.parseContextFromHeader(options.traceContext); } incomingTraceContext = incomingTraceContext || {}; if (!api.agent_.shouldTrace(options, incomingTraceContext.options)) { cls.setRootContext(nullSpan); return null; } var rootContext = api.agent_.createRootSpanData(options.name, incomingTraceContext.traceId, incomingTraceContext.spanId, skipFrames + 1); return new RootSpan(api.agent_, rootContext); }
[ "function", "createRootSpan_", "(", "api", ",", "options", ",", "skipFrames", ")", "{", "options", "=", "options", "||", "{", "}", ";", "// If the options object passed in has the getTraceContext field set,", "// try to retrieve the header field containing incoming trace metadata.", "var", "incomingTraceContext", ";", "if", "(", "is", ".", "string", "(", "options", ".", "traceContext", ")", ")", "{", "incomingTraceContext", "=", "api", ".", "agent_", ".", "parseContextFromHeader", "(", "options", ".", "traceContext", ")", ";", "}", "incomingTraceContext", "=", "incomingTraceContext", "||", "{", "}", ";", "if", "(", "!", "api", ".", "agent_", ".", "shouldTrace", "(", "options", ",", "incomingTraceContext", ".", "options", ")", ")", "{", "cls", ".", "setRootContext", "(", "nullSpan", ")", ";", "return", "null", ";", "}", "var", "rootContext", "=", "api", ".", "agent_", ".", "createRootSpanData", "(", "options", ".", "name", ",", "incomingTraceContext", ".", "traceId", ",", "incomingTraceContext", ".", "spanId", ",", "skipFrames", "+", "1", ")", ";", "return", "new", "RootSpan", "(", "api", ".", "agent_", ",", "rootContext", ")", ";", "}" ]
Module-private functions
[ "Module", "-", "private", "functions" ]
1d283858b45e5fb42519dc1f39cffaaade601931
https://github.com/keymetrics/trassingue/blob/1d283858b45e5fb42519dc1f39cffaaade601931/src/trace-api.js#L322-L340
36,116
cb1kenobi/cli-kit
src/parser/option.js
processAliases
function processAliases(aliases) { const result = { long: {}, short: {} }; if (!aliases) { return result; } if (!Array.isArray(aliases)) { if (typeof aliases === 'object') { if (aliases.long && typeof aliases.long === 'object') { Object.assign(result.long, aliases.long); } if (aliases.short && typeof aliases.short === 'object') { Object.assign(result.short, aliases.short); } return result; } aliases = [ aliases ]; } for (const alias of aliases) { if (!alias || typeof alias !== 'string') { throw E.INVALID_ALIAS('Expected aliases to be a string or an array of strings', { name: 'aliases', scope: 'Option.constructor', value: alias }); } for (const a of alias.split(/[ ,|]+/)) { const m = a.match(aliasRegExp); if (!m) { throw E.INVALID_ALIAS(`Invalid alias format "${alias}"`, { name: 'aliases', scope: 'Option.constructor', value: alias }); } if (m[2]) { result.short[m[2]] = !m[1]; } else if (m[3]) { result.long[m[3]] = !m[1]; } } } return result; }
javascript
function processAliases(aliases) { const result = { long: {}, short: {} }; if (!aliases) { return result; } if (!Array.isArray(aliases)) { if (typeof aliases === 'object') { if (aliases.long && typeof aliases.long === 'object') { Object.assign(result.long, aliases.long); } if (aliases.short && typeof aliases.short === 'object') { Object.assign(result.short, aliases.short); } return result; } aliases = [ aliases ]; } for (const alias of aliases) { if (!alias || typeof alias !== 'string') { throw E.INVALID_ALIAS('Expected aliases to be a string or an array of strings', { name: 'aliases', scope: 'Option.constructor', value: alias }); } for (const a of alias.split(/[ ,|]+/)) { const m = a.match(aliasRegExp); if (!m) { throw E.INVALID_ALIAS(`Invalid alias format "${alias}"`, { name: 'aliases', scope: 'Option.constructor', value: alias }); } if (m[2]) { result.short[m[2]] = !m[1]; } else if (m[3]) { result.long[m[3]] = !m[1]; } } } return result; }
[ "function", "processAliases", "(", "aliases", ")", "{", "const", "result", "=", "{", "long", ":", "{", "}", ",", "short", ":", "{", "}", "}", ";", "if", "(", "!", "aliases", ")", "{", "return", "result", ";", "}", "if", "(", "!", "Array", ".", "isArray", "(", "aliases", ")", ")", "{", "if", "(", "typeof", "aliases", "===", "'object'", ")", "{", "if", "(", "aliases", ".", "long", "&&", "typeof", "aliases", ".", "long", "===", "'object'", ")", "{", "Object", ".", "assign", "(", "result", ".", "long", ",", "aliases", ".", "long", ")", ";", "}", "if", "(", "aliases", ".", "short", "&&", "typeof", "aliases", ".", "short", "===", "'object'", ")", "{", "Object", ".", "assign", "(", "result", ".", "short", ",", "aliases", ".", "short", ")", ";", "}", "return", "result", ";", "}", "aliases", "=", "[", "aliases", "]", ";", "}", "for", "(", "const", "alias", "of", "aliases", ")", "{", "if", "(", "!", "alias", "||", "typeof", "alias", "!==", "'string'", ")", "{", "throw", "E", ".", "INVALID_ALIAS", "(", "'Expected aliases to be a string or an array of strings'", ",", "{", "name", ":", "'aliases'", ",", "scope", ":", "'Option.constructor'", ",", "value", ":", "alias", "}", ")", ";", "}", "for", "(", "const", "a", "of", "alias", ".", "split", "(", "/", "[ ,|]+", "/", ")", ")", "{", "const", "m", "=", "a", ".", "match", "(", "aliasRegExp", ")", ";", "if", "(", "!", "m", ")", "{", "throw", "E", ".", "INVALID_ALIAS", "(", "`", "${", "alias", "}", "`", ",", "{", "name", ":", "'aliases'", ",", "scope", ":", "'Option.constructor'", ",", "value", ":", "alias", "}", ")", ";", "}", "if", "(", "m", "[", "2", "]", ")", "{", "result", ".", "short", "[", "m", "[", "2", "]", "]", "=", "!", "m", "[", "1", "]", ";", "}", "else", "if", "(", "m", "[", "3", "]", ")", "{", "result", ".", "long", "[", "m", "[", "3", "]", "]", "=", "!", "m", "[", "1", "]", ";", "}", "}", "}", "return", "result", ";", "}" ]
Processes aliases into sorted buckets for faster lookup. @param {Array.<String>|String} aliases - An array, object, or string containing aliases. @returns {Object}
[ "Processes", "aliases", "into", "sorted", "buckets", "for", "faster", "lookup", "." ]
6d0d5ebb17cfbd11a8ec25ce8e4251f72cdc7734
https://github.com/cb1kenobi/cli-kit/blob/6d0d5ebb17cfbd11a8ec25ce8e4251f72cdc7734/src/parser/option.js#L221-L266
36,117
ryejs/rye
lib/query.js
getClosestNode
function getClosestNode (element, method, selector) { do { element = element[method] } while (element && ((selector && !matches(element, selector)) || !util.isElement(element))) return element }
javascript
function getClosestNode (element, method, selector) { do { element = element[method] } while (element && ((selector && !matches(element, selector)) || !util.isElement(element))) return element }
[ "function", "getClosestNode", "(", "element", ",", "method", ",", "selector", ")", "{", "do", "{", "element", "=", "element", "[", "method", "]", "}", "while", "(", "element", "&&", "(", "(", "selector", "&&", "!", "matches", "(", "element", ",", "selector", ")", ")", "||", "!", "util", ".", "isElement", "(", "element", ")", ")", ")", "return", "element", "}" ]
Walks the DOM tree using `method`, returns when an element node is found
[ "Walks", "the", "DOM", "tree", "using", "method", "returns", "when", "an", "element", "node", "is", "found" ]
24fd6728d055a1d2285b789c697a4578051f542d
https://github.com/ryejs/rye/blob/24fd6728d055a1d2285b789c697a4578051f542d/lib/query.js#L79-L84
36,118
ryejs/rye
lib/query.js
_create
function _create (elements, selector) { return selector == null ? new Rye(elements) : new Rye(elements).filter(selector) }
javascript
function _create (elements, selector) { return selector == null ? new Rye(elements) : new Rye(elements).filter(selector) }
[ "function", "_create", "(", "elements", ",", "selector", ")", "{", "return", "selector", "==", "null", "?", "new", "Rye", "(", "elements", ")", ":", "new", "Rye", "(", "elements", ")", ".", "filter", "(", "selector", ")", "}" ]
Creates a new Rye instance applying a filter if necessary
[ "Creates", "a", "new", "Rye", "instance", "applying", "a", "filter", "if", "necessary" ]
24fd6728d055a1d2285b789c697a4578051f542d
https://github.com/ryejs/rye/blob/24fd6728d055a1d2285b789c697a4578051f542d/lib/query.js#L87-L89
36,119
keymetrics/trassingue
src/plugins/plugin-redis.js
createCreateStreamWrap
function createCreateStreamWrap(api) { return function createStreamWrap(create_stream) { return function create_stream_trace() { if (!this.stream) { Object.defineProperty(this, 'stream', { get: function () { return this._google_trace_stream; }, set: function (val) { api.wrapEmitter(val); this._google_trace_stream = val; } }); } return create_stream.apply(this, arguments); }; }; }
javascript
function createCreateStreamWrap(api) { return function createStreamWrap(create_stream) { return function create_stream_trace() { if (!this.stream) { Object.defineProperty(this, 'stream', { get: function () { return this._google_trace_stream; }, set: function (val) { api.wrapEmitter(val); this._google_trace_stream = val; } }); } return create_stream.apply(this, arguments); }; }; }
[ "function", "createCreateStreamWrap", "(", "api", ")", "{", "return", "function", "createStreamWrap", "(", "create_stream", ")", "{", "return", "function", "create_stream_trace", "(", ")", "{", "if", "(", "!", "this", ".", "stream", ")", "{", "Object", ".", "defineProperty", "(", "this", ",", "'stream'", ",", "{", "get", ":", "function", "(", ")", "{", "return", "this", ".", "_google_trace_stream", ";", "}", ",", "set", ":", "function", "(", "val", ")", "{", "api", ".", "wrapEmitter", "(", "val", ")", ";", "this", ".", "_google_trace_stream", "=", "val", ";", "}", "}", ")", ";", "}", "return", "create_stream", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "}", ";", "}" ]
Used for redis version > 2.3
[ "Used", "for", "redis", "version", ">", "2", ".", "3" ]
1d283858b45e5fb42519dc1f39cffaaade601931
https://github.com/keymetrics/trassingue/blob/1d283858b45e5fb42519dc1f39cffaaade601931/src/plugins/plugin-redis.js#L32-L47
36,120
keymetrics/trassingue
src/plugins/plugin-redis.js
createStreamListenersWrap
function createStreamListenersWrap(api) { return function streamListenersWrap(install_stream_listeners) { return function install_stream_listeners_trace() { api.wrapEmitter(this.stream); return install_stream_listeners.apply(this, arguments); }; }; }
javascript
function createStreamListenersWrap(api) { return function streamListenersWrap(install_stream_listeners) { return function install_stream_listeners_trace() { api.wrapEmitter(this.stream); return install_stream_listeners.apply(this, arguments); }; }; }
[ "function", "createStreamListenersWrap", "(", "api", ")", "{", "return", "function", "streamListenersWrap", "(", "install_stream_listeners", ")", "{", "return", "function", "install_stream_listeners_trace", "(", ")", "{", "api", ".", "wrapEmitter", "(", "this", ".", "stream", ")", ";", "return", "install_stream_listeners", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "}", ";", "}" ]
Used for redis version <= 2.3
[ "Used", "for", "redis", "version", "<", "=", "2", ".", "3" ]
1d283858b45e5fb42519dc1f39cffaaade601931
https://github.com/keymetrics/trassingue/blob/1d283858b45e5fb42519dc1f39cffaaade601931/src/plugins/plugin-redis.js#L50-L57
36,121
Squarespace/pouchdb-lru-cache
index.js
getDocWithDefault
function getDocWithDefault(db, id, defaultDoc) { return db.get(id).catch(function (err) { /* istanbul ignore if */ if (err.status !== 404) { throw err; } defaultDoc._id = id; return db.put(defaultDoc).catch(function (err) { /* istanbul ignore if */ if (err.status !== 409) { // conflict throw err; } }).then(function () { return db.get(id); }); }); }
javascript
function getDocWithDefault(db, id, defaultDoc) { return db.get(id).catch(function (err) { /* istanbul ignore if */ if (err.status !== 404) { throw err; } defaultDoc._id = id; return db.put(defaultDoc).catch(function (err) { /* istanbul ignore if */ if (err.status !== 409) { // conflict throw err; } }).then(function () { return db.get(id); }); }); }
[ "function", "getDocWithDefault", "(", "db", ",", "id", ",", "defaultDoc", ")", "{", "return", "db", ".", "get", "(", "id", ")", ".", "catch", "(", "function", "(", "err", ")", "{", "/* istanbul ignore if */", "if", "(", "err", ".", "status", "!==", "404", ")", "{", "throw", "err", ";", "}", "defaultDoc", ".", "_id", "=", "id", ";", "return", "db", ".", "put", "(", "defaultDoc", ")", ".", "catch", "(", "function", "(", "err", ")", "{", "/* istanbul ignore if */", "if", "(", "err", ".", "status", "!==", "409", ")", "{", "// conflict", "throw", "err", ";", "}", "}", ")", ".", "then", "(", "function", "(", ")", "{", "return", "db", ".", "get", "(", "id", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Create the doc if it doesn't exist
[ "Create", "the", "doc", "if", "it", "doesn", "t", "exist" ]
dcb35db4771b469be9bfe08bec0cdff71ae0a925
https://github.com/Squarespace/pouchdb-lru-cache/blob/dcb35db4771b469be9bfe08bec0cdff71ae0a925/index.js#L18-L34
36,122
Squarespace/pouchdb-lru-cache
index.js
getMainDoc
function getMainDoc(db) { return getDocWithDefault(db, MAIN_DOC_ID, {}).then(function (doc) { if (!doc._attachments) { doc._attachments = {}; } return doc; }); }
javascript
function getMainDoc(db) { return getDocWithDefault(db, MAIN_DOC_ID, {}).then(function (doc) { if (!doc._attachments) { doc._attachments = {}; } return doc; }); }
[ "function", "getMainDoc", "(", "db", ")", "{", "return", "getDocWithDefault", "(", "db", ",", "MAIN_DOC_ID", ",", "{", "}", ")", ".", "then", "(", "function", "(", "doc", ")", "{", "if", "(", "!", "doc", ".", "_attachments", ")", "{", "doc", ".", "_attachments", "=", "{", "}", ";", "}", "return", "doc", ";", "}", ")", ";", "}" ]
Store all attachments in a single doc. Since attachments are deduped, and unless the attachment metadata can't all fit in memory at once, there's no reason not to do this.
[ "Store", "all", "attachments", "in", "a", "single", "doc", ".", "Since", "attachments", "are", "deduped", "and", "unless", "the", "attachment", "metadata", "can", "t", "all", "fit", "in", "memory", "at", "once", "there", "s", "no", "reason", "not", "to", "do", "this", "." ]
dcb35db4771b469be9bfe08bec0cdff71ae0a925
https://github.com/Squarespace/pouchdb-lru-cache/blob/dcb35db4771b469be9bfe08bec0cdff71ae0a925/index.js#L41-L48
36,123
Squarespace/pouchdb-lru-cache
index.js
calculateTotalSize
function calculateTotalSize(mainDoc) { var digestsToSizes = {}; // dedup by digest, since that's what Pouch does under the hood Object.keys(mainDoc._attachments).forEach(function (attName) { var att = mainDoc._attachments[attName]; digestsToSizes[att.digest] = att.length; }); var total = 0; Object.keys(digestsToSizes).forEach(function (digest) { total += digestsToSizes[digest]; }); return total; }
javascript
function calculateTotalSize(mainDoc) { var digestsToSizes = {}; // dedup by digest, since that's what Pouch does under the hood Object.keys(mainDoc._attachments).forEach(function (attName) { var att = mainDoc._attachments[attName]; digestsToSizes[att.digest] = att.length; }); var total = 0; Object.keys(digestsToSizes).forEach(function (digest) { total += digestsToSizes[digest]; }); return total; }
[ "function", "calculateTotalSize", "(", "mainDoc", ")", "{", "var", "digestsToSizes", "=", "{", "}", ";", "// dedup by digest, since that's what Pouch does under the hood", "Object", ".", "keys", "(", "mainDoc", ".", "_attachments", ")", ".", "forEach", "(", "function", "(", "attName", ")", "{", "var", "att", "=", "mainDoc", ".", "_attachments", "[", "attName", "]", ";", "digestsToSizes", "[", "att", ".", "digest", "]", "=", "att", ".", "length", ";", "}", ")", ";", "var", "total", "=", "0", ";", "Object", ".", "keys", "(", "digestsToSizes", ")", ".", "forEach", "(", "function", "(", "digest", ")", "{", "total", "+=", "digestsToSizes", "[", "digest", "]", ";", "}", ")", ";", "return", "total", ";", "}" ]
Get the total size of the LRU cache, taking duplicate digests into account
[ "Get", "the", "total", "size", "of", "the", "LRU", "cache", "taking", "duplicate", "digests", "into", "account" ]
dcb35db4771b469be9bfe08bec0cdff71ae0a925
https://github.com/Squarespace/pouchdb-lru-cache/blob/dcb35db4771b469be9bfe08bec0cdff71ae0a925/index.js#L81-L95
36,124
Squarespace/pouchdb-lru-cache
index.js
synchronous
function synchronous(promiseFactory) { return function () { var promise = queue.then(promiseFactory); queue = promise.catch(noop); // squelch return promise; }; }
javascript
function synchronous(promiseFactory) { return function () { var promise = queue.then(promiseFactory); queue = promise.catch(noop); // squelch return promise; }; }
[ "function", "synchronous", "(", "promiseFactory", ")", "{", "return", "function", "(", ")", "{", "var", "promise", "=", "queue", ".", "then", "(", "promiseFactory", ")", ";", "queue", "=", "promise", ".", "catch", "(", "noop", ")", ";", "// squelch", "return", "promise", ";", "}", ";", "}" ]
To mitigate 409s, we synchronize certain things that need to be done in a "transaction". So whatever promise is given to this function will execute sequentially.
[ "To", "mitigate", "409s", "we", "synchronize", "certain", "things", "that", "need", "to", "be", "done", "in", "a", "transaction", ".", "So", "whatever", "promise", "is", "given", "to", "this", "function", "will", "execute", "sequentially", "." ]
dcb35db4771b469be9bfe08bec0cdff71ae0a925
https://github.com/Squarespace/pouchdb-lru-cache/blob/dcb35db4771b469be9bfe08bec0cdff71ae0a925/index.js#L102-L108
36,125
Squarespace/pouchdb-lru-cache
index.js
getDigestsToLastUsed
function getDigestsToLastUsed(mainDoc, lastUsedDoc) { var result = {}; // dedup by digest, use the most recent date Object.keys(mainDoc._attachments).forEach(function (attName) { var att = mainDoc._attachments[attName]; var existing = result[att.digest] || 0; result[att.digest] = Math.max(existing, lastUsedDoc.lastUsed[att.digest]); }); return result; }
javascript
function getDigestsToLastUsed(mainDoc, lastUsedDoc) { var result = {}; // dedup by digest, use the most recent date Object.keys(mainDoc._attachments).forEach(function (attName) { var att = mainDoc._attachments[attName]; var existing = result[att.digest] || 0; result[att.digest] = Math.max(existing, lastUsedDoc.lastUsed[att.digest]); }); return result; }
[ "function", "getDigestsToLastUsed", "(", "mainDoc", ",", "lastUsedDoc", ")", "{", "var", "result", "=", "{", "}", ";", "// dedup by digest, use the most recent date", "Object", ".", "keys", "(", "mainDoc", ".", "_attachments", ")", ".", "forEach", "(", "function", "(", "attName", ")", "{", "var", "att", "=", "mainDoc", ".", "_attachments", "[", "attName", "]", ";", "var", "existing", "=", "result", "[", "att", ".", "digest", "]", "||", "0", ";", "result", "[", "att", ".", "digest", "]", "=", "Math", ".", "max", "(", "existing", ",", "lastUsedDoc", ".", "lastUsed", "[", "att", ".", "digest", "]", ")", ";", "}", ")", ";", "return", "result", ";", "}" ]
Get a map of unique digests to when they were last used.
[ "Get", "a", "map", "of", "unique", "digests", "to", "when", "they", "were", "last", "used", "." ]
dcb35db4771b469be9bfe08bec0cdff71ae0a925
https://github.com/Squarespace/pouchdb-lru-cache/blob/dcb35db4771b469be9bfe08bec0cdff71ae0a925/index.js#L113-L124
36,126
Squarespace/pouchdb-lru-cache
index.js
getLeastRecentlyUsed
function getLeastRecentlyUsed(mainDoc, lastUsedDoc) { var digestsToLastUsed = getDigestsToLastUsed(mainDoc, lastUsedDoc); var min; var minDigest; Object.keys(digestsToLastUsed).forEach(function (digest) { var lastUsed = digestsToLastUsed[digest]; if (typeof min === 'undefined' || min > lastUsed) { min = lastUsed; minDigest = digest; } }); return minDigest; }
javascript
function getLeastRecentlyUsed(mainDoc, lastUsedDoc) { var digestsToLastUsed = getDigestsToLastUsed(mainDoc, lastUsedDoc); var min; var minDigest; Object.keys(digestsToLastUsed).forEach(function (digest) { var lastUsed = digestsToLastUsed[digest]; if (typeof min === 'undefined' || min > lastUsed) { min = lastUsed; minDigest = digest; } }); return minDigest; }
[ "function", "getLeastRecentlyUsed", "(", "mainDoc", ",", "lastUsedDoc", ")", "{", "var", "digestsToLastUsed", "=", "getDigestsToLastUsed", "(", "mainDoc", ",", "lastUsedDoc", ")", ";", "var", "min", ";", "var", "minDigest", ";", "Object", ".", "keys", "(", "digestsToLastUsed", ")", ".", "forEach", "(", "function", "(", "digest", ")", "{", "var", "lastUsed", "=", "digestsToLastUsed", "[", "digest", "]", ";", "if", "(", "typeof", "min", "===", "'undefined'", "||", "min", ">", "lastUsed", ")", "{", "min", "=", "lastUsed", ";", "minDigest", "=", "digest", ";", "}", "}", ")", ";", "return", "minDigest", ";", "}" ]
Get the digest that's the least recently used. If a digest was used by more than one attachment, then favor the more recent usage date.
[ "Get", "the", "digest", "that", "s", "the", "least", "recently", "used", ".", "If", "a", "digest", "was", "used", "by", "more", "than", "one", "attachment", "then", "favor", "the", "more", "recent", "usage", "date", "." ]
dcb35db4771b469be9bfe08bec0cdff71ae0a925
https://github.com/Squarespace/pouchdb-lru-cache/blob/dcb35db4771b469be9bfe08bec0cdff71ae0a925/index.js#L130-L143
36,127
BBVAEngineering/ember-task-scheduler
addon/services/scheduler.js
scheduleFrame
function scheduleFrame(context, method) { method = context[method]; return requestAnimationFrame(method.bind(context)); }
javascript
function scheduleFrame(context, method) { method = context[method]; return requestAnimationFrame(method.bind(context)); }
[ "function", "scheduleFrame", "(", "context", ",", "method", ")", "{", "method", "=", "context", "[", "method", "]", ";", "return", "requestAnimationFrame", "(", "method", ".", "bind", "(", "context", ")", ")", ";", "}" ]
Bind context to method and call requestAnimationFrame with generated function. @method scheduleFrame @param {Object} context @param {String} method @return Number @private
[ "Bind", "context", "to", "method", "and", "call", "requestAnimationFrame", "with", "generated", "function", "." ]
a6c35916e7e5f9e57c8d646062b15f9ae8164147
https://github.com/BBVAEngineering/ember-task-scheduler/blob/a6c35916e7e5f9e57c8d646062b15f9ae8164147/addon/services/scheduler.js#L26-L30
36,128
BBVAEngineering/ember-task-scheduler
addon/services/scheduler.js
exec
function exec(target, method, args, onError, stack) { try { method.apply(target, args); } catch (e) { if (onError) { onError(e, stack); } } }
javascript
function exec(target, method, args, onError, stack) { try { method.apply(target, args); } catch (e) { if (onError) { onError(e, stack); } } }
[ "function", "exec", "(", "target", ",", "method", ",", "args", ",", "onError", ",", "stack", ")", "{", "try", "{", "method", ".", "apply", "(", "target", ",", "args", ")", ";", "}", "catch", "(", "e", ")", "{", "if", "(", "onError", ")", "{", "onError", "(", "e", ",", "stack", ")", ";", "}", "}", "}" ]
Try to exec a function with target and args. When function throws an error it calls onError function with error and stack. @method exec @param {Object} target @param {Function|String} method @param {Array} args @param {Function} onError @param {Error} stack @private
[ "Try", "to", "exec", "a", "function", "with", "target", "and", "args", "." ]
a6c35916e7e5f9e57c8d646062b15f9ae8164147
https://github.com/BBVAEngineering/ember-task-scheduler/blob/a6c35916e7e5f9e57c8d646062b15f9ae8164147/addon/services/scheduler.js#L45-L53
36,129
BBVAEngineering/ember-task-scheduler
addon/services/scheduler.js
_logWarn
function _logWarn(title, stack, test = false, options = {}) { if (test) { return; } const { groupCollapsed, log, trace, groupEnd } = console; if (groupCollapsed && trace && groupEnd) { groupCollapsed(title); log(options.id); trace(stack.stack); groupEnd(title); } else { warn(`${title}\n${stack.stack}`, test, options); } }
javascript
function _logWarn(title, stack, test = false, options = {}) { if (test) { return; } const { groupCollapsed, log, trace, groupEnd } = console; if (groupCollapsed && trace && groupEnd) { groupCollapsed(title); log(options.id); trace(stack.stack); groupEnd(title); } else { warn(`${title}\n${stack.stack}`, test, options); } }
[ "function", "_logWarn", "(", "title", ",", "stack", ",", "test", "=", "false", ",", "options", "=", "{", "}", ")", "{", "if", "(", "test", ")", "{", "return", ";", "}", "const", "{", "groupCollapsed", ",", "log", ",", "trace", ",", "groupEnd", "}", "=", "console", ";", "if", "(", "groupCollapsed", "&&", "trace", "&&", "groupEnd", ")", "{", "groupCollapsed", "(", "title", ")", ";", "log", "(", "options", ".", "id", ")", ";", "trace", "(", "stack", ".", "stack", ")", ";", "groupEnd", "(", "title", ")", ";", "}", "else", "{", "warn", "(", "`", "${", "title", "}", "\\n", "${", "stack", ".", "stack", "}", "`", ",", "test", ",", "options", ")", ";", "}", "}" ]
Logs a grouped stack trace. Fallback to warn() from @ember/debug @param {String} title Group title @param {Object} stack Stack trace @param {Boolean} test An optional boolean. If falsy, the warning will be displayed. @param {Object} options Can be used to pass a unique `id` for this warning. /* istanbul ignore next
[ "Logs", "a", "grouped", "stack", "trace", "." ]
a6c35916e7e5f9e57c8d646062b15f9ae8164147
https://github.com/BBVAEngineering/ember-task-scheduler/blob/a6c35916e7e5f9e57c8d646062b15f9ae8164147/addon/services/scheduler.js#L66-L81
36,130
nomocas/min-history
lib/min-history.js
function(id, location) { var search = "?"+ (location.search || "") + "&hid=" + id; return (location.pathname || '/') + search + (location.hash ? ("#" + location.hash) : ""); }
javascript
function(id, location) { var search = "?"+ (location.search || "") + "&hid=" + id; return (location.pathname || '/') + search + (location.hash ? ("#" + location.hash) : ""); }
[ "function", "(", "id", ",", "location", ")", "{", "var", "search", "=", "\"?\"", "+", "(", "location", ".", "search", "||", "\"\"", ")", "+", "\"&hid=\"", "+", "id", ";", "return", "(", "location", ".", "pathname", "||", "'/'", ")", "+", "search", "+", "(", "location", ".", "hash", "?", "(", "\"#\"", "+", "location", ".", "hash", ")", ":", "\"\"", ")", ";", "}" ]
produce href with hid in search part
[ "produce", "href", "with", "hid", "in", "search", "part" ]
d4e3514bf08982eb43aa0e1512294c767b8dea03
https://github.com/nomocas/min-history/blob/d4e3514bf08982eb43aa0e1512294c767b8dea03/lib/min-history.js#L120-L125
36,131
nomocas/min-history
lib/min-history.js
function(location) { if (!location.search) return; location.search = location.search.replace(/&hid=([^&]+)/gi, function(c, v) { location.hid = v; return ""; }); location.path = location.pathname + (location.search ? ("?" + location.search) : ""); location.relative = location.path + (location.hash ? ("#" + location.hash) : ""); location.href = location.protocol + "://" + location.host + location.relative; }
javascript
function(location) { if (!location.search) return; location.search = location.search.replace(/&hid=([^&]+)/gi, function(c, v) { location.hid = v; return ""; }); location.path = location.pathname + (location.search ? ("?" + location.search) : ""); location.relative = location.path + (location.hash ? ("#" + location.hash) : ""); location.href = location.protocol + "://" + location.host + location.relative; }
[ "function", "(", "location", ")", "{", "if", "(", "!", "location", ".", "search", ")", "return", ";", "location", ".", "search", "=", "location", ".", "search", ".", "replace", "(", "/", "&hid=([^&]+)", "/", "gi", ",", "function", "(", "c", ",", "v", ")", "{", "location", ".", "hid", "=", "v", ";", "return", "\"\"", ";", "}", ")", ";", "location", ".", "path", "=", "location", ".", "pathname", "+", "(", "location", ".", "search", "?", "(", "\"?\"", "+", "location", ".", "search", ")", ":", "\"\"", ")", ";", "location", ".", "relative", "=", "location", ".", "path", "+", "(", "location", ".", "hash", "?", "(", "\"#\"", "+", "location", ".", "hash", ")", ":", "\"\"", ")", ";", "location", ".", "href", "=", "location", ".", "protocol", "+", "\"://\"", "+", "location", ".", "host", "+", "location", ".", "relative", ";", "}" ]
remove hid from location parts. store hid in location.
[ "remove", "hid", "from", "location", "parts", ".", "store", "hid", "in", "location", "." ]
d4e3514bf08982eb43aa0e1512294c767b8dea03
https://github.com/nomocas/min-history/blob/d4e3514bf08982eb43aa0e1512294c767b8dea03/lib/min-history.js#L128-L138
36,132
caohanyang/json_diff_rfc6902
lib/deepEquals.js
_equals
function _equals(a, b) { switch (typeof a) { case 'undefined': case 'boolean': case 'string': case 'number': return a === b; case 'object': if (a === null) {return b === null;} if (_isArray(a)) { if (!_isArray(b) || a.length !== b.length) {return false;} for (var i = 0, l = a.length; i < l; i++) { if (!_equals(a[i], b[i])) {return false;} } return true; } var bKeys = _objectKeys(b); var bLength = bKeys.length; if (_objectKeys(a).length !== bLength) {return false;} for (var i = 0, k; i < bLength; i++) { k = bKeys[i]; if (!(k in a && _equals(a[k], b[k]))) {return false;} } return true; default: return false; } }
javascript
function _equals(a, b) { switch (typeof a) { case 'undefined': case 'boolean': case 'string': case 'number': return a === b; case 'object': if (a === null) {return b === null;} if (_isArray(a)) { if (!_isArray(b) || a.length !== b.length) {return false;} for (var i = 0, l = a.length; i < l; i++) { if (!_equals(a[i], b[i])) {return false;} } return true; } var bKeys = _objectKeys(b); var bLength = bKeys.length; if (_objectKeys(a).length !== bLength) {return false;} for (var i = 0, k; i < bLength; i++) { k = bKeys[i]; if (!(k in a && _equals(a[k], b[k]))) {return false;} } return true; default: return false; } }
[ "function", "_equals", "(", "a", ",", "b", ")", "{", "switch", "(", "typeof", "a", ")", "{", "case", "'undefined'", ":", "case", "'boolean'", ":", "case", "'string'", ":", "case", "'number'", ":", "return", "a", "===", "b", ";", "case", "'object'", ":", "if", "(", "a", "===", "null", ")", "{", "return", "b", "===", "null", ";", "}", "if", "(", "_isArray", "(", "a", ")", ")", "{", "if", "(", "!", "_isArray", "(", "b", ")", "||", "a", ".", "length", "!==", "b", ".", "length", ")", "{", "return", "false", ";", "}", "for", "(", "var", "i", "=", "0", ",", "l", "=", "a", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "!", "_equals", "(", "a", "[", "i", "]", ",", "b", "[", "i", "]", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "var", "bKeys", "=", "_objectKeys", "(", "b", ")", ";", "var", "bLength", "=", "bKeys", ".", "length", ";", "if", "(", "_objectKeys", "(", "a", ")", ".", "length", "!==", "bLength", ")", "{", "return", "false", ";", "}", "for", "(", "var", "i", "=", "0", ",", "k", ";", "i", "<", "bLength", ";", "i", "++", ")", "{", "k", "=", "bKeys", "[", "i", "]", ";", "if", "(", "!", "(", "k", "in", "a", "&&", "_equals", "(", "a", "[", "k", "]", ",", "b", "[", "k", "]", ")", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "default", ":", "return", "false", ";", "}", "}" ]
_equals - This can save a lot of time 5 ms @param {type} a description @param {type} b description @return {type} description
[ "_equals", "-", "This", "can", "save", "a", "lot", "of", "time", "5", "ms" ]
cb23e4adafb86156409c72790c593881f7685dc1
https://github.com/caohanyang/json_diff_rfc6902/blob/cb23e4adafb86156409c72790c593881f7685dc1/lib/deepEquals.js#L40-L78
36,133
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
function (prototype) { if (!_.isObject(prototype)) return {}; if (nativeCreate) return nativeCreate(prototype); Ctor.prototype = prototype; var result = new Ctor(); Ctor.prototype = null; return result; }
javascript
function (prototype) { if (!_.isObject(prototype)) return {}; if (nativeCreate) return nativeCreate(prototype); Ctor.prototype = prototype; var result = new Ctor(); Ctor.prototype = null; return result; }
[ "function", "(", "prototype", ")", "{", "if", "(", "!", "_", ".", "isObject", "(", "prototype", ")", ")", "return", "{", "}", ";", "if", "(", "nativeCreate", ")", "return", "nativeCreate", "(", "prototype", ")", ";", "Ctor", ".", "prototype", "=", "prototype", ";", "var", "result", "=", "new", "Ctor", "(", ")", ";", "Ctor", ".", "prototype", "=", "null", ";", "return", "result", ";", "}" ]
An internal function for creating a new object that inherits from another.
[ "An", "internal", "function", "for", "creating", "a", "new", "object", "that", "inherits", "from", "another", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L140-L147
36,134
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
omit
function omit(obj, blackList) { var newObj = {}; Object.keys(obj || {}).forEach(function (key) { if (blackList.indexOf(key) === -1) { newObj[key] = obj[key]; } }); return newObj; }
javascript
function omit(obj, blackList) { var newObj = {}; Object.keys(obj || {}).forEach(function (key) { if (blackList.indexOf(key) === -1) { newObj[key] = obj[key]; } }); return newObj; }
[ "function", "omit", "(", "obj", ",", "blackList", ")", "{", "var", "newObj", "=", "{", "}", ";", "Object", ".", "keys", "(", "obj", "||", "{", "}", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "blackList", ".", "indexOf", "(", "key", ")", "===", "-", "1", ")", "{", "newObj", "[", "key", "]", "=", "obj", "[", "key", "]", ";", "}", "}", ")", ";", "return", "newObj", ";", "}" ]
Return a copy of the object, filtered to omit the blacklisted array of keys.
[ "Return", "a", "copy", "of", "the", "object", "filtered", "to", "omit", "the", "blacklisted", "array", "of", "keys", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L5578-L5586
36,135
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
parseStartKey
function parseStartKey(key, restOfLine) { // When a new key is encountered, the rest of the line is immediately added as // its value, by calling `flushBuffer`. flushBuffer(); incrementArrayElement(key); if (stackScope && stackScope.flags.indexOf('+') > -1) key = 'value'; bufferKey = key; bufferString = restOfLine; flushBufferInto(key, { replace: true }); }
javascript
function parseStartKey(key, restOfLine) { // When a new key is encountered, the rest of the line is immediately added as // its value, by calling `flushBuffer`. flushBuffer(); incrementArrayElement(key); if (stackScope && stackScope.flags.indexOf('+') > -1) key = 'value'; bufferKey = key; bufferString = restOfLine; flushBufferInto(key, { replace: true }); }
[ "function", "parseStartKey", "(", "key", ",", "restOfLine", ")", "{", "// When a new key is encountered, the rest of the line is immediately added as", "// its value, by calling `flushBuffer`.", "flushBuffer", "(", ")", ";", "incrementArrayElement", "(", "key", ")", ";", "if", "(", "stackScope", "&&", "stackScope", ".", "flags", ".", "indexOf", "(", "'+'", ")", ">", "-", "1", ")", "key", "=", "'value'", ";", "bufferKey", "=", "key", ";", "bufferString", "=", "restOfLine", ";", "flushBufferInto", "(", "key", ",", "{", "replace", ":", "true", "}", ")", ";", "}" ]
The following parse functions add to the global `data` object and update scoping variables to keep track of what we're parsing.
[ "The", "following", "parse", "functions", "add", "to", "the", "global", "data", "object", "and", "update", "scoping", "variables", "to", "keep", "track", "of", "what", "we", "re", "parsing", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L5667-L5680
36,136
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
getParser
function getParser(delimiterOrParser) { var parser; if (typeof delimiterOrParser === 'string') { parser = discernParser(delimiterOrParser, { delimiter: true }); } else if (typeof delimiterOrParser === 'function' || (typeof delimiterOrParser === 'undefined' ? 'undefined' : _typeof(delimiterOrParser)) === 'object') { parser = delimiterOrParser; } return parser; }
javascript
function getParser(delimiterOrParser) { var parser; if (typeof delimiterOrParser === 'string') { parser = discernParser(delimiterOrParser, { delimiter: true }); } else if (typeof delimiterOrParser === 'function' || (typeof delimiterOrParser === 'undefined' ? 'undefined' : _typeof(delimiterOrParser)) === 'object') { parser = delimiterOrParser; } return parser; }
[ "function", "getParser", "(", "delimiterOrParser", ")", "{", "var", "parser", ";", "if", "(", "typeof", "delimiterOrParser", "===", "'string'", ")", "{", "parser", "=", "discernParser", "(", "delimiterOrParser", ",", "{", "delimiter", ":", "true", "}", ")", ";", "}", "else", "if", "(", "typeof", "delimiterOrParser", "===", "'function'", "||", "(", "typeof", "delimiterOrParser", "===", "'undefined'", "?", "'undefined'", ":", "_typeof", "(", "delimiterOrParser", ")", ")", "===", "'object'", ")", "{", "parser", "=", "delimiterOrParser", ";", "}", "return", "parser", ";", "}" ]
Our `readData` fns can take either a delimiter to parse a file, or a full blown parser Determine what they passed in with this handy function
[ "Our", "readData", "fns", "can", "take", "either", "a", "delimiter", "to", "parse", "a", "file", "or", "a", "full", "blown", "parser", "Determine", "what", "they", "passed", "in", "with", "this", "handy", "function" ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L6098-L6106
36,137
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
formattingPreflight
function formattingPreflight(file, format) { if (file === '') { return []; } else if (!Array.isArray(file)) { notListError(format); } return file; }
javascript
function formattingPreflight(file, format) { if (file === '') { return []; } else if (!Array.isArray(file)) { notListError(format); } return file; }
[ "function", "formattingPreflight", "(", "file", ",", "format", ")", "{", "if", "(", "file", "===", "''", ")", "{", "return", "[", "]", ";", "}", "else", "if", "(", "!", "Array", ".", "isArray", "(", "file", ")", ")", "{", "notListError", "(", "format", ")", ";", "}", "return", "file", ";", "}" ]
Some shared data integrity checks for formatters
[ "Some", "shared", "data", "integrity", "checks", "for", "formatters" ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L6603-L6610
36,138
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readDbf
function readDbf(filePath, opts_, cb) { var parserOptions = { map: identity }; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, parserOptions, cb); }
javascript
function readDbf(filePath, opts_, cb) { var parserOptions = { map: identity }; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, parserOptions, cb); }
[ "function", "readDbf", "(", "filePath", ",", "opts_", ",", "cb", ")", "{", "var", "parserOptions", "=", "{", "map", ":", "identity", "}", ";", "if", "(", "typeof", "cb", "===", "'undefined'", ")", "{", "cb", "=", "opts_", ";", "}", "else", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "readData", "(", "filePath", ",", "parserOptions", ",", "cb", ")", ";", "}" ]
Asynchronously read a dbf file. Returns an empty array if file is empty. @function readDbf @param {String} filePath Input file path @param {Function|Object} [map] Optional map function or an object with `map` key that is a function. Called once for each row with the signature `(row, i)` and must return the transformed row. See example below. @param {Function} callback Has signature `(err, data)` @example io.readDbf('path/to/data.dbf', function (err, data) { console.log(data) // Json data }) // Transform values on load io.readDbf('path/to/data.csv', function (row, i) { console.log(columns) // [ 'name', 'occupation', 'height' ] row.height = +row.height // Convert this value to a number return row }, function (err, data) { console.log(data) // Converted json data })
[ "Asynchronously", "read", "a", "dbf", "file", ".", "Returns", "an", "empty", "array", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L7247-L7257
36,139
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readdirFilter
function readdirFilter(dirPath, opts_, cb) { if (typeof cb === 'undefined') { cb = opts_; opts_ = undefined; } readdir({ async: true }, dirPath, opts_, cb); }
javascript
function readdirFilter(dirPath, opts_, cb) { if (typeof cb === 'undefined') { cb = opts_; opts_ = undefined; } readdir({ async: true }, dirPath, opts_, cb); }
[ "function", "readdirFilter", "(", "dirPath", ",", "opts_", ",", "cb", ")", "{", "if", "(", "typeof", "cb", "===", "'undefined'", ")", "{", "cb", "=", "opts_", ";", "opts_", "=", "undefined", ";", "}", "readdir", "(", "{", "async", ":", "true", "}", ",", "dirPath", ",", "opts_", ",", "cb", ")", ";", "}" ]
Asynchronously get a list of a directory's files and folders if certain critera are met. @function readdirFilter @param {String} dirPath The directory to read from @param {Object} options Filter options, see below @param {Boolean} [options.fullPath=false] If `true`, return the full path of the file, otherwise just return the file name. @param {Boolean} [options.detailed=false] If `true`, return an object like `{basePath: 'path/to', fileName: 'file.csv'}`. Whether `basePath` has a trailing will follow what you give to `dirPath`, which can take either. @param {Boolean} [options.skipFiles=false] If `true`, omit files from results. @param {Boolean} [options.skipDirs=false] If `true`, omit directories from results. @param {Boolean} [options.skipHidden=false] If `true`, omit files that start with a dot from results. Shorthand for `{exclude: /^\./}`. @param {String|RegExp|Array<String|RegExp>} options.include If given a string, return files that have that string as their extension. If given a Regular Expression, return the files whose name matches the pattern. Can also take a list of either type. List matching behavior is described in `includeMatchAll`. @param {String|RegExp|Array<String|RegExp>} options.exclude If given a string, return files that do not have that string as their extension. If given a Regular Expression, omit files whose name matches the pattern. Can also take a list of either type. List matching behavior is described in `excludeMatchAll`. @param {Boolean} [options.includeMatchAll=false] If true, require all include conditions to be met for a file to be included. @param {Boolean} [options.excludeMatchAll=false] If true, require all exclude conditions to be met for a file to be excluded. @param {Function} callback Has signature `(err, data)` where `files` is a list of matching file names. @example // dir contains `data-0.tsv`, `data-0.json`, `data-0.csv`, `data-1.csv`, `.hidden-file` io.readdirFilter('path/to/files', {include: 'csv'}, function(err, files){ console.log(files) // ['data-0.csv', 'data-1.csv'] }) io.readdirFilter('path/to/files', {include: [/^data/], exclude: ['csv', 'json']}, , function(err, files){ console.log(files) // ['path/to/files/data-0.csv', 'path/to/files/data-1.csv', 'path/to/files/data-0.tsv'] })
[ "Asynchronously", "get", "a", "list", "of", "a", "directory", "s", "files", "and", "folders", "if", "certain", "critera", "are", "met", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L7978-L7985
36,140
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readAml
function readAml(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserAml, parserOptions: parserOptions }, cb); }
javascript
function readAml(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserAml, parserOptions: parserOptions }, cb); }
[ "function", "readAml", "(", "filePath", ",", "opts_", ",", "cb", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "cb", "===", "'undefined'", ")", "{", "cb", "=", "opts_", ";", "}", "else", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "readData", "(", "filePath", ",", "{", "parser", ":", "parserAml", ",", "parserOptions", ":", "parserOptions", "}", ",", "cb", ")", ";", "}" ]
Asynchronously read an ArchieMl file. Returns an empty object if file is empty. @function readAml @param {String} filePath Input file path @param {Function|Object} [map] Optional map function or an object with `map` key that is a function. Takes the parsed file (usually an object) and must return the modified file. See example below. @param {Function} callback Has signature `(err, data)` @example io.readAml('path/to/data.aml', function (err, data) { console.log(data) // json data }) // With map io.readAml('path/to/data.aml', function (amlFile) { amlFile.height = amlFile.height * 2 return amlFile }, function (err, data) { console.log(data) // json data with height multiplied by 2 })
[ "Asynchronously", "read", "an", "ArchieMl", "file", ".", "Returns", "an", "empty", "object", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8041-L8049
36,141
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readAmlSync
function readAmlSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserAml, parserOptions: parserOptions }); }
javascript
function readAmlSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserAml, parserOptions: parserOptions }); }
[ "function", "readAmlSync", "(", "filePath", ",", "opts_", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "opts_", "!==", "'undefined'", ")", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "return", "readDataSync", "(", "filePath", ",", "{", "parser", ":", "parserAml", ",", "parserOptions", ":", "parserOptions", "}", ")", ";", "}" ]
Synchronously read an ArchieML file. Returns an empty object if file is empty. @function readAmlSync @param {String} filePath Input file path @param {Function} [map] Optional map function. Takes the parsed file (usually an object) and must return the modified file. See example below. @returns {Object} The parsed file @example var data = io.readAmlSync('path/to/data.aml') console.log(data) // json data var data = io.readAmlSync('path/to/data-with-comments.aml', function (amlFile) { amlFile.height = amlFile.height * 2 return amlFile }) console.log(data) // json data with height multiplied by 2
[ "Synchronously", "read", "an", "ArchieML", "file", ".", "Returns", "an", "empty", "object", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8069-L8075
36,142
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readCsv
function readCsv(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserCsv, parserOptions: parserOptions }, cb); }
javascript
function readCsv(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserCsv, parserOptions: parserOptions }, cb); }
[ "function", "readCsv", "(", "filePath", ",", "opts_", ",", "cb", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "cb", "===", "'undefined'", ")", "{", "cb", "=", "opts_", ";", "}", "else", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "readData", "(", "filePath", ",", "{", "parser", ":", "parserCsv", ",", "parserOptions", ":", "parserOptions", "}", ",", "cb", ")", ";", "}" ]
Asynchronously read a comma-separated value file. Returns an empty array if file is empty. @function readCsv @param {String} filePath Input file path @param {Function|Object} [map] Optional map function or an object with `map` key that is a function. Called once for each row with the signature `(row, i)` and must return the transformed row. See example below or d3-dsv documentation for details. @param {Function} callback Has signature `(err, data)` @example io.readCsv('path/to/data.csv', function (err, data) { console.log(data) // Json data }) // Transform values on load io.readCsv('path/to/data.csv', function (row, i, columns) { console.log(columns) // [ 'name', 'occupation', 'height' ] row.height = +row.height // Convert this value to a number return row }, function (err, data) { console.log(data) // Converted json data }) // Pass in an object with a `map` key io.readCsv('path/to/data.csv', {map: function (row, i, columns) { console.log(columns) // [ 'name', 'occupation', 'height' ] row.height = +row.height // Convert this value to a number return row }}, function (err, data) { console.log(data) // Converted json data })
[ "Asynchronously", "read", "a", "comma", "-", "separated", "value", "file", ".", "Returns", "an", "empty", "array", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8108-L8116
36,143
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readCsvSync
function readCsvSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserCsv, parserOptions: parserOptions }); }
javascript
function readCsvSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserCsv, parserOptions: parserOptions }); }
[ "function", "readCsvSync", "(", "filePath", ",", "opts_", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "opts_", "!==", "'undefined'", ")", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "return", "readDataSync", "(", "filePath", ",", "{", "parser", ":", "parserCsv", ",", "parserOptions", ":", "parserOptions", "}", ")", ";", "}" ]
Synchronously read a comma-separated value file. Returns an empty array if file is empty. @function readCsvSync @param {String} filePath Input file path @param {Function|Object} [map] Optional map function or an object with `map` key that is a function. Called once for each row with the signature `(row, i)` and must return the transformed row. See example below or d3-dsv documentation for details. @returns {Array} the contents of the file as JSON @example var data = io.readCsvSync('path/to/data.csv') console.log(data) // Json data // Transform values on load var data = io.readCsvSync('path/to/data.csv', function (row, i, columns) { console.log(columns) // [ 'name', 'occupation', 'height' ] row.height = +row.height // Convert this value to a number return row }) console.log(data) // Json data with casted values // Pass in an object with a `map` key var data = io.readCsvSync('path/to/data.csv', {map: function (row, i, columns) { console.log(columns) // [ 'name', 'occupation', 'height' ] row.height = +row.height // Convert this value to a number return row }}) console.log(data) // Json data with casted values
[ "Synchronously", "read", "a", "comma", "-", "separated", "value", "file", ".", "Returns", "an", "empty", "array", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8146-L8152
36,144
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readJson
function readJson(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserJson, parserOptions: parserOptions }, cb); }
javascript
function readJson(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserJson, parserOptions: parserOptions }, cb); }
[ "function", "readJson", "(", "filePath", ",", "opts_", ",", "cb", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "cb", "===", "'undefined'", ")", "{", "cb", "=", "opts_", ";", "}", "else", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "readData", "(", "filePath", ",", "{", "parser", ":", "parserJson", ",", "parserOptions", ":", "parserOptions", "}", ",", "cb", ")", ";", "}" ]
Asynchronously read a JSON file. Returns an empty array if file is empty. @function readJson @param {String} filePath Input file path @param {Function|Object} [parserOptions] Optional map function or an object specifying the optional options below. @param {Function} [parserOptions.map] Map function. Called once for each row if your file is an array (it tests if the first non-whitespace character is a `[`) with a callback signature `(row, i)` and delegates to `_.map`. Otherwise it's considered an object and the callback the signature is `(value, key)` and delegates to `_.mapObject`. See example below. @param {String} [parserOptions.filename] File name displayed in the error message. @param {Function} [parserOptions.reviver] A function that prescribes how the value originally produced by parsing is mapped before being returned. See JSON.parse docs for more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter @param {Function} callback Has signature `(err, data)` @example io.readJson('path/to/data.json', function (err, data) { console.log(data) // Json data }) // Specify a map io.readJson('path/to/data.json', function (row, i) { row.height = row.height * 2 return row }, function (err, data) { console.log(data) // Json data with height multiplied by two }) // Specify a filename io.readJson('path/to/data.json', 'awesome-data.json', function (err, data) { console.log(data) // Json data, any errors are reported with `fileName`. }) // Specify a map and a filename io.readJson('path/to/data.json', { map: function (row, i) { row.height = row.height * 2 return row }, filename: 'awesome-data.json' }, function (err, data) { console.log(data) // Json data with any number values multiplied by two and errors reported with `fileName` }) // Specify a map and a filename on json object io.readJson('path/to/json-object.json', { map: function (value, key) { if (typeof value === 'number') { return value * 2 } return value }, filename: 'awesome-data.json' }, function (err, data) { console.log(data) // Json data with any number values multiplied by two and errors reported with `fileName` }) // Specify a reviver function and a filename io.readJson('path/to/data.json', { reviver: function (k, v) { if (typeof v === 'number') { return v * 2 } return v }, filename: 'awesome-data.json' }, function (err, data) { console.log(data) // Json data with any number values multiplied by two and errors reported with `fileName` })
[ "Asynchronously", "read", "a", "JSON", "file", ".", "Returns", "an", "empty", "array", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8220-L8228
36,145
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readJsonSync
function readJsonSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserJson, parserOptions: parserOptions }); }
javascript
function readJsonSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserJson, parserOptions: parserOptions }); }
[ "function", "readJsonSync", "(", "filePath", ",", "opts_", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "opts_", "!==", "'undefined'", ")", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "return", "readDataSync", "(", "filePath", ",", "{", "parser", ":", "parserJson", ",", "parserOptions", ":", "parserOptions", "}", ")", ";", "}" ]
Synchronously read a JSON file. Returns an empty array if file is empty. @function readJsonSync @param {String} filePath Input file path @param {Function|Object} [parserOptions] Optional map function or an object specifying the optional options below. @param {Function} [parserOptions.map] Map function. Called once for each row if your file is an array (it tests if the first non-whitespace character is a `[`) with a callback signature `(row, i)` and delegates to `_.map`. Otherwise it's considered an object and the callback the signature is `(value, key)` and delegates to `_.mapObject`. See example below. @param {String} [parserOptions.filename] File name displayed in the error message. @param {Function} [parserOptions.reviver] A function that prescribes how the value originally produced by parsing is mapped before being returned. See JSON.parse docs for more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter @returns {Array|Object} The contents of the file as JSON @example var data = io.readJsonSync('path/to/data.json') console.log(data) // Json data // Specify a map var data = io.readJson('path/to/data.json', function (k, v) { if (typeof v === 'number') { return v * 2 } return v }) console.log(data) // Json data with any number values multiplied by two // Specify a filename var data = io.readJson('path/to/data.json', 'awesome-data.json') console.log(data) // Json data, any errors are reported with `fileName`. // Specify a map and a filename var data = io.readJsonSync('path/to/data.json', { map: function (k, v) { if (typeof v === 'number') { return v * 2 } return v }, filename: 'awesome-data.json' }) console.log(data) // Json data with any number values multiplied by two and errors reported with `fileName`
[ "Synchronously", "read", "a", "JSON", "file", ".", "Returns", "an", "empty", "array", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8271-L8277
36,146
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readPsv
function readPsv(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserPsv, parserOptions: parserOptions }, cb); }
javascript
function readPsv(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserPsv, parserOptions: parserOptions }, cb); }
[ "function", "readPsv", "(", "filePath", ",", "opts_", ",", "cb", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "cb", "===", "'undefined'", ")", "{", "cb", "=", "opts_", ";", "}", "else", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "readData", "(", "filePath", ",", "{", "parser", ":", "parserPsv", ",", "parserOptions", ":", "parserOptions", "}", ",", "cb", ")", ";", "}" ]
Asynchronously read a pipe-separated value file. Returns an empty array if file is empty. @function readPsv @param {String} filePath Input file path @param {Function|Object} [map] Optional map function or an object with `map` key that is a function. Called once for each row with the signature `(row, i)` and must return the transformed row. See example below or d3-dsv documentation for details. @param {Function} callback Has signature `(err, data)` @example io.readPsv('path/to/data.psv', function (err, data) { console.log(data) // Json data }) // Transform values on load io.readPsv('path/to/data.psv', function (row, i, columns) { console.log(columns) // [ 'name', 'occupation', 'height' ] row.height = +row.height // Convert this value to a number return row }, function (err, data) { console.log(data) // Json data with casted values })
[ "Asynchronously", "read", "a", "pipe", "-", "separated", "value", "file", ".", "Returns", "an", "empty", "array", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8301-L8309
36,147
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readPsvSync
function readPsvSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserPsv, parserOptions: parserOptions }); }
javascript
function readPsvSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserPsv, parserOptions: parserOptions }); }
[ "function", "readPsvSync", "(", "filePath", ",", "opts_", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "opts_", "!==", "'undefined'", ")", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "return", "readDataSync", "(", "filePath", ",", "{", "parser", ":", "parserPsv", ",", "parserOptions", ":", "parserOptions", "}", ")", ";", "}" ]
Synchronously read a pipe-separated value file. Returns an empty array if file is empty. @function readPsvSync @param {String} filePath Input file path @param {Function|Object} [map] Optional map function or an object with `map` key that is a function. Called once for each row with the signature `(row, i)` and must return the transformed row. See example below or d3-dsv documentation for details. @returns {Array} The contents of the file as JSON @example var data = io.readPsvSync('path/to/data.psv') console.log(data) // Json data var data = io.readPsvSync('path/to/data.psv', function (row, i, columns) { console.log(columns) // [ 'name', 'occupation', 'height' ] row.height = +row.height // Convert this value to a number return row }) console.log(data) // Json data with casted values
[ "Synchronously", "read", "a", "pipe", "-", "separated", "value", "file", ".", "Returns", "an", "empty", "array", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8330-L8336
36,148
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readTsv
function readTsv(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserTsv, parserOptions: parserOptions }, cb); }
javascript
function readTsv(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserTsv, parserOptions: parserOptions }, cb); }
[ "function", "readTsv", "(", "filePath", ",", "opts_", ",", "cb", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "cb", "===", "'undefined'", ")", "{", "cb", "=", "opts_", ";", "}", "else", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "readData", "(", "filePath", ",", "{", "parser", ":", "parserTsv", ",", "parserOptions", ":", "parserOptions", "}", ",", "cb", ")", ";", "}" ]
Asynchronously read a tab-separated value file. Returns an empty array if file is empty. @function readTsv @param {String} filePath Input file path @param {Function|Object} [map] Optional map function or an object with `map` key that is a function. Called once for each row with the signature `(row, i)` and must return the transformed row. See example below or d3-dsv documentation for details. @param {Function} callback Has signature `(err, data)` @example io.readTsv('path/to/data.tsv', function (err, data) { console.log(data) // Json data }) // Transform values on load io.readTsv('path/to/data.tsv', function (row, i, columns) { console.log(columns) // [ 'name', 'occupation', 'height' ] row.height = +row.height // Convert this value to a number return row }, function (err, data) { console.log(data) // Json data with casted values })
[ "Asynchronously", "read", "a", "tab", "-", "separated", "value", "file", ".", "Returns", "an", "empty", "array", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8360-L8368
36,149
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readTsvSync
function readTsvSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserTsv, parserOptions: parserOptions }); }
javascript
function readTsvSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserTsv, parserOptions: parserOptions }); }
[ "function", "readTsvSync", "(", "filePath", ",", "opts_", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "opts_", "!==", "'undefined'", ")", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "return", "readDataSync", "(", "filePath", ",", "{", "parser", ":", "parserTsv", ",", "parserOptions", ":", "parserOptions", "}", ")", ";", "}" ]
Synchronously read a tab-separated value file. Returns an empty array if file is empty. @function readTsvSync @param {String} filePath Input file path @param {Function} [map] Optional map function, called once for each row (header row skipped). Has signature `(row, i, columns)` and must return the transformed row. See example below or d3-dsv documentation for details. @returns {Array} the contents of the file as JSON @example var data = io.readTsvSync('path/to/data.tsv') console.log(data) // Json data // Transform values on load var data = io.readTsvSync('path/to/data.tsv', function (row, i, columns) { console.log(columns) // [ 'name', 'occupation', 'height' ] row.height = +row.height // Convert this value to a number return row }) console.log(data) // Json data with casted values
[ "Synchronously", "read", "a", "tab", "-", "separated", "value", "file", ".", "Returns", "an", "empty", "array", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8390-L8396
36,150
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readTxt
function readTxt(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserTxt, parserOptions: parserOptions }, cb); }
javascript
function readTxt(filePath, opts_, cb) { var parserOptions; if (typeof cb === 'undefined') { cb = opts_; } else { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } readData(filePath, { parser: parserTxt, parserOptions: parserOptions }, cb); }
[ "function", "readTxt", "(", "filePath", ",", "opts_", ",", "cb", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "cb", "===", "'undefined'", ")", "{", "cb", "=", "opts_", ";", "}", "else", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "readData", "(", "filePath", ",", "{", "parser", ":", "parserTxt", ",", "parserOptions", ":", "parserOptions", "}", ",", "cb", ")", ";", "}" ]
Asynchronously read a text file. Returns an empty string if file is empty. @function readTxt @param {String} filePath Input file path @param {Function|Object} [map] Optional map function or an object with `map` key that is a function. Takes the file read in as text and return the modified file. See example below. @param {Function} callback Has signature `(err, data)` @example io.readTxt('path/to/data.txt', function (err, data) { console.log(data) // string data }) io.readTxt('path/to/data.txt', function (str) { return str.replace(/hello/g, 'goodbye') // Replace all instances of `"hello"` with `"goodbye"` }, function (err, data) { console.log(data) // string data with values replaced })
[ "Asynchronously", "read", "a", "text", "file", ".", "Returns", "an", "empty", "string", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8417-L8425
36,151
mhkeller/indian-ocean
dist/indian-ocean.cjs.js
readTxtSync
function readTxtSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserTxt, parserOptions: parserOptions }); }
javascript
function readTxtSync(filePath, opts_) { var parserOptions; if (typeof opts_ !== 'undefined') { parserOptions = typeof opts_ === 'function' ? { map: opts_ } : opts_; } return readDataSync(filePath, { parser: parserTxt, parserOptions: parserOptions }); }
[ "function", "readTxtSync", "(", "filePath", ",", "opts_", ")", "{", "var", "parserOptions", ";", "if", "(", "typeof", "opts_", "!==", "'undefined'", ")", "{", "parserOptions", "=", "typeof", "opts_", "===", "'function'", "?", "{", "map", ":", "opts_", "}", ":", "opts_", ";", "}", "return", "readDataSync", "(", "filePath", ",", "{", "parser", ":", "parserTxt", ",", "parserOptions", ":", "parserOptions", "}", ")", ";", "}" ]
Synchronously read a text file. Returns an empty string if file is empty. @function readTxtSync @param {String} filePath Input file path @param {Function|Object} [map] Optional map function or an object with `map` key that is a function. Takes the file read in as text and must return the modified file. See example below. @returns {String} the contents of the file as a string @example var data = io.readTxtSync('path/to/data.txt') console.log(data) // string data var data = io.readTxtSync('path/to/data.txt', function (str) { return str.replace(/hello/g, 'goodbye') // Replace all instances of `"hello"` with `"goodbye"` }) console.log(data) // string data with values replaced
[ "Synchronously", "read", "a", "text", "file", ".", "Returns", "an", "empty", "string", "if", "file", "is", "empty", "." ]
32b5b5799341370452b17ec2ac18529c849f3916
https://github.com/mhkeller/indian-ocean/blob/32b5b5799341370452b17ec2ac18529c849f3916/dist/indian-ocean.cjs.js#L8444-L8450
36,152
ascartabelli/lamb
src/privates/_getInsertionIndex.js
_getInsertionIndex
function _getInsertionIndex (array, element, comparer, start, end) { if (array.length === 0) { return 0; } var pivot = (start + end) >> 1; var result = comparer( { value: element, index: pivot }, { value: array[pivot], index: pivot } ); if (end - start <= 1) { return result < 0 ? pivot : pivot + 1; } else if (result < 0) { return _getInsertionIndex(array, element, comparer, start, pivot); } else if (result === 0) { return pivot + 1; } else { return _getInsertionIndex(array, element, comparer, pivot, end); } }
javascript
function _getInsertionIndex (array, element, comparer, start, end) { if (array.length === 0) { return 0; } var pivot = (start + end) >> 1; var result = comparer( { value: element, index: pivot }, { value: array[pivot], index: pivot } ); if (end - start <= 1) { return result < 0 ? pivot : pivot + 1; } else if (result < 0) { return _getInsertionIndex(array, element, comparer, start, pivot); } else if (result === 0) { return pivot + 1; } else { return _getInsertionIndex(array, element, comparer, pivot, end); } }
[ "function", "_getInsertionIndex", "(", "array", ",", "element", ",", "comparer", ",", "start", ",", "end", ")", "{", "if", "(", "array", ".", "length", "===", "0", ")", "{", "return", "0", ";", "}", "var", "pivot", "=", "(", "start", "+", "end", ")", ">>", "1", ";", "var", "result", "=", "comparer", "(", "{", "value", ":", "element", ",", "index", ":", "pivot", "}", ",", "{", "value", ":", "array", "[", "pivot", "]", ",", "index", ":", "pivot", "}", ")", ";", "if", "(", "end", "-", "start", "<=", "1", ")", "{", "return", "result", "<", "0", "?", "pivot", ":", "pivot", "+", "1", ";", "}", "else", "if", "(", "result", "<", "0", ")", "{", "return", "_getInsertionIndex", "(", "array", ",", "element", ",", "comparer", ",", "start", ",", "pivot", ")", ";", "}", "else", "if", "(", "result", "===", "0", ")", "{", "return", "pivot", "+", "1", ";", "}", "else", "{", "return", "_getInsertionIndex", "(", "array", ",", "element", ",", "comparer", ",", "pivot", ",", "end", ")", ";", "}", "}" ]
Establishes at which index an element should be inserted in a sorted array to respect the array order. Needs the comparer used to sort the array. @private @param {Array} array @param {*} element @param {Function} comparer @param {Number} start @param {Number} end @returns {Number}
[ "Establishes", "at", "which", "index", "an", "element", "should", "be", "inserted", "in", "a", "sorted", "array", "to", "respect", "the", "array", "order", ".", "Needs", "the", "comparer", "used", "to", "sort", "the", "array", "." ]
d36e45945c4789e4f1a2d8805936514b53f32362
https://github.com/ascartabelli/lamb/blob/d36e45945c4789e4f1a2d8805936514b53f32362/src/privates/_getInsertionIndex.js#L12-L32
36,153
ascartabelli/lamb
src/privates/_getNumConsecutiveHits.js
_getNumConsecutiveHits
function _getNumConsecutiveHits (arrayLike, predicate) { var idx = 0; var len = arrayLike.length; while (idx < len && predicate(arrayLike[idx], idx, arrayLike)) { idx++; } return idx; }
javascript
function _getNumConsecutiveHits (arrayLike, predicate) { var idx = 0; var len = arrayLike.length; while (idx < len && predicate(arrayLike[idx], idx, arrayLike)) { idx++; } return idx; }
[ "function", "_getNumConsecutiveHits", "(", "arrayLike", ",", "predicate", ")", "{", "var", "idx", "=", "0", ";", "var", "len", "=", "arrayLike", ".", "length", ";", "while", "(", "idx", "<", "len", "&&", "predicate", "(", "arrayLike", "[", "idx", "]", ",", "idx", ",", "arrayLike", ")", ")", "{", "idx", "++", ";", "}", "return", "idx", ";", "}" ]
Gets the number of consecutive elements satisfying a predicate in an array-like object. @private @param {ArrayLike} arrayLike @param {ListIteratorCallback} predicate @returns {Number}
[ "Gets", "the", "number", "of", "consecutive", "elements", "satisfying", "a", "predicate", "in", "an", "array", "-", "like", "object", "." ]
d36e45945c4789e4f1a2d8805936514b53f32362
https://github.com/ascartabelli/lamb/blob/d36e45945c4789e4f1a2d8805936514b53f32362/src/privates/_getNumConsecutiveHits.js#L8-L17
36,154
AvrahamO/he-date
HeDate.js
function(src, dest) { var i = 0; var len = Math.min(src.length, dest.length); while(i < len) { dest[i] = src[i]; i++; } return dest; }
javascript
function(src, dest) { var i = 0; var len = Math.min(src.length, dest.length); while(i < len) { dest[i] = src[i]; i++; } return dest; }
[ "function", "(", "src", ",", "dest", ")", "{", "var", "i", "=", "0", ";", "var", "len", "=", "Math", ".", "min", "(", "src", ".", "length", ",", "dest", ".", "length", ")", ";", "while", "(", "i", "<", "len", ")", "{", "dest", "[", "i", "]", "=", "src", "[", "i", "]", ";", "i", "++", ";", "}", "return", "dest", ";", "}" ]
src - Array || Argument object dest - Array
[ "src", "-", "Array", "||", "Argument", "object", "dest", "-", "Array" ]
942049a4f39e3f57e44ed6f2bef1caa274e21b80
https://github.com/AvrahamO/he-date/blob/942049a4f39e3f57e44ed6f2bef1caa274e21b80/HeDate.js#L49-L57
36,155
AvrahamO/he-date
HeDate.js
function(month, year1, year2) { var leap1 = isLeap(year1 - 1); var leap2 = isLeap(year2 - 1); if(month < 5 + leap1) return 0; return leap2 - leap1; }
javascript
function(month, year1, year2) { var leap1 = isLeap(year1 - 1); var leap2 = isLeap(year2 - 1); if(month < 5 + leap1) return 0; return leap2 - leap1; }
[ "function", "(", "month", ",", "year1", ",", "year2", ")", "{", "var", "leap1", "=", "isLeap", "(", "year1", "-", "1", ")", ";", "var", "leap2", "=", "isLeap", "(", "year2", "-", "1", ")", ";", "if", "(", "month", "<", "5", "+", "leap1", ")", "return", "0", ";", "return", "leap2", "-", "leap1", ";", "}" ]
returns 0, 1 or -1
[ "returns", "0", "1", "or", "-", "1" ]
942049a4f39e3f57e44ed6f2bef1caa274e21b80
https://github.com/AvrahamO/he-date/blob/942049a4f39e3f57e44ed6f2bef1caa274e21b80/HeDate.js#L218-L224
36,156
ILLGrenoble/guacamole-common-js
src/Keyboard.js
function() { /** * Reference to this key event. */ var key_event = this; /** * An arbitrary timestamp in milliseconds, indicating this event's * position in time relative to other events. * * @type {Number} */ this.timestamp = new Date().getTime(); /** * Whether the default action of this key event should be prevented. * * @type {Boolean} */ this.defaultPrevented = false; /** * The keysym of the key associated with this key event, as determined * by a best-effort guess using available event properties and keyboard * state. * * @type {Number} */ this.keysym = null; /** * Whether the keysym value of this key event is known to be reliable. * If false, the keysym may still be valid, but it's only a best guess, * and future key events may be a better source of information. * * @type {Boolean} */ this.reliable = false; /** * Returns the number of milliseconds elapsed since this event was * received. * * @return {Number} The number of milliseconds elapsed since this * event was received. */ this.getAge = function() { return new Date().getTime() - key_event.timestamp; }; }
javascript
function() { /** * Reference to this key event. */ var key_event = this; /** * An arbitrary timestamp in milliseconds, indicating this event's * position in time relative to other events. * * @type {Number} */ this.timestamp = new Date().getTime(); /** * Whether the default action of this key event should be prevented. * * @type {Boolean} */ this.defaultPrevented = false; /** * The keysym of the key associated with this key event, as determined * by a best-effort guess using available event properties and keyboard * state. * * @type {Number} */ this.keysym = null; /** * Whether the keysym value of this key event is known to be reliable. * If false, the keysym may still be valid, but it's only a best guess, * and future key events may be a better source of information. * * @type {Boolean} */ this.reliable = false; /** * Returns the number of milliseconds elapsed since this event was * received. * * @return {Number} The number of milliseconds elapsed since this * event was received. */ this.getAge = function() { return new Date().getTime() - key_event.timestamp; }; }
[ "function", "(", ")", "{", "/**\n * Reference to this key event.\n */", "var", "key_event", "=", "this", ";", "/**\n * An arbitrary timestamp in milliseconds, indicating this event's\n * position in time relative to other events.\n *\n * @type {Number}\n */", "this", ".", "timestamp", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "/**\n * Whether the default action of this key event should be prevented.\n *\n * @type {Boolean}\n */", "this", ".", "defaultPrevented", "=", "false", ";", "/**\n * The keysym of the key associated with this key event, as determined\n * by a best-effort guess using available event properties and keyboard\n * state.\n *\n * @type {Number}\n */", "this", ".", "keysym", "=", "null", ";", "/**\n * Whether the keysym value of this key event is known to be reliable.\n * If false, the keysym may still be valid, but it's only a best guess,\n * and future key events may be a better source of information.\n *\n * @type {Boolean}\n */", "this", ".", "reliable", "=", "false", ";", "/**\n * Returns the number of milliseconds elapsed since this event was\n * received.\n *\n * @return {Number} The number of milliseconds elapsed since this\n * event was received.\n */", "this", ".", "getAge", "=", "function", "(", ")", "{", "return", "new", "Date", "(", ")", ".", "getTime", "(", ")", "-", "key_event", ".", "timestamp", ";", "}", ";", "}" ]
A key event having a corresponding timestamp. This event is non-specific. Its subclasses should be used instead when recording specific key events. @private @constructor
[ "A", "key", "event", "having", "a", "corresponding", "timestamp", ".", "This", "event", "is", "non", "-", "specific", ".", "Its", "subclasses", "should", "be", "used", "instead", "when", "recording", "specific", "key", "events", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Keyboard.js#L66-L117
36,157
ILLGrenoble/guacamole-common-js
src/Keyboard.js
function(charCode) { // We extend KeyEvent KeyEvent.apply(this); /** * The Unicode codepoint of the character that would be typed by the * key pressed. * * @type {Number} */ this.charCode = charCode; // Pull keysym from char code this.keysym = keysym_from_charcode(charCode); // Keypress is always reliable this.reliable = true; }
javascript
function(charCode) { // We extend KeyEvent KeyEvent.apply(this); /** * The Unicode codepoint of the character that would be typed by the * key pressed. * * @type {Number} */ this.charCode = charCode; // Pull keysym from char code this.keysym = keysym_from_charcode(charCode); // Keypress is always reliable this.reliable = true; }
[ "function", "(", "charCode", ")", "{", "// We extend KeyEvent", "KeyEvent", ".", "apply", "(", "this", ")", ";", "/**\n * The Unicode codepoint of the character that would be typed by the\n * key pressed.\n *\n * @type {Number}\n */", "this", ".", "charCode", "=", "charCode", ";", "// Pull keysym from char code", "this", ".", "keysym", "=", "keysym_from_charcode", "(", "charCode", ")", ";", "// Keypress is always reliable", "this", ".", "reliable", "=", "true", ";", "}" ]
Information related to the pressing of a key, which MUST be associated with a printable character. The presence or absence of any information within this object is browser-dependent. @private @constructor @augments Guacamole.Keyboard.KeyEvent @param {Number} charCode The Unicode codepoint of the character that would be typed by the key pressed.
[ "Information", "related", "to", "the", "pressing", "of", "a", "key", "which", "MUST", "be", "associated", "with", "a", "printable", "character", ".", "The", "presence", "or", "absence", "of", "any", "information", "within", "this", "object", "is", "browser", "-", "dependent", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Keyboard.js#L220-L239
36,158
ILLGrenoble/guacamole-common-js
src/Keyboard.js
update_modifier_state
function update_modifier_state(e) { // Get state var state = Guacamole.Keyboard.ModifierState.fromKeyboardEvent(e); // Release alt if implicitly released if (guac_keyboard.modifiers.alt && state.alt === false) { guac_keyboard.release(0xFFE9); // Left alt guac_keyboard.release(0xFFEA); // Right alt guac_keyboard.release(0xFE03); // AltGr } // Release shift if implicitly released if (guac_keyboard.modifiers.shift && state.shift === false) { guac_keyboard.release(0xFFE1); // Left shift guac_keyboard.release(0xFFE2); // Right shift } // Release ctrl if implicitly released if (guac_keyboard.modifiers.ctrl && state.ctrl === false) { guac_keyboard.release(0xFFE3); // Left ctrl guac_keyboard.release(0xFFE4); // Right ctrl } // Release meta if implicitly released if (guac_keyboard.modifiers.meta && state.meta === false) { guac_keyboard.release(0xFFE7); // Left meta guac_keyboard.release(0xFFE8); // Right meta } // Release hyper if implicitly released if (guac_keyboard.modifiers.hyper && state.hyper === false) { guac_keyboard.release(0xFFEB); // Left hyper guac_keyboard.release(0xFFEC); // Right hyper } // Update state guac_keyboard.modifiers = state; }
javascript
function update_modifier_state(e) { // Get state var state = Guacamole.Keyboard.ModifierState.fromKeyboardEvent(e); // Release alt if implicitly released if (guac_keyboard.modifiers.alt && state.alt === false) { guac_keyboard.release(0xFFE9); // Left alt guac_keyboard.release(0xFFEA); // Right alt guac_keyboard.release(0xFE03); // AltGr } // Release shift if implicitly released if (guac_keyboard.modifiers.shift && state.shift === false) { guac_keyboard.release(0xFFE1); // Left shift guac_keyboard.release(0xFFE2); // Right shift } // Release ctrl if implicitly released if (guac_keyboard.modifiers.ctrl && state.ctrl === false) { guac_keyboard.release(0xFFE3); // Left ctrl guac_keyboard.release(0xFFE4); // Right ctrl } // Release meta if implicitly released if (guac_keyboard.modifiers.meta && state.meta === false) { guac_keyboard.release(0xFFE7); // Left meta guac_keyboard.release(0xFFE8); // Right meta } // Release hyper if implicitly released if (guac_keyboard.modifiers.hyper && state.hyper === false) { guac_keyboard.release(0xFFEB); // Left hyper guac_keyboard.release(0xFFEC); // Right hyper } // Update state guac_keyboard.modifiers = state; }
[ "function", "update_modifier_state", "(", "e", ")", "{", "// Get state", "var", "state", "=", "Guacamole", ".", "Keyboard", ".", "ModifierState", ".", "fromKeyboardEvent", "(", "e", ")", ";", "// Release alt if implicitly released", "if", "(", "guac_keyboard", ".", "modifiers", ".", "alt", "&&", "state", ".", "alt", "===", "false", ")", "{", "guac_keyboard", ".", "release", "(", "0xFFE9", ")", ";", "// Left alt", "guac_keyboard", ".", "release", "(", "0xFFEA", ")", ";", "// Right alt", "guac_keyboard", ".", "release", "(", "0xFE03", ")", ";", "// AltGr", "}", "// Release shift if implicitly released", "if", "(", "guac_keyboard", ".", "modifiers", ".", "shift", "&&", "state", ".", "shift", "===", "false", ")", "{", "guac_keyboard", ".", "release", "(", "0xFFE1", ")", ";", "// Left shift", "guac_keyboard", ".", "release", "(", "0xFFE2", ")", ";", "// Right shift", "}", "// Release ctrl if implicitly released", "if", "(", "guac_keyboard", ".", "modifiers", ".", "ctrl", "&&", "state", ".", "ctrl", "===", "false", ")", "{", "guac_keyboard", ".", "release", "(", "0xFFE3", ")", ";", "// Left ctrl ", "guac_keyboard", ".", "release", "(", "0xFFE4", ")", ";", "// Right ctrl ", "}", "// Release meta if implicitly released", "if", "(", "guac_keyboard", ".", "modifiers", ".", "meta", "&&", "state", ".", "meta", "===", "false", ")", "{", "guac_keyboard", ".", "release", "(", "0xFFE7", ")", ";", "// Left meta ", "guac_keyboard", ".", "release", "(", "0xFFE8", ")", ";", "// Right meta ", "}", "// Release hyper if implicitly released", "if", "(", "guac_keyboard", ".", "modifiers", ".", "hyper", "&&", "state", ".", "hyper", "===", "false", ")", "{", "guac_keyboard", ".", "release", "(", "0xFFEB", ")", ";", "// Left hyper", "guac_keyboard", ".", "release", "(", "0xFFEC", ")", ";", "// Right hyper", "}", "// Update state", "guac_keyboard", ".", "modifiers", "=", "state", ";", "}" ]
Given a keyboard event, updates the local modifier state and remote key state based on the modifier flags within the event. This function pays no attention to keycodes. @private @param {KeyboardEvent} e The keyboard event containing the flags to update.
[ "Given", "a", "keyboard", "event", "updates", "the", "local", "modifier", "state", "and", "remote", "key", "state", "based", "on", "the", "modifier", "flags", "within", "the", "event", ".", "This", "function", "pays", "no", "attention", "to", "keycodes", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Keyboard.js#L811-L850
36,159
ILLGrenoble/guacamole-common-js
src/Keyboard.js
release_simulated_altgr
function release_simulated_altgr(keysym) { // Both Ctrl+Alt must be pressed if simulated AltGr is in use if (!guac_keyboard.modifiers.ctrl || !guac_keyboard.modifiers.alt) return; // Assume [A-Z] never require AltGr if (keysym >= 0x0041 && keysym <= 0x005A) return; // Assume [a-z] never require AltGr if (keysym >= 0x0061 && keysym <= 0x007A) return; // Release Ctrl+Alt if the keysym is printable if (keysym <= 0xFF || (keysym & 0xFF000000) === 0x01000000) { guac_keyboard.release(0xFFE3); // Left ctrl guac_keyboard.release(0xFFE4); // Right ctrl guac_keyboard.release(0xFFE9); // Left alt guac_keyboard.release(0xFFEA); // Right alt } }
javascript
function release_simulated_altgr(keysym) { // Both Ctrl+Alt must be pressed if simulated AltGr is in use if (!guac_keyboard.modifiers.ctrl || !guac_keyboard.modifiers.alt) return; // Assume [A-Z] never require AltGr if (keysym >= 0x0041 && keysym <= 0x005A) return; // Assume [a-z] never require AltGr if (keysym >= 0x0061 && keysym <= 0x007A) return; // Release Ctrl+Alt if the keysym is printable if (keysym <= 0xFF || (keysym & 0xFF000000) === 0x01000000) { guac_keyboard.release(0xFFE3); // Left ctrl guac_keyboard.release(0xFFE4); // Right ctrl guac_keyboard.release(0xFFE9); // Left alt guac_keyboard.release(0xFFEA); // Right alt } }
[ "function", "release_simulated_altgr", "(", "keysym", ")", "{", "// Both Ctrl+Alt must be pressed if simulated AltGr is in use", "if", "(", "!", "guac_keyboard", ".", "modifiers", ".", "ctrl", "||", "!", "guac_keyboard", ".", "modifiers", ".", "alt", ")", "return", ";", "// Assume [A-Z] never require AltGr", "if", "(", "keysym", ">=", "0x0041", "&&", "keysym", "<=", "0x005A", ")", "return", ";", "// Assume [a-z] never require AltGr", "if", "(", "keysym", ">=", "0x0061", "&&", "keysym", "<=", "0x007A", ")", "return", ";", "// Release Ctrl+Alt if the keysym is printable", "if", "(", "keysym", "<=", "0xFF", "||", "(", "keysym", "&", "0xFF000000", ")", "===", "0x01000000", ")", "{", "guac_keyboard", ".", "release", "(", "0xFFE3", ")", ";", "// Left ctrl ", "guac_keyboard", ".", "release", "(", "0xFFE4", ")", ";", "// Right ctrl ", "guac_keyboard", ".", "release", "(", "0xFFE9", ")", ";", "// Left alt", "guac_keyboard", ".", "release", "(", "0xFFEA", ")", ";", "// Right alt", "}", "}" ]
Releases Ctrl+Alt, if both are currently pressed and the given keysym looks like a key that may require AltGr. @private @param {Number} keysym The key that was just pressed.
[ "Releases", "Ctrl", "+", "Alt", "if", "both", "are", "currently", "pressed", "and", "the", "given", "keysym", "looks", "like", "a", "key", "that", "may", "require", "AltGr", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Keyboard.js#L886-L908
36,160
ILLGrenoble/guacamole-common-js
src/Keyboard.js
interpret_event
function interpret_event() { // Peek at first event in log var first = eventLog[0]; if (!first) return null; // Keydown event if (first instanceof KeydownEvent) { var keysym = null; var accepted_events = []; // If event itself is reliable, no need to wait for other events if (first.reliable) { keysym = first.keysym; accepted_events = eventLog.splice(0, 1); } // If keydown is immediately followed by a keypress, use the indicated character else if (eventLog[1] instanceof KeypressEvent) { keysym = eventLog[1].keysym; accepted_events = eventLog.splice(0, 2); } // If keydown is immediately followed by anything else, then no // keypress can possibly occur to clarify this event, and we must // handle it now else if (eventLog[1]) { keysym = first.keysym; accepted_events = eventLog.splice(0, 1); } // Fire a key press if valid events were found if (accepted_events.length > 0) { if (keysym) { // Fire event release_simulated_altgr(keysym); var defaultPrevented = !guac_keyboard.press(keysym); recentKeysym[first.keyCode] = keysym; // If a key is pressed while meta is held down, the keyup will // never be sent in Chrome, so send it now. (bug #108404) if (guac_keyboard.modifiers.meta && keysym !== 0xFFE7 && keysym !== 0xFFE8) guac_keyboard.release(keysym); // Record whether default was prevented for (var i=0; i<accepted_events.length; i++) accepted_events[i].defaultPrevented = defaultPrevented; } return first; } } // end if keydown // Keyup event else if (first instanceof KeyupEvent) { // Release specific key if known var keysym = first.keysym; if (keysym) { guac_keyboard.release(keysym); first.defaultPrevented = true; } // Otherwise, fall back to releasing all keys else { guac_keyboard.reset(); return first; } return eventLog.shift(); } // end if keyup // Ignore any other type of event (keypress by itself is invalid) else return eventLog.shift(); // No event interpreted return null; }
javascript
function interpret_event() { // Peek at first event in log var first = eventLog[0]; if (!first) return null; // Keydown event if (first instanceof KeydownEvent) { var keysym = null; var accepted_events = []; // If event itself is reliable, no need to wait for other events if (first.reliable) { keysym = first.keysym; accepted_events = eventLog.splice(0, 1); } // If keydown is immediately followed by a keypress, use the indicated character else if (eventLog[1] instanceof KeypressEvent) { keysym = eventLog[1].keysym; accepted_events = eventLog.splice(0, 2); } // If keydown is immediately followed by anything else, then no // keypress can possibly occur to clarify this event, and we must // handle it now else if (eventLog[1]) { keysym = first.keysym; accepted_events = eventLog.splice(0, 1); } // Fire a key press if valid events were found if (accepted_events.length > 0) { if (keysym) { // Fire event release_simulated_altgr(keysym); var defaultPrevented = !guac_keyboard.press(keysym); recentKeysym[first.keyCode] = keysym; // If a key is pressed while meta is held down, the keyup will // never be sent in Chrome, so send it now. (bug #108404) if (guac_keyboard.modifiers.meta && keysym !== 0xFFE7 && keysym !== 0xFFE8) guac_keyboard.release(keysym); // Record whether default was prevented for (var i=0; i<accepted_events.length; i++) accepted_events[i].defaultPrevented = defaultPrevented; } return first; } } // end if keydown // Keyup event else if (first instanceof KeyupEvent) { // Release specific key if known var keysym = first.keysym; if (keysym) { guac_keyboard.release(keysym); first.defaultPrevented = true; } // Otherwise, fall back to releasing all keys else { guac_keyboard.reset(); return first; } return eventLog.shift(); } // end if keyup // Ignore any other type of event (keypress by itself is invalid) else return eventLog.shift(); // No event interpreted return null; }
[ "function", "interpret_event", "(", ")", "{", "// Peek at first event in log", "var", "first", "=", "eventLog", "[", "0", "]", ";", "if", "(", "!", "first", ")", "return", "null", ";", "// Keydown event", "if", "(", "first", "instanceof", "KeydownEvent", ")", "{", "var", "keysym", "=", "null", ";", "var", "accepted_events", "=", "[", "]", ";", "// If event itself is reliable, no need to wait for other events", "if", "(", "first", ".", "reliable", ")", "{", "keysym", "=", "first", ".", "keysym", ";", "accepted_events", "=", "eventLog", ".", "splice", "(", "0", ",", "1", ")", ";", "}", "// If keydown is immediately followed by a keypress, use the indicated character", "else", "if", "(", "eventLog", "[", "1", "]", "instanceof", "KeypressEvent", ")", "{", "keysym", "=", "eventLog", "[", "1", "]", ".", "keysym", ";", "accepted_events", "=", "eventLog", ".", "splice", "(", "0", ",", "2", ")", ";", "}", "// If keydown is immediately followed by anything else, then no", "// keypress can possibly occur to clarify this event, and we must", "// handle it now", "else", "if", "(", "eventLog", "[", "1", "]", ")", "{", "keysym", "=", "first", ".", "keysym", ";", "accepted_events", "=", "eventLog", ".", "splice", "(", "0", ",", "1", ")", ";", "}", "// Fire a key press if valid events were found", "if", "(", "accepted_events", ".", "length", ">", "0", ")", "{", "if", "(", "keysym", ")", "{", "// Fire event", "release_simulated_altgr", "(", "keysym", ")", ";", "var", "defaultPrevented", "=", "!", "guac_keyboard", ".", "press", "(", "keysym", ")", ";", "recentKeysym", "[", "first", ".", "keyCode", "]", "=", "keysym", ";", "// If a key is pressed while meta is held down, the keyup will", "// never be sent in Chrome, so send it now. (bug #108404)", "if", "(", "guac_keyboard", ".", "modifiers", ".", "meta", "&&", "keysym", "!==", "0xFFE7", "&&", "keysym", "!==", "0xFFE8", ")", "guac_keyboard", ".", "release", "(", "keysym", ")", ";", "// Record whether default was prevented", "for", "(", "var", "i", "=", "0", ";", "i", "<", "accepted_events", ".", "length", ";", "i", "++", ")", "accepted_events", "[", "i", "]", ".", "defaultPrevented", "=", "defaultPrevented", ";", "}", "return", "first", ";", "}", "}", "// end if keydown", "// Keyup event", "else", "if", "(", "first", "instanceof", "KeyupEvent", ")", "{", "// Release specific key if known", "var", "keysym", "=", "first", ".", "keysym", ";", "if", "(", "keysym", ")", "{", "guac_keyboard", ".", "release", "(", "keysym", ")", ";", "first", ".", "defaultPrevented", "=", "true", ";", "}", "// Otherwise, fall back to releasing all keys", "else", "{", "guac_keyboard", ".", "reset", "(", ")", ";", "return", "first", ";", "}", "return", "eventLog", ".", "shift", "(", ")", ";", "}", "// end if keyup", "// Ignore any other type of event (keypress by itself is invalid)", "else", "return", "eventLog", ".", "shift", "(", ")", ";", "// No event interpreted", "return", "null", ";", "}" ]
Reads through the event log, interpreting the first event, if possible, and returning that event. If no events can be interpreted, due to a total lack of events or the need for more events, null is returned. Any interpreted events are automatically removed from the log. @private @return {KeyEvent} The first key event in the log, if it can be interpreted, or null otherwise.
[ "Reads", "through", "the", "event", "log", "interpreting", "the", "first", "event", "if", "possible", "and", "returning", "that", "event", ".", "If", "no", "events", "can", "be", "interpreted", "due", "to", "a", "total", "lack", "of", "events", "or", "the", "need", "for", "more", "events", "null", "is", "returned", ".", "Any", "interpreted", "events", "are", "automatically", "removed", "from", "the", "log", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Keyboard.js#L921-L1008
36,161
the-simian/gulp-concat-filenames
index.js
function(str) { var output; try { output = opts.template(str); } catch (e) { e.message = error.badTemplate + ': ' + e.message; return this.emit('error', new PluginError('gulp-concat-filenames', e)); } if (typeof output !== 'string') { return this.emit('error', new PluginError('gulp-concat-filenames', error.badTemplate)); } return output; }
javascript
function(str) { var output; try { output = opts.template(str); } catch (e) { e.message = error.badTemplate + ': ' + e.message; return this.emit('error', new PluginError('gulp-concat-filenames', e)); } if (typeof output !== 'string') { return this.emit('error', new PluginError('gulp-concat-filenames', error.badTemplate)); } return output; }
[ "function", "(", "str", ")", "{", "var", "output", ";", "try", "{", "output", "=", "opts", ".", "template", "(", "str", ")", ";", "}", "catch", "(", "e", ")", "{", "e", ".", "message", "=", "error", ".", "badTemplate", "+", "': '", "+", "e", ".", "message", ";", "return", "this", ".", "emit", "(", "'error'", ",", "new", "PluginError", "(", "'gulp-concat-filenames'", ",", "e", ")", ")", ";", "}", "if", "(", "typeof", "output", "!==", "'string'", ")", "{", "return", "this", ".", "emit", "(", "'error'", ",", "new", "PluginError", "(", "'gulp-concat-filenames'", ",", "error", ".", "badTemplate", ")", ")", ";", "}", "return", "output", ";", "}" ]
Make sure template errors reach the output
[ "Make", "sure", "template", "errors", "reach", "the", "output" ]
5b521d82b7867623e43e41647ad7cac6ca2f11b8
https://github.com/the-simian/gulp-concat-filenames/blob/5b521d82b7867623e43e41647ad7cac6ca2f11b8/index.js#L39-L52
36,162
kibertoad/objection-swagger
lib/transformers/query-param.schema.transformer.js
transformIntoQueryParamSchema
function transformIntoQueryParamSchema(processedSchema) { return _.transform( processedSchema.items.properties, (result, value, key) => { const parameter = Object.assign( { name: key }, value, { type: Array.isArray(value.type) ? value.type[0] : value.type, required: !_.includes(value.type, "null") } ); result.push(parameter); }, [] ); }
javascript
function transformIntoQueryParamSchema(processedSchema) { return _.transform( processedSchema.items.properties, (result, value, key) => { const parameter = Object.assign( { name: key }, value, { type: Array.isArray(value.type) ? value.type[0] : value.type, required: !_.includes(value.type, "null") } ); result.push(parameter); }, [] ); }
[ "function", "transformIntoQueryParamSchema", "(", "processedSchema", ")", "{", "return", "_", ".", "transform", "(", "processedSchema", ".", "items", ".", "properties", ",", "(", "result", ",", "value", ",", "key", ")", "=>", "{", "const", "parameter", "=", "Object", ".", "assign", "(", "{", "name", ":", "key", "}", ",", "value", ",", "{", "type", ":", "Array", ".", "isArray", "(", "value", ".", "type", ")", "?", "value", ".", "type", "[", "0", "]", ":", "value", ".", "type", ",", "required", ":", "!", "_", ".", "includes", "(", "value", ".", "type", ",", "\"null\"", ")", "}", ")", ";", "result", ".", "push", "(", "parameter", ")", ";", "}", ",", "[", "]", ")", ";", "}" ]
Transforms JSON-Schema to be usable as Swagger endpoint query param schema @param {Object} processedSchema @returns {*}
[ "Transforms", "JSON", "-", "Schema", "to", "be", "usable", "as", "Swagger", "endpoint", "query", "param", "schema" ]
2109b58ce323e78252729a46bcc94e617035b541
https://github.com/kibertoad/objection-swagger/blob/2109b58ce323e78252729a46bcc94e617035b541/lib/transformers/query-param.schema.transformer.js#L8-L26
36,163
jorisvervuurt/JVSDisplayOTron
lib/dothat/dothat.js
DOTHAT
function DOTHAT() { if (!(this instanceof DOTHAT)) { return new DOTHAT(); } this.displayOTron = new DisplayOTron('HAT'); this.lcd = new LCD(this.displayOTron); this.backlight = new Backlight(this.displayOTron); this.barGraph = new BarGraph(this.displayOTron); this.touch = new Touch(this.displayOTron); }
javascript
function DOTHAT() { if (!(this instanceof DOTHAT)) { return new DOTHAT(); } this.displayOTron = new DisplayOTron('HAT'); this.lcd = new LCD(this.displayOTron); this.backlight = new Backlight(this.displayOTron); this.barGraph = new BarGraph(this.displayOTron); this.touch = new Touch(this.displayOTron); }
[ "function", "DOTHAT", "(", ")", "{", "if", "(", "!", "(", "this", "instanceof", "DOTHAT", ")", ")", "{", "return", "new", "DOTHAT", "(", ")", ";", "}", "this", ".", "displayOTron", "=", "new", "DisplayOTron", "(", "'HAT'", ")", ";", "this", ".", "lcd", "=", "new", "LCD", "(", "this", ".", "displayOTron", ")", ";", "this", ".", "backlight", "=", "new", "Backlight", "(", "this", ".", "displayOTron", ")", ";", "this", ".", "barGraph", "=", "new", "BarGraph", "(", "this", ".", "displayOTron", ")", ";", "this", ".", "touch", "=", "new", "Touch", "(", "this", ".", "displayOTron", ")", ";", "}" ]
Creates a new `DOTHAT` object. @constructor
[ "Creates", "a", "new", "DOTHAT", "object", "." ]
c8f9bfdbf4e2658bb12fc83bbf49853c938e7dcc
https://github.com/jorisvervuurt/JVSDisplayOTron/blob/c8f9bfdbf4e2658bb12fc83bbf49853c938e7dcc/lib/dothat/dothat.js#L44-L54
36,164
Accela-Inc/accela-rest-nodejs
lib/rest-client.js
setAuthType
function setAuthType(auth_type) { var headers = { 'Content-Type': 'application/json', 'Accept': 'application/json' }; if (auth_type == 'AccessToken') { headers['Authorization'] = _config.access_token; } else if (auth_type == 'AppCredentials') { headers['x-accela-appid'] = _config.app_id headers['x-accela-appsecret'] = _config.app_secret; } else { headers['x-accela-appid'] = _config.app_id headers['x-accela-agency'] = _config.agency; headers['x-accela-environment'] = _config.environment; } return headers; }
javascript
function setAuthType(auth_type) { var headers = { 'Content-Type': 'application/json', 'Accept': 'application/json' }; if (auth_type == 'AccessToken') { headers['Authorization'] = _config.access_token; } else if (auth_type == 'AppCredentials') { headers['x-accela-appid'] = _config.app_id headers['x-accela-appsecret'] = _config.app_secret; } else { headers['x-accela-appid'] = _config.app_id headers['x-accela-agency'] = _config.agency; headers['x-accela-environment'] = _config.environment; } return headers; }
[ "function", "setAuthType", "(", "auth_type", ")", "{", "var", "headers", "=", "{", "'Content-Type'", ":", "'application/json'", ",", "'Accept'", ":", "'application/json'", "}", ";", "if", "(", "auth_type", "==", "'AccessToken'", ")", "{", "headers", "[", "'Authorization'", "]", "=", "_config", ".", "access_token", ";", "}", "else", "if", "(", "auth_type", "==", "'AppCredentials'", ")", "{", "headers", "[", "'x-accela-appid'", "]", "=", "_config", ".", "app_id", "headers", "[", "'x-accela-appsecret'", "]", "=", "_config", ".", "app_secret", ";", "}", "else", "{", "headers", "[", "'x-accela-appid'", "]", "=", "_config", ".", "app_id", "headers", "[", "'x-accela-agency'", "]", "=", "_config", ".", "agency", ";", "headers", "[", "'x-accela-environment'", "]", "=", "_config", ".", "environment", ";", "}", "return", "headers", ";", "}" ]
Method to set authorization type.
[ "Method", "to", "set", "authorization", "type", "." ]
8f79d5f48d1244b3ab9afd958e7c9ae1f7ecbb0e
https://github.com/Accela-Inc/accela-rest-nodejs/blob/8f79d5f48d1244b3ab9afd958e7c9ae1f7ecbb0e/lib/rest-client.js#L133-L152
36,165
Accela-Inc/accela-rest-nodejs
lib/rest-client.js
escapeCharacters
function escapeCharacters(params) { return params; var find = new Array('.','-','%','/','\\\\',':','*','\\','<','>','|','?',' ','&','#'); var replace = new Array('.0','.1','.2','.3','.4','.5','.6','.7','.8','.9','.a','.b','.c','.d','.e'); var escaped = {}; for (var param in params) { if(typeof(params[param]) == 'string') { escaped[param] = replaceCharacter(find, replace, params[param]); } else { escaped[param] = params[param]; } } return escaped; }
javascript
function escapeCharacters(params) { return params; var find = new Array('.','-','%','/','\\\\',':','*','\\','<','>','|','?',' ','&','#'); var replace = new Array('.0','.1','.2','.3','.4','.5','.6','.7','.8','.9','.a','.b','.c','.d','.e'); var escaped = {}; for (var param in params) { if(typeof(params[param]) == 'string') { escaped[param] = replaceCharacter(find, replace, params[param]); } else { escaped[param] = params[param]; } } return escaped; }
[ "function", "escapeCharacters", "(", "params", ")", "{", "return", "params", ";", "var", "find", "=", "new", "Array", "(", "'.'", ",", "'-'", ",", "'%'", ",", "'/'", ",", "'\\\\\\\\'", ",", "':'", ",", "'*'", ",", "'\\\\'", ",", "'<'", ",", "'>'", ",", "'|'", ",", "'?'", ",", "' '", ",", "'&'", ",", "'#'", ")", ";", "var", "replace", "=", "new", "Array", "(", "'.0'", ",", "'.1'", ",", "'.2'", ",", "'.3'", ",", "'.4'", ",", "'.5'", ",", "'.6'", ",", "'.7'", ",", "'.8'", ",", "'.9'", ",", "'.a'", ",", "'.b'", ",", "'.c'", ",", "'.d'", ",", "'.e'", ")", ";", "var", "escaped", "=", "{", "}", ";", "for", "(", "var", "param", "in", "params", ")", "{", "if", "(", "typeof", "(", "params", "[", "param", "]", ")", "==", "'string'", ")", "{", "escaped", "[", "param", "]", "=", "replaceCharacter", "(", "find", ",", "replace", ",", "params", "[", "param", "]", ")", ";", "}", "else", "{", "escaped", "[", "param", "]", "=", "params", "[", "param", "]", ";", "}", "}", "return", "escaped", ";", "}" ]
Method to escape special characters.
[ "Method", "to", "escape", "special", "characters", "." ]
8f79d5f48d1244b3ab9afd958e7c9ae1f7ecbb0e
https://github.com/Accela-Inc/accela-rest-nodejs/blob/8f79d5f48d1244b3ab9afd958e7c9ae1f7ecbb0e/lib/rest-client.js#L155-L169
36,166
Accela-Inc/accela-rest-nodejs
lib/rest-client.js
replaceCharacter
function replaceCharacter(search, replace, subject, count) { var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0, f = [].concat(search), r = [].concat(replace), s = subject, ra = Object.prototype.toString.call(r) === '[object Array]', sa = Object.prototype.toString.call(s) === '[object Array]', s = [].concat(s); if(typeof(search) === 'object' && typeof(replace) === 'string' ) { temp = replace; replace = new Array(); for (i=0; i < search.length; i+=1) { replace[i] = temp; } temp = ''; r = [].concat(replace); ra = Object.prototype.toString.call(r) === '[object Array]'; } if (count) { this.window[count] = 0; } for (i = 0, sl = s.length; i < sl; i++) { if (s[i] === '') { continue; } for (j = 0, fl = f.length; j < fl; j++) { temp = s[i] + ''; repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0]; s[i] = (temp) .split(f[j]) .join(repl); if (count) { this.window[count] += ((temp.split(f[j])).length - 1); } } } return sa ? s : s[0]; }
javascript
function replaceCharacter(search, replace, subject, count) { var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0, f = [].concat(search), r = [].concat(replace), s = subject, ra = Object.prototype.toString.call(r) === '[object Array]', sa = Object.prototype.toString.call(s) === '[object Array]', s = [].concat(s); if(typeof(search) === 'object' && typeof(replace) === 'string' ) { temp = replace; replace = new Array(); for (i=0; i < search.length; i+=1) { replace[i] = temp; } temp = ''; r = [].concat(replace); ra = Object.prototype.toString.call(r) === '[object Array]'; } if (count) { this.window[count] = 0; } for (i = 0, sl = s.length; i < sl; i++) { if (s[i] === '') { continue; } for (j = 0, fl = f.length; j < fl; j++) { temp = s[i] + ''; repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0]; s[i] = (temp) .split(f[j]) .join(repl); if (count) { this.window[count] += ((temp.split(f[j])).length - 1); } } } return sa ? s : s[0]; }
[ "function", "replaceCharacter", "(", "search", ",", "replace", ",", "subject", ",", "count", ")", "{", "var", "i", "=", "0", ",", "j", "=", "0", ",", "temp", "=", "''", ",", "repl", "=", "''", ",", "sl", "=", "0", ",", "fl", "=", "0", ",", "f", "=", "[", "]", ".", "concat", "(", "search", ")", ",", "r", "=", "[", "]", ".", "concat", "(", "replace", ")", ",", "s", "=", "subject", ",", "ra", "=", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "r", ")", "===", "'[object Array]'", ",", "sa", "=", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "s", ")", "===", "'[object Array]'", ",", "s", "=", "[", "]", ".", "concat", "(", "s", ")", ";", "if", "(", "typeof", "(", "search", ")", "===", "'object'", "&&", "typeof", "(", "replace", ")", "===", "'string'", ")", "{", "temp", "=", "replace", ";", "replace", "=", "new", "Array", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "search", ".", "length", ";", "i", "+=", "1", ")", "{", "replace", "[", "i", "]", "=", "temp", ";", "}", "temp", "=", "''", ";", "r", "=", "[", "]", ".", "concat", "(", "replace", ")", ";", "ra", "=", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "r", ")", "===", "'[object Array]'", ";", "}", "if", "(", "count", ")", "{", "this", ".", "window", "[", "count", "]", "=", "0", ";", "}", "for", "(", "i", "=", "0", ",", "sl", "=", "s", ".", "length", ";", "i", "<", "sl", ";", "i", "++", ")", "{", "if", "(", "s", "[", "i", "]", "===", "''", ")", "{", "continue", ";", "}", "for", "(", "j", "=", "0", ",", "fl", "=", "f", ".", "length", ";", "j", "<", "fl", ";", "j", "++", ")", "{", "temp", "=", "s", "[", "i", "]", "+", "''", ";", "repl", "=", "ra", "?", "(", "r", "[", "j", "]", "!==", "undefined", "?", "r", "[", "j", "]", ":", "''", ")", ":", "r", "[", "0", "]", ";", "s", "[", "i", "]", "=", "(", "temp", ")", ".", "split", "(", "f", "[", "j", "]", ")", ".", "join", "(", "repl", ")", ";", "if", "(", "count", ")", "{", "this", ".", "window", "[", "count", "]", "+=", "(", "(", "temp", ".", "split", "(", "f", "[", "j", "]", ")", ")", ".", "length", "-", "1", ")", ";", "}", "}", "}", "return", "sa", "?", "s", ":", "s", "[", "0", "]", ";", "}" ]
Method for character replacement.
[ "Method", "for", "character", "replacement", "." ]
8f79d5f48d1244b3ab9afd958e7c9ae1f7ecbb0e
https://github.com/Accela-Inc/accela-rest-nodejs/blob/8f79d5f48d1244b3ab9afd958e7c9ae1f7ecbb0e/lib/rest-client.js#L172-L209
36,167
Accela-Inc/accela-rest-nodejs
lib/rest-client.js
buildQueryString
function buildQueryString(params) { var querystring = ''; for(param in params) { querystring += '&' + param + '=' + params[param]; } return querystring; }
javascript
function buildQueryString(params) { var querystring = ''; for(param in params) { querystring += '&' + param + '=' + params[param]; } return querystring; }
[ "function", "buildQueryString", "(", "params", ")", "{", "var", "querystring", "=", "''", ";", "for", "(", "param", "in", "params", ")", "{", "querystring", "+=", "'&'", "+", "param", "+", "'='", "+", "params", "[", "param", "]", ";", "}", "return", "querystring", ";", "}" ]
Utility function to build querystring parameters for API call.
[ "Utility", "function", "to", "build", "querystring", "parameters", "for", "API", "call", "." ]
8f79d5f48d1244b3ab9afd958e7c9ae1f7ecbb0e
https://github.com/Accela-Inc/accela-rest-nodejs/blob/8f79d5f48d1244b3ab9afd958e7c9ae1f7ecbb0e/lib/rest-client.js#L220-L226
36,168
Accela-Inc/accela-rest-nodejs
lib/rest-client.js
makeRequest
function makeRequest(options, callback) { request(options, function (error, response, body){ if (error) { callback(error, null); } else if (response.statusCode == 200) { callback( null, JSON.parse(body)); } else { callback(new Error('HTTP Response Code: ' + response.statusCode), null); } }); }
javascript
function makeRequest(options, callback) { request(options, function (error, response, body){ if (error) { callback(error, null); } else if (response.statusCode == 200) { callback( null, JSON.parse(body)); } else { callback(new Error('HTTP Response Code: ' + response.statusCode), null); } }); }
[ "function", "makeRequest", "(", "options", ",", "callback", ")", "{", "request", "(", "options", ",", "function", "(", "error", ",", "response", ",", "body", ")", "{", "if", "(", "error", ")", "{", "callback", "(", "error", ",", "null", ")", ";", "}", "else", "if", "(", "response", ".", "statusCode", "==", "200", ")", "{", "callback", "(", "null", ",", "JSON", ".", "parse", "(", "body", ")", ")", ";", "}", "else", "{", "callback", "(", "new", "Error", "(", "'HTTP Response Code: '", "+", "response", ".", "statusCode", ")", ",", "null", ")", ";", "}", "}", ")", ";", "}" ]
Private method to make API call.
[ "Private", "method", "to", "make", "API", "call", "." ]
8f79d5f48d1244b3ab9afd958e7c9ae1f7ecbb0e
https://github.com/Accela-Inc/accela-rest-nodejs/blob/8f79d5f48d1244b3ab9afd958e7c9ae1f7ecbb0e/lib/rest-client.js#L229-L241
36,169
aMarCruz/jspreproc
lib/options.js
_setFilter
function _setFilter(filt) { filt = filt.trim() if (filt === 'all') this.filter = filt else if (filt in _filters) { if (this.filter !== 'all' && this.filter.indexOf(filt) < 0) this.filter.push(filt) } else this.invalid('filter', filt) }
javascript
function _setFilter(filt) { filt = filt.trim() if (filt === 'all') this.filter = filt else if (filt in _filters) { if (this.filter !== 'all' && this.filter.indexOf(filt) < 0) this.filter.push(filt) } else this.invalid('filter', filt) }
[ "function", "_setFilter", "(", "filt", ")", "{", "filt", "=", "filt", ".", "trim", "(", ")", "if", "(", "filt", "===", "'all'", ")", "this", ".", "filter", "=", "filt", "else", "if", "(", "filt", "in", "_filters", ")", "{", "if", "(", "this", ".", "filter", "!==", "'all'", "&&", "this", ".", "filter", ".", "indexOf", "(", "filt", ")", "<", "0", ")", "this", ".", "filter", ".", "push", "(", "filt", ")", "}", "else", "this", ".", "invalid", "(", "'filter'", ",", "filt", ")", "}" ]
Enable filters for comments, 'all' enable all filters
[ "Enable", "filters", "for", "comments", "all", "enable", "all", "filters" ]
5f31820d702a329e8aa25f0f3983f13097610250
https://github.com/aMarCruz/jspreproc/blob/5f31820d702a329e8aa25f0f3983f13097610250/lib/options.js#L175-L184
36,170
aMarCruz/jspreproc
lib/options.js
_createFilter
function _createFilter(res) { for (var i = 0; i < res.length; ++i) { var f = res[i] if (f instanceof RegExp) custfilt.push(f) else { //console.log('--- creating regex with `' + str + '`') try { f = new RegExp(f) custfilt.push(f) } catch (e) { f = null } if (!f) this.invalid('custom filter', res[i]) } } }
javascript
function _createFilter(res) { for (var i = 0; i < res.length; ++i) { var f = res[i] if (f instanceof RegExp) custfilt.push(f) else { //console.log('--- creating regex with `' + str + '`') try { f = new RegExp(f) custfilt.push(f) } catch (e) { f = null } if (!f) this.invalid('custom filter', res[i]) } } }
[ "function", "_createFilter", "(", "res", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "res", ".", "length", ";", "++", "i", ")", "{", "var", "f", "=", "res", "[", "i", "]", "if", "(", "f", "instanceof", "RegExp", ")", "custfilt", ".", "push", "(", "f", ")", "else", "{", "//console.log('--- creating regex with `' + str + '`')", "try", "{", "f", "=", "new", "RegExp", "(", "f", ")", "custfilt", ".", "push", "(", "f", ")", "}", "catch", "(", "e", ")", "{", "f", "=", "null", "}", "if", "(", "!", "f", ")", "this", ".", "invalid", "(", "'custom filter'", ",", "res", "[", "i", "]", ")", "}", "}", "}" ]
Creates a custom filter
[ "Creates", "a", "custom", "filter" ]
5f31820d702a329e8aa25f0f3983f13097610250
https://github.com/aMarCruz/jspreproc/blob/5f31820d702a329e8aa25f0f3983f13097610250/lib/options.js#L187-L205
36,171
ascartabelli/lamb
src/privates/_getPathKey.js
_getPathKey
function _getPathKey (target, key, includeNonEnumerables) { if (includeNonEnumerables && key in Object(target) || _isEnumerable(target, key)) { return key; } var n = +key; var len = target && target.length; return n >= -len && n < len ? n < 0 ? n + len : n : void 0; }
javascript
function _getPathKey (target, key, includeNonEnumerables) { if (includeNonEnumerables && key in Object(target) || _isEnumerable(target, key)) { return key; } var n = +key; var len = target && target.length; return n >= -len && n < len ? n < 0 ? n + len : n : void 0; }
[ "function", "_getPathKey", "(", "target", ",", "key", ",", "includeNonEnumerables", ")", "{", "if", "(", "includeNonEnumerables", "&&", "key", "in", "Object", "(", "target", ")", "||", "_isEnumerable", "(", "target", ",", "key", ")", ")", "{", "return", "key", ";", "}", "var", "n", "=", "+", "key", ";", "var", "len", "=", "target", "&&", "target", ".", "length", ";", "return", "n", ">=", "-", "len", "&&", "n", "<", "len", "?", "n", "<", "0", "?", "n", "+", "len", ":", "n", ":", "void", "0", ";", "}" ]
Helper to retrieve the correct key while evaluating a path. @private @param {Object} target @param {String} key @param {Boolean} includeNonEnumerables @returns {String|Number|Undefined}
[ "Helper", "to", "retrieve", "the", "correct", "key", "while", "evaluating", "a", "path", "." ]
d36e45945c4789e4f1a2d8805936514b53f32362
https://github.com/ascartabelli/lamb/blob/d36e45945c4789e4f1a2d8805936514b53f32362/src/privates/_getPathKey.js#L11-L20
36,172
ascartabelli/lamb
src/privates/_sorter.js
_sorter
function _sorter (reader, isDescending, comparer) { if (typeof reader !== "function" || reader === identity) { reader = null; } if (typeof comparer !== "function") { comparer = _comparer; } return { isDescending: isDescending === true, compare: function (a, b) { if (reader) { a = reader(a); b = reader(b); } return comparer(a, b); } }; }
javascript
function _sorter (reader, isDescending, comparer) { if (typeof reader !== "function" || reader === identity) { reader = null; } if (typeof comparer !== "function") { comparer = _comparer; } return { isDescending: isDescending === true, compare: function (a, b) { if (reader) { a = reader(a); b = reader(b); } return comparer(a, b); } }; }
[ "function", "_sorter", "(", "reader", ",", "isDescending", ",", "comparer", ")", "{", "if", "(", "typeof", "reader", "!==", "\"function\"", "||", "reader", "===", "identity", ")", "{", "reader", "=", "null", ";", "}", "if", "(", "typeof", "comparer", "!==", "\"function\"", ")", "{", "comparer", "=", "_comparer", ";", "}", "return", "{", "isDescending", ":", "isDescending", "===", "true", ",", "compare", ":", "function", "(", "a", ",", "b", ")", "{", "if", "(", "reader", ")", "{", "a", "=", "reader", "(", "a", ")", ";", "b", "=", "reader", "(", "b", ")", ";", "}", "return", "comparer", "(", "a", ",", "b", ")", ";", "}", "}", ";", "}" ]
Builds a sorting criterion. If the comparer function is missing, the default comparer will be used instead. @private @param {Function} reader @param {Boolean} isDescending @param {Function} [comparer] @returns {Sorter}
[ "Builds", "a", "sorting", "criterion", ".", "If", "the", "comparer", "function", "is", "missing", "the", "default", "comparer", "will", "be", "used", "instead", "." ]
d36e45945c4789e4f1a2d8805936514b53f32362
https://github.com/ascartabelli/lamb/blob/d36e45945c4789e4f1a2d8805936514b53f32362/src/privates/_sorter.js#L13-L33
36,173
ascartabelli/lamb
src/privates/_merge.js
_merge
function _merge (getKeys, a, b) { return reduce([a, b], function (result, source) { forEach(getKeys(source), function (key) { result[key] = source[key]; }); return result; }, {}); }
javascript
function _merge (getKeys, a, b) { return reduce([a, b], function (result, source) { forEach(getKeys(source), function (key) { result[key] = source[key]; }); return result; }, {}); }
[ "function", "_merge", "(", "getKeys", ",", "a", ",", "b", ")", "{", "return", "reduce", "(", "[", "a", ",", "b", "]", ",", "function", "(", "result", ",", "source", ")", "{", "forEach", "(", "getKeys", "(", "source", ")", ",", "function", "(", "key", ")", "{", "result", "[", "key", "]", "=", "source", "[", "key", "]", ";", "}", ")", ";", "return", "result", ";", "}", ",", "{", "}", ")", ";", "}" ]
Merges the received objects using the provided function to retrieve their keys. @private @param {Function} getKeys @param {Object} a @param {Object} b @returns {Function}
[ "Merges", "the", "received", "objects", "using", "the", "provided", "function", "to", "retrieve", "their", "keys", "." ]
d36e45945c4789e4f1a2d8805936514b53f32362
https://github.com/ascartabelli/lamb/blob/d36e45945c4789e4f1a2d8805936514b53f32362/src/privates/_merge.js#L12-L20
36,174
wearefractal/recorder
recorder.js
trigger
function trigger(el, name, options){ var event, type; type = eventTypes[name]; if (!type) { throw new SyntaxError('Unknown event type: '+type); } options = options || {}; inherit(defaults, options); if (document.createEvent) { // Standard Event event = document.createEvent(type); initializers[type](el, name, event, options); el.dispatchEvent(event); } else { // IE Event event = document.createEventObject(); for (var key in options){ event[key] = options[key]; } el.fireEvent('on' + name, event); } }
javascript
function trigger(el, name, options){ var event, type; type = eventTypes[name]; if (!type) { throw new SyntaxError('Unknown event type: '+type); } options = options || {}; inherit(defaults, options); if (document.createEvent) { // Standard Event event = document.createEvent(type); initializers[type](el, name, event, options); el.dispatchEvent(event); } else { // IE Event event = document.createEventObject(); for (var key in options){ event[key] = options[key]; } el.fireEvent('on' + name, event); } }
[ "function", "trigger", "(", "el", ",", "name", ",", "options", ")", "{", "var", "event", ",", "type", ";", "type", "=", "eventTypes", "[", "name", "]", ";", "if", "(", "!", "type", ")", "{", "throw", "new", "SyntaxError", "(", "'Unknown event type: '", "+", "type", ")", ";", "}", "options", "=", "options", "||", "{", "}", ";", "inherit", "(", "defaults", ",", "options", ")", ";", "if", "(", "document", ".", "createEvent", ")", "{", "// Standard Event", "event", "=", "document", ".", "createEvent", "(", "type", ")", ";", "initializers", "[", "type", "]", "(", "el", ",", "name", ",", "event", ",", "options", ")", ";", "el", ".", "dispatchEvent", "(", "event", ")", ";", "}", "else", "{", "// IE Event", "event", "=", "document", ".", "createEventObject", "(", ")", ";", "for", "(", "var", "key", "in", "options", ")", "{", "event", "[", "key", "]", "=", "options", "[", "key", "]", ";", "}", "el", ".", "fireEvent", "(", "'on'", "+", "name", ",", "event", ")", ";", "}", "}" ]
Trigger a DOM event. trigger(document.body, "click", {clientX: 10, clientY: 35}); Where sensible, sane defaults will be filled in. See the list of event types for supported events. Loosely based on: https://github.com/kangax/protolicious/blob/master/event.simulate.js
[ "Trigger", "a", "DOM", "event", "." ]
527cca4f66560ea68b769f24ae1393f095c494f0
https://github.com/wearefractal/recorder/blob/527cca4f66560ea68b769f24ae1393f095c494f0/recorder.js#L447-L471
36,175
aMarCruz/jspreproc
spec/helpers/SpecHelper.js
function (util) { function printable(str) { return ('' + str).replace(/\n/g, '\\n').replace(/\r/g, '\\r') } function compare(actual, expected) { var pass = actual === expected return { pass: pass, message: util.buildFailureMessage( 'toHasLinesLike', pass, printable(actual), printable(expected)) } } return {compare: compare} }
javascript
function (util) { function printable(str) { return ('' + str).replace(/\n/g, '\\n').replace(/\r/g, '\\r') } function compare(actual, expected) { var pass = actual === expected return { pass: pass, message: util.buildFailureMessage( 'toHasLinesLike', pass, printable(actual), printable(expected)) } } return {compare: compare} }
[ "function", "(", "util", ")", "{", "function", "printable", "(", "str", ")", "{", "return", "(", "''", "+", "str", ")", ".", "replace", "(", "/", "\\n", "/", "g", ",", "'\\\\n'", ")", ".", "replace", "(", "/", "\\r", "/", "g", ",", "'\\\\r'", ")", "}", "function", "compare", "(", "actual", ",", "expected", ")", "{", "var", "pass", "=", "actual", "===", "expected", "return", "{", "pass", ":", "pass", ",", "message", ":", "util", ".", "buildFailureMessage", "(", "'toHasLinesLike'", ",", "pass", ",", "printable", "(", "actual", ")", ",", "printable", "(", "expected", ")", ")", "}", "}", "return", "{", "compare", ":", "compare", "}", "}" ]
simple string comparator, mainly for easy visualization of eols
[ "simple", "string", "comparator", "mainly", "for", "easy", "visualization", "of", "eols" ]
5f31820d702a329e8aa25f0f3983f13097610250
https://github.com/aMarCruz/jspreproc/blob/5f31820d702a329e8aa25f0f3983f13097610250/spec/helpers/SpecHelper.js#L6-L21
36,176
aMarCruz/jspreproc
spec/helpers/SpecHelper.js
function (/*util*/) { function compare(actual, expected) { return { pass: actual instanceof Error && ('' + actual).indexOf(expected) >= 0 } } return {compare: compare} }
javascript
function (/*util*/) { function compare(actual, expected) { return { pass: actual instanceof Error && ('' + actual).indexOf(expected) >= 0 } } return {compare: compare} }
[ "function", "(", "/*util*/", ")", "{", "function", "compare", "(", "actual", ",", "expected", ")", "{", "return", "{", "pass", ":", "actual", "instanceof", "Error", "&&", "(", "''", "+", "actual", ")", ".", "indexOf", "(", "expected", ")", ">=", "0", "}", "}", "return", "{", "compare", ":", "compare", "}", "}" ]
actual has to be an Error instance, and contain the expected string
[ "actual", "has", "to", "be", "an", "Error", "instance", "and", "contain", "the", "expected", "string" ]
5f31820d702a329e8aa25f0f3983f13097610250
https://github.com/aMarCruz/jspreproc/blob/5f31820d702a329e8aa25f0f3983f13097610250/spec/helpers/SpecHelper.js#L24-L33
36,177
ILLGrenoble/guacamole-common-js
src/Mouse.js
mousewheel_handler
function mousewheel_handler(e) { // Determine approximate scroll amount (in pixels) var delta = e.deltaY || -e.wheelDeltaY || -e.wheelDelta; // If successfully retrieved scroll amount, convert to pixels if not // already in pixels if (delta) { // Convert to pixels if delta was lines if (e.deltaMode === 1) delta = e.deltaY * guac_mouse.PIXELS_PER_LINE; // Convert to pixels if delta was pages else if (e.deltaMode === 2) delta = e.deltaY * guac_mouse.PIXELS_PER_PAGE; } // Otherwise, assume legacy mousewheel event and line scrolling else delta = e.detail * guac_mouse.PIXELS_PER_LINE; // Update overall delta scroll_delta += delta; // Up if (scroll_delta <= -guac_mouse.scrollThreshold) { // Repeatedly click the up button until insufficient delta remains do { if (guac_mouse.onmousedown) { guac_mouse.currentState.up = true; guac_mouse.onmousedown(guac_mouse.currentState); } if (guac_mouse.onmouseup) { guac_mouse.currentState.up = false; guac_mouse.onmouseup(guac_mouse.currentState); } scroll_delta += guac_mouse.scrollThreshold; } while (scroll_delta <= -guac_mouse.scrollThreshold); // Reset delta scroll_delta = 0; } // Down if (scroll_delta >= guac_mouse.scrollThreshold) { // Repeatedly click the down button until insufficient delta remains do { if (guac_mouse.onmousedown) { guac_mouse.currentState.down = true; guac_mouse.onmousedown(guac_mouse.currentState); } if (guac_mouse.onmouseup) { guac_mouse.currentState.down = false; guac_mouse.onmouseup(guac_mouse.currentState); } scroll_delta -= guac_mouse.scrollThreshold; } while (scroll_delta >= guac_mouse.scrollThreshold); // Reset delta scroll_delta = 0; } cancelEvent(e); }
javascript
function mousewheel_handler(e) { // Determine approximate scroll amount (in pixels) var delta = e.deltaY || -e.wheelDeltaY || -e.wheelDelta; // If successfully retrieved scroll amount, convert to pixels if not // already in pixels if (delta) { // Convert to pixels if delta was lines if (e.deltaMode === 1) delta = e.deltaY * guac_mouse.PIXELS_PER_LINE; // Convert to pixels if delta was pages else if (e.deltaMode === 2) delta = e.deltaY * guac_mouse.PIXELS_PER_PAGE; } // Otherwise, assume legacy mousewheel event and line scrolling else delta = e.detail * guac_mouse.PIXELS_PER_LINE; // Update overall delta scroll_delta += delta; // Up if (scroll_delta <= -guac_mouse.scrollThreshold) { // Repeatedly click the up button until insufficient delta remains do { if (guac_mouse.onmousedown) { guac_mouse.currentState.up = true; guac_mouse.onmousedown(guac_mouse.currentState); } if (guac_mouse.onmouseup) { guac_mouse.currentState.up = false; guac_mouse.onmouseup(guac_mouse.currentState); } scroll_delta += guac_mouse.scrollThreshold; } while (scroll_delta <= -guac_mouse.scrollThreshold); // Reset delta scroll_delta = 0; } // Down if (scroll_delta >= guac_mouse.scrollThreshold) { // Repeatedly click the down button until insufficient delta remains do { if (guac_mouse.onmousedown) { guac_mouse.currentState.down = true; guac_mouse.onmousedown(guac_mouse.currentState); } if (guac_mouse.onmouseup) { guac_mouse.currentState.down = false; guac_mouse.onmouseup(guac_mouse.currentState); } scroll_delta -= guac_mouse.scrollThreshold; } while (scroll_delta >= guac_mouse.scrollThreshold); // Reset delta scroll_delta = 0; } cancelEvent(e); }
[ "function", "mousewheel_handler", "(", "e", ")", "{", "// Determine approximate scroll amount (in pixels)", "var", "delta", "=", "e", ".", "deltaY", "||", "-", "e", ".", "wheelDeltaY", "||", "-", "e", ".", "wheelDelta", ";", "// If successfully retrieved scroll amount, convert to pixels if not", "// already in pixels", "if", "(", "delta", ")", "{", "// Convert to pixels if delta was lines", "if", "(", "e", ".", "deltaMode", "===", "1", ")", "delta", "=", "e", ".", "deltaY", "*", "guac_mouse", ".", "PIXELS_PER_LINE", ";", "// Convert to pixels if delta was pages", "else", "if", "(", "e", ".", "deltaMode", "===", "2", ")", "delta", "=", "e", ".", "deltaY", "*", "guac_mouse", ".", "PIXELS_PER_PAGE", ";", "}", "// Otherwise, assume legacy mousewheel event and line scrolling", "else", "delta", "=", "e", ".", "detail", "*", "guac_mouse", ".", "PIXELS_PER_LINE", ";", "// Update overall delta", "scroll_delta", "+=", "delta", ";", "// Up", "if", "(", "scroll_delta", "<=", "-", "guac_mouse", ".", "scrollThreshold", ")", "{", "// Repeatedly click the up button until insufficient delta remains", "do", "{", "if", "(", "guac_mouse", ".", "onmousedown", ")", "{", "guac_mouse", ".", "currentState", ".", "up", "=", "true", ";", "guac_mouse", ".", "onmousedown", "(", "guac_mouse", ".", "currentState", ")", ";", "}", "if", "(", "guac_mouse", ".", "onmouseup", ")", "{", "guac_mouse", ".", "currentState", ".", "up", "=", "false", ";", "guac_mouse", ".", "onmouseup", "(", "guac_mouse", ".", "currentState", ")", ";", "}", "scroll_delta", "+=", "guac_mouse", ".", "scrollThreshold", ";", "}", "while", "(", "scroll_delta", "<=", "-", "guac_mouse", ".", "scrollThreshold", ")", ";", "// Reset delta", "scroll_delta", "=", "0", ";", "}", "// Down", "if", "(", "scroll_delta", ">=", "guac_mouse", ".", "scrollThreshold", ")", "{", "// Repeatedly click the down button until insufficient delta remains", "do", "{", "if", "(", "guac_mouse", ".", "onmousedown", ")", "{", "guac_mouse", ".", "currentState", ".", "down", "=", "true", ";", "guac_mouse", ".", "onmousedown", "(", "guac_mouse", ".", "currentState", ")", ";", "}", "if", "(", "guac_mouse", ".", "onmouseup", ")", "{", "guac_mouse", ".", "currentState", ".", "down", "=", "false", ";", "guac_mouse", ".", "onmouseup", "(", "guac_mouse", ".", "currentState", ")", ";", "}", "scroll_delta", "-=", "guac_mouse", ".", "scrollThreshold", ";", "}", "while", "(", "scroll_delta", ">=", "guac_mouse", ".", "scrollThreshold", ")", ";", "// Reset delta", "scroll_delta", "=", "0", ";", "}", "cancelEvent", "(", "e", ")", ";", "}" ]
Scroll wheel support
[ "Scroll", "wheel", "support" ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Mouse.js#L249-L327
36,178
ILLGrenoble/guacamole-common-js
src/Mouse.js
press_button
function press_button(button) { if (!guac_touchscreen.currentState[button]) { guac_touchscreen.currentState[button] = true; if (guac_touchscreen.onmousedown) guac_touchscreen.onmousedown(guac_touchscreen.currentState); } }
javascript
function press_button(button) { if (!guac_touchscreen.currentState[button]) { guac_touchscreen.currentState[button] = true; if (guac_touchscreen.onmousedown) guac_touchscreen.onmousedown(guac_touchscreen.currentState); } }
[ "function", "press_button", "(", "button", ")", "{", "if", "(", "!", "guac_touchscreen", ".", "currentState", "[", "button", "]", ")", "{", "guac_touchscreen", ".", "currentState", "[", "button", "]", "=", "true", ";", "if", "(", "guac_touchscreen", ".", "onmousedown", ")", "guac_touchscreen", ".", "onmousedown", "(", "guac_touchscreen", ".", "currentState", ")", ";", "}", "}" ]
Presses the given mouse button, if it isn't already pressed. Valid button values are "left", "middle", "right", "up", and "down". @private @param {String} button The mouse button to press.
[ "Presses", "the", "given", "mouse", "button", "if", "it", "isn", "t", "already", "pressed", ".", "Valid", "button", "values", "are", "left", "middle", "right", "up", "and", "down", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Mouse.js#L898-L904
36,179
ILLGrenoble/guacamole-common-js
src/Mouse.js
release_button
function release_button(button) { if (guac_touchscreen.currentState[button]) { guac_touchscreen.currentState[button] = false; if (guac_touchscreen.onmouseup) guac_touchscreen.onmouseup(guac_touchscreen.currentState); } }
javascript
function release_button(button) { if (guac_touchscreen.currentState[button]) { guac_touchscreen.currentState[button] = false; if (guac_touchscreen.onmouseup) guac_touchscreen.onmouseup(guac_touchscreen.currentState); } }
[ "function", "release_button", "(", "button", ")", "{", "if", "(", "guac_touchscreen", ".", "currentState", "[", "button", "]", ")", "{", "guac_touchscreen", ".", "currentState", "[", "button", "]", "=", "false", ";", "if", "(", "guac_touchscreen", ".", "onmouseup", ")", "guac_touchscreen", ".", "onmouseup", "(", "guac_touchscreen", ".", "currentState", ")", ";", "}", "}" ]
Releases the given mouse button, if it isn't already released. Valid button values are "left", "middle", "right", "up", and "down". @private @param {String} button The mouse button to release.
[ "Releases", "the", "given", "mouse", "button", "if", "it", "isn", "t", "already", "released", ".", "Valid", "button", "values", "are", "left", "middle", "right", "up", "and", "down", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Mouse.js#L913-L919
36,180
ILLGrenoble/guacamole-common-js
src/Mouse.js
move_mouse
function move_mouse(x, y) { guac_touchscreen.currentState.fromClientPosition(element, x, y); if (guac_touchscreen.onmousemove) guac_touchscreen.onmousemove(guac_touchscreen.currentState); }
javascript
function move_mouse(x, y) { guac_touchscreen.currentState.fromClientPosition(element, x, y); if (guac_touchscreen.onmousemove) guac_touchscreen.onmousemove(guac_touchscreen.currentState); }
[ "function", "move_mouse", "(", "x", ",", "y", ")", "{", "guac_touchscreen", ".", "currentState", ".", "fromClientPosition", "(", "element", ",", "x", ",", "y", ")", ";", "if", "(", "guac_touchscreen", ".", "onmousemove", ")", "guac_touchscreen", ".", "onmousemove", "(", "guac_touchscreen", ".", "currentState", ")", ";", "}" ]
Moves the mouse to the given coordinates. These coordinates must be relative to the browser window, as they will be translated based on the touch event target's location within the browser window. @private @param {Number} x The X coordinate of the mouse pointer. @param {Number} y The Y coordinate of the mouse pointer.
[ "Moves", "the", "mouse", "to", "the", "given", "coordinates", ".", "These", "coordinates", "must", "be", "relative", "to", "the", "browser", "window", "as", "they", "will", "be", "translated", "based", "on", "the", "touch", "event", "target", "s", "location", "within", "the", "browser", "window", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Mouse.js#L942-L946
36,181
ILLGrenoble/guacamole-common-js
src/Mouse.js
finger_moved
function finger_moved(e) { var touch = e.touches[0] || e.changedTouches[0]; var delta_x = touch.clientX - gesture_start_x; var delta_y = touch.clientY - gesture_start_y; return Math.sqrt(delta_x*delta_x + delta_y*delta_y) >= guac_touchscreen.clickMoveThreshold; }
javascript
function finger_moved(e) { var touch = e.touches[0] || e.changedTouches[0]; var delta_x = touch.clientX - gesture_start_x; var delta_y = touch.clientY - gesture_start_y; return Math.sqrt(delta_x*delta_x + delta_y*delta_y) >= guac_touchscreen.clickMoveThreshold; }
[ "function", "finger_moved", "(", "e", ")", "{", "var", "touch", "=", "e", ".", "touches", "[", "0", "]", "||", "e", ".", "changedTouches", "[", "0", "]", ";", "var", "delta_x", "=", "touch", ".", "clientX", "-", "gesture_start_x", ";", "var", "delta_y", "=", "touch", ".", "clientY", "-", "gesture_start_y", ";", "return", "Math", ".", "sqrt", "(", "delta_x", "*", "delta_x", "+", "delta_y", "*", "delta_y", ")", ">=", "guac_touchscreen", ".", "clickMoveThreshold", ";", "}" ]
Returns whether the given touch event exceeds the movement threshold for clicking, based on where the touch gesture began. @private @param {TouchEvent} e The touch event to check. @return {Boolean} true if the movement threshold is exceeded, false otherwise.
[ "Returns", "whether", "the", "given", "touch", "event", "exceeds", "the", "movement", "threshold", "for", "clicking", "based", "on", "where", "the", "touch", "gesture", "began", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Mouse.js#L957-L962
36,182
ILLGrenoble/guacamole-common-js
src/Mouse.js
begin_gesture
function begin_gesture(e) { var touch = e.touches[0]; gesture_in_progress = true; gesture_start_x = touch.clientX; gesture_start_y = touch.clientY; }
javascript
function begin_gesture(e) { var touch = e.touches[0]; gesture_in_progress = true; gesture_start_x = touch.clientX; gesture_start_y = touch.clientY; }
[ "function", "begin_gesture", "(", "e", ")", "{", "var", "touch", "=", "e", ".", "touches", "[", "0", "]", ";", "gesture_in_progress", "=", "true", ";", "gesture_start_x", "=", "touch", ".", "clientX", ";", "gesture_start_y", "=", "touch", ".", "clientY", ";", "}" ]
Begins a new gesture at the location of the first touch in the given touch event. @private @param {TouchEvent} e The touch event beginning this new gesture.
[ "Begins", "a", "new", "gesture", "at", "the", "location", "of", "the", "first", "touch", "in", "the", "given", "touch", "event", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Mouse.js#L971-L976
36,183
tooleks/shevchenko-js
src/api.js
shevchenko
function shevchenko(anthroponym, inflectionCase) { return anthroponymInflector.inflect(new Anthroponym(anthroponym), new InflectionCase(inflectionCase)).toObject(); }
javascript
function shevchenko(anthroponym, inflectionCase) { return anthroponymInflector.inflect(new Anthroponym(anthroponym), new InflectionCase(inflectionCase)).toObject(); }
[ "function", "shevchenko", "(", "anthroponym", ",", "inflectionCase", ")", "{", "return", "anthroponymInflector", ".", "inflect", "(", "new", "Anthroponym", "(", "anthroponym", ")", ",", "new", "InflectionCase", "(", "inflectionCase", ")", ")", ".", "toObject", "(", ")", ";", "}" ]
Inflects the anthroponym. @param {object} anthroponym @param {string} anthroponym.firstName @param {string} anthroponym.lastName @param {string} anthroponym.middleName @param {string} anthroponym.gender @param {string} inflectionCase
[ "Inflects", "the", "anthroponym", "." ]
6c0b9543065585876dac5799bf90aa69ec48e0bc
https://github.com/tooleks/shevchenko-js/blob/6c0b9543065585876dac5799bf90aa69ec48e0bc/src/api.js#L16-L18
36,184
ILLGrenoble/guacamole-common-js
src/Object.js
dequeueBodyCallback
function dequeueBodyCallback(name) { // If no callbacks defined, simply return null var callbacks = bodyCallbacks[name]; if (!callbacks) return null; // Otherwise, pull off first callback, deleting the queue if empty var callback = callbacks.shift(); if (callbacks.length === 0) delete bodyCallbacks[name]; // Return found callback return callback; }
javascript
function dequeueBodyCallback(name) { // If no callbacks defined, simply return null var callbacks = bodyCallbacks[name]; if (!callbacks) return null; // Otherwise, pull off first callback, deleting the queue if empty var callback = callbacks.shift(); if (callbacks.length === 0) delete bodyCallbacks[name]; // Return found callback return callback; }
[ "function", "dequeueBodyCallback", "(", "name", ")", "{", "// If no callbacks defined, simply return null", "var", "callbacks", "=", "bodyCallbacks", "[", "name", "]", ";", "if", "(", "!", "callbacks", ")", "return", "null", ";", "// Otherwise, pull off first callback, deleting the queue if empty", "var", "callback", "=", "callbacks", ".", "shift", "(", ")", ";", "if", "(", "callbacks", ".", "length", "===", "0", ")", "delete", "bodyCallbacks", "[", "name", "]", ";", "// Return found callback", "return", "callback", ";", "}" ]
Removes and returns the callback at the head of the callback queue for the stream having the given name. If no such callbacks exist, null is returned. @private @param {String} name The name of the stream to retrieve a callback for. @returns {Function} The next callback associated with the stream having the given name, or null if no such callback exists.
[ "Removes", "and", "returns", "the", "callback", "at", "the", "head", "of", "the", "callback", "queue", "for", "the", "stream", "having", "the", "given", "name", ".", "If", "no", "such", "callbacks", "exist", "null", "is", "returned", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Object.js#L65-L80
36,185
ILLGrenoble/guacamole-common-js
src/Object.js
enqueueBodyCallback
function enqueueBodyCallback(name, callback) { // Get callback queue by name, creating first if necessary var callbacks = bodyCallbacks[name]; if (!callbacks) { callbacks = []; bodyCallbacks[name] = callbacks; } // Add callback to end of queue callbacks.push(callback); }
javascript
function enqueueBodyCallback(name, callback) { // Get callback queue by name, creating first if necessary var callbacks = bodyCallbacks[name]; if (!callbacks) { callbacks = []; bodyCallbacks[name] = callbacks; } // Add callback to end of queue callbacks.push(callback); }
[ "function", "enqueueBodyCallback", "(", "name", ",", "callback", ")", "{", "// Get callback queue by name, creating first if necessary", "var", "callbacks", "=", "bodyCallbacks", "[", "name", "]", ";", "if", "(", "!", "callbacks", ")", "{", "callbacks", "=", "[", "]", ";", "bodyCallbacks", "[", "name", "]", "=", "callbacks", ";", "}", "// Add callback to end of queue", "callbacks", ".", "push", "(", "callback", ")", ";", "}" ]
Adds the given callback to the tail of the callback queue for the stream having the given name. @private @param {String} name The name of the stream to associate with the given callback. @param {Function} callback The callback to add to the queue of the stream with the given name.
[ "Adds", "the", "given", "callback", "to", "the", "tail", "of", "the", "callback", "queue", "for", "the", "stream", "having", "the", "given", "name", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Object.js#L93-L105
36,186
ILLGrenoble/guacamole-common-js
src/Client.js
getLayer
function getLayer(index) { // Get layer, create if necessary var layer = layers[index]; if (!layer) { // Create layer based on index if (index === 0) layer = display.getDefaultLayer(); else if (index > 0) layer = display.createLayer(); else layer = display.createBuffer(); // Add new layer layers[index] = layer; } return layer; }
javascript
function getLayer(index) { // Get layer, create if necessary var layer = layers[index]; if (!layer) { // Create layer based on index if (index === 0) layer = display.getDefaultLayer(); else if (index > 0) layer = display.createLayer(); else layer = display.createBuffer(); // Add new layer layers[index] = layer; } return layer; }
[ "function", "getLayer", "(", "index", ")", "{", "// Get layer, create if necessary", "var", "layer", "=", "layers", "[", "index", "]", ";", "if", "(", "!", "layer", ")", "{", "// Create layer based on index", "if", "(", "index", "===", "0", ")", "layer", "=", "display", ".", "getDefaultLayer", "(", ")", ";", "else", "if", "(", "index", ">", "0", ")", "layer", "=", "display", ".", "createLayer", "(", ")", ";", "else", "layer", "=", "display", ".", "createBuffer", "(", ")", ";", "// Add new layer", "layers", "[", "index", "]", "=", "layer", ";", "}", "return", "layer", ";", "}" ]
Returns the layer with the given index, creating it if necessary. Positive indices refer to visible layers, an index of zero refers to the default layer, and negative indices refer to buffers. @private @param {Number} index The index of the layer to retrieve. @return {Guacamole.Display.VisibleLayer|Guacamole.Layer} The layer having the given index.
[ "Returns", "the", "layer", "with", "the", "given", "index", "creating", "it", "if", "necessary", ".", "Positive", "indices", "refer", "to", "visible", "layers", "an", "index", "of", "zero", "refers", "to", "the", "default", "layer", "and", "negative", "indices", "refer", "to", "buffers", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/Client.js#L723-L744
36,187
ILLGrenoble/guacamole-common-js
src/SessionRecording.js
findFrame
function findFrame(minIndex, maxIndex, timestamp) { // Do not search if the region contains only one element if (minIndex === maxIndex) return minIndex; // Split search region into two halves var midIndex = Math.floor((minIndex + maxIndex) / 2); var midTimestamp = toRelativeTimestamp(frames[midIndex].timestamp); // If timestamp is within lesser half, search again within that half if (timestamp < midTimestamp && midIndex > minIndex) return findFrame(minIndex, midIndex - 1, timestamp); // If timestamp is within greater half, search again within that half if (timestamp > midTimestamp && midIndex < maxIndex) return findFrame(midIndex + 1, maxIndex, timestamp); // Otherwise, we lucked out and found a frame with exactly the // desired timestamp return midIndex; }
javascript
function findFrame(minIndex, maxIndex, timestamp) { // Do not search if the region contains only one element if (minIndex === maxIndex) return minIndex; // Split search region into two halves var midIndex = Math.floor((minIndex + maxIndex) / 2); var midTimestamp = toRelativeTimestamp(frames[midIndex].timestamp); // If timestamp is within lesser half, search again within that half if (timestamp < midTimestamp && midIndex > minIndex) return findFrame(minIndex, midIndex - 1, timestamp); // If timestamp is within greater half, search again within that half if (timestamp > midTimestamp && midIndex < maxIndex) return findFrame(midIndex + 1, maxIndex, timestamp); // Otherwise, we lucked out and found a frame with exactly the // desired timestamp return midIndex; }
[ "function", "findFrame", "(", "minIndex", ",", "maxIndex", ",", "timestamp", ")", "{", "// Do not search if the region contains only one element", "if", "(", "minIndex", "===", "maxIndex", ")", "return", "minIndex", ";", "// Split search region into two halves", "var", "midIndex", "=", "Math", ".", "floor", "(", "(", "minIndex", "+", "maxIndex", ")", "/", "2", ")", ";", "var", "midTimestamp", "=", "toRelativeTimestamp", "(", "frames", "[", "midIndex", "]", ".", "timestamp", ")", ";", "// If timestamp is within lesser half, search again within that half", "if", "(", "timestamp", "<", "midTimestamp", "&&", "midIndex", ">", "minIndex", ")", "return", "findFrame", "(", "minIndex", ",", "midIndex", "-", "1", ",", "timestamp", ")", ";", "// If timestamp is within greater half, search again within that half", "if", "(", "timestamp", ">", "midTimestamp", "&&", "midIndex", "<", "maxIndex", ")", "return", "findFrame", "(", "midIndex", "+", "1", ",", "maxIndex", ",", "timestamp", ")", ";", "// Otherwise, we lucked out and found a frame with exactly the", "// desired timestamp", "return", "midIndex", ";", "}" ]
Searches through the given region of frames for the frame having a relative timestamp closest to the timestamp given. @private @param {Number} minIndex The index of the first frame in the region (the frame having the smallest timestamp). @param {Number} maxIndex The index of the last frame in the region (the frame having the largest timestamp). @param {Number} timestamp The relative timestamp to search for, where zero denotes the first frame in the recording. @returns {Number} The index of the frame having a relative timestamp closest to the given value.
[ "Searches", "through", "the", "given", "region", "of", "frames", "for", "the", "frame", "having", "a", "relative", "timestamp", "closest", "to", "the", "timestamp", "given", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/SessionRecording.js#L254-L276
36,188
ILLGrenoble/guacamole-common-js
src/SessionRecording.js
replayFrame
function replayFrame(index) { var frame = frames[index]; // Replay all instructions within the retrieved frame for (var i = 0; i < frame.instructions.length; i++) { var instruction = frame.instructions[i]; playbackTunnel.receiveInstruction(instruction.opcode, instruction.args); } // Store client state if frame is flagged as a keyframe if (frame.keyframe && !frame.clientState) { playbackClient.exportState(function storeClientState(state) { frame.clientState = state; }); } }
javascript
function replayFrame(index) { var frame = frames[index]; // Replay all instructions within the retrieved frame for (var i = 0; i < frame.instructions.length; i++) { var instruction = frame.instructions[i]; playbackTunnel.receiveInstruction(instruction.opcode, instruction.args); } // Store client state if frame is flagged as a keyframe if (frame.keyframe && !frame.clientState) { playbackClient.exportState(function storeClientState(state) { frame.clientState = state; }); } }
[ "function", "replayFrame", "(", "index", ")", "{", "var", "frame", "=", "frames", "[", "index", "]", ";", "// Replay all instructions within the retrieved frame", "for", "(", "var", "i", "=", "0", ";", "i", "<", "frame", ".", "instructions", ".", "length", ";", "i", "++", ")", "{", "var", "instruction", "=", "frame", ".", "instructions", "[", "i", "]", ";", "playbackTunnel", ".", "receiveInstruction", "(", "instruction", ".", "opcode", ",", "instruction", ".", "args", ")", ";", "}", "// Store client state if frame is flagged as a keyframe", "if", "(", "frame", ".", "keyframe", "&&", "!", "frame", ".", "clientState", ")", "{", "playbackClient", ".", "exportState", "(", "function", "storeClientState", "(", "state", ")", "{", "frame", ".", "clientState", "=", "state", ";", "}", ")", ";", "}", "}" ]
Replays the instructions associated with the given frame, sending those instructions to the playback client. @private @param {Number} index The index of the frame within the frames array which should be replayed.
[ "Replays", "the", "instructions", "associated", "with", "the", "given", "frame", "sending", "those", "instructions", "to", "the", "playback", "client", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/SessionRecording.js#L287-L304
36,189
ILLGrenoble/guacamole-common-js
src/SessionRecording.js
seekToFrame
function seekToFrame(index, callback, delay) { // Abort any in-progress seek abortSeek(); // Replay frames asynchronously seekTimeout = window.setTimeout(function continueSeek() { var startIndex; // Back up until startIndex represents current state for (startIndex = index; startIndex >= 0; startIndex--) { var frame = frames[startIndex]; // If we've reached the current frame, startIndex represents // current state by definition if (startIndex === currentFrame) break; // If frame has associated absolute state, make that frame the // current state if (frame.clientState) { playbackClient.importState(frame.clientState); break; } } // Advance to frame index after current state startIndex++; var startTime = new Date().getTime(); // Replay any applicable incremental frames for (; startIndex <= index; startIndex++) { // Stop seeking if the operation is taking too long var currentTime = new Date().getTime(); if (currentTime - startTime >= MAXIMUM_SEEK_TIME) break; replayFrame(startIndex); } // Current frame is now at requested index currentFrame = startIndex - 1; // Notify of changes in position if (recording.onseek) recording.onseek(recording.getPosition()); // If the seek operation has not yet completed, schedule continuation if (currentFrame !== index) seekToFrame(index, callback, Math.max(delay - (new Date().getTime() - startTime), 0)); // Notify that the requested seek has completed else callback(); }, delay || 0); }
javascript
function seekToFrame(index, callback, delay) { // Abort any in-progress seek abortSeek(); // Replay frames asynchronously seekTimeout = window.setTimeout(function continueSeek() { var startIndex; // Back up until startIndex represents current state for (startIndex = index; startIndex >= 0; startIndex--) { var frame = frames[startIndex]; // If we've reached the current frame, startIndex represents // current state by definition if (startIndex === currentFrame) break; // If frame has associated absolute state, make that frame the // current state if (frame.clientState) { playbackClient.importState(frame.clientState); break; } } // Advance to frame index after current state startIndex++; var startTime = new Date().getTime(); // Replay any applicable incremental frames for (; startIndex <= index; startIndex++) { // Stop seeking if the operation is taking too long var currentTime = new Date().getTime(); if (currentTime - startTime >= MAXIMUM_SEEK_TIME) break; replayFrame(startIndex); } // Current frame is now at requested index currentFrame = startIndex - 1; // Notify of changes in position if (recording.onseek) recording.onseek(recording.getPosition()); // If the seek operation has not yet completed, schedule continuation if (currentFrame !== index) seekToFrame(index, callback, Math.max(delay - (new Date().getTime() - startTime), 0)); // Notify that the requested seek has completed else callback(); }, delay || 0); }
[ "function", "seekToFrame", "(", "index", ",", "callback", ",", "delay", ")", "{", "// Abort any in-progress seek", "abortSeek", "(", ")", ";", "// Replay frames asynchronously", "seekTimeout", "=", "window", ".", "setTimeout", "(", "function", "continueSeek", "(", ")", "{", "var", "startIndex", ";", "// Back up until startIndex represents current state", "for", "(", "startIndex", "=", "index", ";", "startIndex", ">=", "0", ";", "startIndex", "--", ")", "{", "var", "frame", "=", "frames", "[", "startIndex", "]", ";", "// If we've reached the current frame, startIndex represents", "// current state by definition", "if", "(", "startIndex", "===", "currentFrame", ")", "break", ";", "// If frame has associated absolute state, make that frame the", "// current state", "if", "(", "frame", ".", "clientState", ")", "{", "playbackClient", ".", "importState", "(", "frame", ".", "clientState", ")", ";", "break", ";", "}", "}", "// Advance to frame index after current state", "startIndex", "++", ";", "var", "startTime", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "// Replay any applicable incremental frames", "for", "(", ";", "startIndex", "<=", "index", ";", "startIndex", "++", ")", "{", "// Stop seeking if the operation is taking too long", "var", "currentTime", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "if", "(", "currentTime", "-", "startTime", ">=", "MAXIMUM_SEEK_TIME", ")", "break", ";", "replayFrame", "(", "startIndex", ")", ";", "}", "// Current frame is now at requested index", "currentFrame", "=", "startIndex", "-", "1", ";", "// Notify of changes in position", "if", "(", "recording", ".", "onseek", ")", "recording", ".", "onseek", "(", "recording", ".", "getPosition", "(", ")", ")", ";", "// If the seek operation has not yet completed, schedule continuation", "if", "(", "currentFrame", "!==", "index", ")", "seekToFrame", "(", "index", ",", "callback", ",", "Math", ".", "max", "(", "delay", "-", "(", "new", "Date", "(", ")", ".", "getTime", "(", ")", "-", "startTime", ")", ",", "0", ")", ")", ";", "// Notify that the requested seek has completed", "else", "callback", "(", ")", ";", "}", ",", "delay", "||", "0", ")", ";", "}" ]
Moves the playback position to the given frame, resetting the state of the playback client and replaying frames as necessary. The seek operation will proceed asynchronously. If a seek operation is already in progress, that seek is first aborted. The progress of the seek operation can be observed through the onseek handler and the provided callback. @private @param {Number} index The index of the frame which should become the new playback position. @param {function} callback The callback to invoke once the seek operation has completed. @param {Number} [delay=0] The number of milliseconds that the seek operation should be scheduled to take.
[ "Moves", "the", "playback", "position", "to", "the", "given", "frame", "resetting", "the", "state", "of", "the", "playback", "client", "and", "replaying", "frames", "as", "necessary", ".", "The", "seek", "operation", "will", "proceed", "asynchronously", ".", "If", "a", "seek", "operation", "is", "already", "in", "progress", "that", "seek", "is", "first", "aborted", ".", "The", "progress", "of", "the", "seek", "operation", "can", "be", "observed", "through", "the", "onseek", "handler", "and", "the", "provided", "callback", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/SessionRecording.js#L325-L388
36,190
ILLGrenoble/guacamole-common-js
src/SessionRecording.js
continuePlayback
function continuePlayback() { // If frames remain after advancing, schedule next frame if (currentFrame + 1 < frames.length) { // Pull the upcoming frame var next = frames[currentFrame + 1]; // Calculate the real timestamp corresponding to when the next // frame begins var nextRealTimestamp = next.timestamp - startVideoTimestamp + startRealTimestamp; // Calculate the relative delay between the current time and // the next frame start var delay = Math.max(nextRealTimestamp - new Date().getTime(), 0); // Advance to next frame after enough time has elapsed seekToFrame(currentFrame + 1, function frameDelayElapsed() { continuePlayback(); }, delay); } // Otherwise stop playback else recording.pause(); }
javascript
function continuePlayback() { // If frames remain after advancing, schedule next frame if (currentFrame + 1 < frames.length) { // Pull the upcoming frame var next = frames[currentFrame + 1]; // Calculate the real timestamp corresponding to when the next // frame begins var nextRealTimestamp = next.timestamp - startVideoTimestamp + startRealTimestamp; // Calculate the relative delay between the current time and // the next frame start var delay = Math.max(nextRealTimestamp - new Date().getTime(), 0); // Advance to next frame after enough time has elapsed seekToFrame(currentFrame + 1, function frameDelayElapsed() { continuePlayback(); }, delay); } // Otherwise stop playback else recording.pause(); }
[ "function", "continuePlayback", "(", ")", "{", "// If frames remain after advancing, schedule next frame", "if", "(", "currentFrame", "+", "1", "<", "frames", ".", "length", ")", "{", "// Pull the upcoming frame", "var", "next", "=", "frames", "[", "currentFrame", "+", "1", "]", ";", "// Calculate the real timestamp corresponding to when the next", "// frame begins", "var", "nextRealTimestamp", "=", "next", ".", "timestamp", "-", "startVideoTimestamp", "+", "startRealTimestamp", ";", "// Calculate the relative delay between the current time and", "// the next frame start", "var", "delay", "=", "Math", ".", "max", "(", "nextRealTimestamp", "-", "new", "Date", "(", ")", ".", "getTime", "(", ")", ",", "0", ")", ";", "// Advance to next frame after enough time has elapsed", "seekToFrame", "(", "currentFrame", "+", "1", ",", "function", "frameDelayElapsed", "(", ")", "{", "continuePlayback", "(", ")", ";", "}", ",", "delay", ")", ";", "}", "// Otherwise stop playback", "else", "recording", ".", "pause", "(", ")", ";", "}" ]
Advances playback to the next frame in the frames array and schedules playback of the frame following that frame based on their associated timestamps. If no frames exist after the next frame, playback is paused. @private
[ "Advances", "playback", "to", "the", "next", "frame", "in", "the", "frames", "array", "and", "schedules", "playback", "of", "the", "frame", "following", "that", "frame", "based", "on", "their", "associated", "timestamps", ".", "If", "no", "frames", "exist", "after", "the", "next", "frame", "playback", "is", "paused", "." ]
71925794155ea3fc37d2a125adbca6f8be532887
https://github.com/ILLGrenoble/guacamole-common-js/blob/71925794155ea3fc37d2a125adbca6f8be532887/src/SessionRecording.js#L407-L434
36,191
etpinard/sane-topojson
bin/shp2geo.js
getCmd
function getCmd(program, opt) { var cmd, expr; if(program==='ogr2ogr') { if(opt==='where') { expr = [ '-where ', "\"", specs.key, " IN ", "('", specs.val, "')\" ", '-clipsrc ', specs.bounds.join(' ') ].join(''); } else if(opt==='clipsrc') { expr = [ '-clipsrc ', specs.bounds.join(' ') ].join(''); } else expr = ''; cmd = [ "ogr2ogr -f GeoJSON", expr, common.geojsonDir + common.tn(r, s.name, v.name, 'geo.json'), common.wgetDir + common.srcPrefix + common.bn(r, v.src, 'shp') ].join(' '); } else if(program==='mapshaper') { cmd = [ mapshaper, common.wgetDir + common.srcPrefix + common.bn(r, v.src, 'shp'), "encoding=utf8", "-clip", common.wgetDir + common.tn(r, s.name, specs.src, 'shp'), "-filter remove-empty", "-o", common.geojsonDir + common.tn(r, s.name, v.name, 'geo.json') ].join(' '); } return cmd; }
javascript
function getCmd(program, opt) { var cmd, expr; if(program==='ogr2ogr') { if(opt==='where') { expr = [ '-where ', "\"", specs.key, " IN ", "('", specs.val, "')\" ", '-clipsrc ', specs.bounds.join(' ') ].join(''); } else if(opt==='clipsrc') { expr = [ '-clipsrc ', specs.bounds.join(' ') ].join(''); } else expr = ''; cmd = [ "ogr2ogr -f GeoJSON", expr, common.geojsonDir + common.tn(r, s.name, v.name, 'geo.json'), common.wgetDir + common.srcPrefix + common.bn(r, v.src, 'shp') ].join(' '); } else if(program==='mapshaper') { cmd = [ mapshaper, common.wgetDir + common.srcPrefix + common.bn(r, v.src, 'shp'), "encoding=utf8", "-clip", common.wgetDir + common.tn(r, s.name, specs.src, 'shp'), "-filter remove-empty", "-o", common.geojsonDir + common.tn(r, s.name, v.name, 'geo.json') ].join(' '); } return cmd; }
[ "function", "getCmd", "(", "program", ",", "opt", ")", "{", "var", "cmd", ",", "expr", ";", "if", "(", "program", "===", "'ogr2ogr'", ")", "{", "if", "(", "opt", "===", "'where'", ")", "{", "expr", "=", "[", "'-where '", ",", "\"\\\"\"", ",", "specs", ".", "key", ",", "\" IN \"", ",", "\"('\"", ",", "specs", ".", "val", ",", "\"')\\\" \"", ",", "'-clipsrc '", ",", "specs", ".", "bounds", ".", "join", "(", "' '", ")", "]", ".", "join", "(", "''", ")", ";", "}", "else", "if", "(", "opt", "===", "'clipsrc'", ")", "{", "expr", "=", "[", "'-clipsrc '", ",", "specs", ".", "bounds", ".", "join", "(", "' '", ")", "]", ".", "join", "(", "''", ")", ";", "}", "else", "expr", "=", "''", ";", "cmd", "=", "[", "\"ogr2ogr -f GeoJSON\"", ",", "expr", ",", "common", ".", "geojsonDir", "+", "common", ".", "tn", "(", "r", ",", "s", ".", "name", ",", "v", ".", "name", ",", "'geo.json'", ")", ",", "common", ".", "wgetDir", "+", "common", ".", "srcPrefix", "+", "common", ".", "bn", "(", "r", ",", "v", ".", "src", ",", "'shp'", ")", "]", ".", "join", "(", "' '", ")", ";", "}", "else", "if", "(", "program", "===", "'mapshaper'", ")", "{", "cmd", "=", "[", "mapshaper", ",", "common", ".", "wgetDir", "+", "common", ".", "srcPrefix", "+", "common", ".", "bn", "(", "r", ",", "v", ".", "src", ",", "'shp'", ")", ",", "\"encoding=utf8\"", ",", "\"-clip\"", ",", "common", ".", "wgetDir", "+", "common", ".", "tn", "(", "r", ",", "s", ".", "name", ",", "specs", ".", "src", ",", "'shp'", ")", ",", "\"-filter remove-empty\"", ",", "\"-o\"", ",", "common", ".", "geojsonDir", "+", "common", ".", "tn", "(", "r", ",", "s", ".", "name", ",", "v", ".", "name", ",", "'geo.json'", ")", "]", ".", "join", "(", "' '", ")", ";", "}", "return", "cmd", ";", "}" ]
use ogr2ogr for clip around bound use mapshaper for clip around shapefile polygons
[ "use", "ogr2ogr", "for", "clip", "around", "bound", "use", "mapshaper", "for", "clip", "around", "shapefile", "polygons" ]
3efc5797df570fc7143a121d0ca9903defb8a8d5
https://github.com/etpinard/sane-topojson/blob/3efc5797df570fc7143a121d0ca9903defb8a8d5/bin/shp2geo.js#L69-L114
36,192
kibertoad/objection-swagger
lib/converters/query-params-to-json-schema.converter.js
swaggerQueryParamsToSchema
function swaggerQueryParamsToSchema(queryModel) { const requiredFields = []; const transformedProperties = {}; _.forOwn(queryModel.items.properties, (value, key) => { if (value.required) { requiredFields.push(key); } transformedProperties[key] = { ...value }; if (!_.isNil(transformedProperties[key].required)) { delete transformedProperties[key].required; } }); return { title: queryModel.title, description: queryModel.description, additionalProperties: false, required: requiredFields, properties: transformedProperties }; }
javascript
function swaggerQueryParamsToSchema(queryModel) { const requiredFields = []; const transformedProperties = {}; _.forOwn(queryModel.items.properties, (value, key) => { if (value.required) { requiredFields.push(key); } transformedProperties[key] = { ...value }; if (!_.isNil(transformedProperties[key].required)) { delete transformedProperties[key].required; } }); return { title: queryModel.title, description: queryModel.description, additionalProperties: false, required: requiredFields, properties: transformedProperties }; }
[ "function", "swaggerQueryParamsToSchema", "(", "queryModel", ")", "{", "const", "requiredFields", "=", "[", "]", ";", "const", "transformedProperties", "=", "{", "}", ";", "_", ".", "forOwn", "(", "queryModel", ".", "items", ".", "properties", ",", "(", "value", ",", "key", ")", "=>", "{", "if", "(", "value", ".", "required", ")", "{", "requiredFields", ".", "push", "(", "key", ")", ";", "}", "transformedProperties", "[", "key", "]", "=", "{", "...", "value", "}", ";", "if", "(", "!", "_", ".", "isNil", "(", "transformedProperties", "[", "key", "]", ".", "required", ")", ")", "{", "delete", "transformedProperties", "[", "key", "]", ".", "required", ";", "}", "}", ")", ";", "return", "{", "title", ":", "queryModel", ".", "title", ",", "description", ":", "queryModel", ".", "description", ",", "additionalProperties", ":", "false", ",", "required", ":", "requiredFields", ",", "properties", ":", "transformedProperties", "}", ";", "}" ]
Transforms Swagger query params into correct JSON Schema @param {Object} queryModel - Swagger query params model @returns {Object} JSON Schema object
[ "Transforms", "Swagger", "query", "params", "into", "correct", "JSON", "Schema" ]
2109b58ce323e78252729a46bcc94e617035b541
https://github.com/kibertoad/objection-swagger/blob/2109b58ce323e78252729a46bcc94e617035b541/lib/converters/query-params-to-json-schema.converter.js#L9-L32
36,193
kibertoad/objection-swagger
lib/objection-swagger.js
generateSchemaRaw
function generateSchemaRaw(modelParam, opts = {}) { validate.notNil(modelParam, "modelParam is mandatory"); let models; if (_.isArray(modelParam)) { models = modelParam; } else if (_.isObject(modelParam)) { models = [modelParam]; } else { throw new Error("modelParam should be an object or an array of objects"); } return models.map(model => { const processedSchema = modelTransformer.transformJsonSchemaFromModel( model, opts ); return { name: model.name, schema: processedSchema }; }); }
javascript
function generateSchemaRaw(modelParam, opts = {}) { validate.notNil(modelParam, "modelParam is mandatory"); let models; if (_.isArray(modelParam)) { models = modelParam; } else if (_.isObject(modelParam)) { models = [modelParam]; } else { throw new Error("modelParam should be an object or an array of objects"); } return models.map(model => { const processedSchema = modelTransformer.transformJsonSchemaFromModel( model, opts ); return { name: model.name, schema: processedSchema }; }); }
[ "function", "generateSchemaRaw", "(", "modelParam", ",", "opts", "=", "{", "}", ")", "{", "validate", ".", "notNil", "(", "modelParam", ",", "\"modelParam is mandatory\"", ")", ";", "let", "models", ";", "if", "(", "_", ".", "isArray", "(", "modelParam", ")", ")", "{", "models", "=", "modelParam", ";", "}", "else", "if", "(", "_", ".", "isObject", "(", "modelParam", ")", ")", "{", "models", "=", "[", "modelParam", "]", ";", "}", "else", "{", "throw", "new", "Error", "(", "\"modelParam should be an object or an array of objects\"", ")", ";", "}", "return", "models", ".", "map", "(", "model", "=>", "{", "const", "processedSchema", "=", "modelTransformer", ".", "transformJsonSchemaFromModel", "(", "model", ",", "opts", ")", ";", "return", "{", "name", ":", "model", ".", "name", ",", "schema", ":", "processedSchema", "}", ";", "}", ")", ";", "}" ]
Generates JSON schemas from Objection.js models @param {Model|Model[]} modelParam - model(s) to generate schemas for @param {Options} opts @returns {GeneratedSwagger[]} generated JSON schemas as objects
[ "Generates", "JSON", "schemas", "from", "Objection", ".", "js", "models" ]
2109b58ce323e78252729a46bcc94e617035b541
https://github.com/kibertoad/objection-swagger/blob/2109b58ce323e78252729a46bcc94e617035b541/lib/objection-swagger.js#L44-L67
36,194
kibertoad/objection-swagger
lib/objection-swagger.js
saveSchema
function saveSchema(modelParam, targetDir, opts = {}) { validate.notNil(modelParam, "modelParam is mandatory"); validate.notNil(targetDir, "targetDir is mandatory"); const yamlSchemaContainers = generateSchema(modelParam, opts); return yamlWriter.writeYamlsToFs(yamlSchemaContainers, targetDir, opts); }
javascript
function saveSchema(modelParam, targetDir, opts = {}) { validate.notNil(modelParam, "modelParam is mandatory"); validate.notNil(targetDir, "targetDir is mandatory"); const yamlSchemaContainers = generateSchema(modelParam, opts); return yamlWriter.writeYamlsToFs(yamlSchemaContainers, targetDir, opts); }
[ "function", "saveSchema", "(", "modelParam", ",", "targetDir", ",", "opts", "=", "{", "}", ")", "{", "validate", ".", "notNil", "(", "modelParam", ",", "\"modelParam is mandatory\"", ")", ";", "validate", ".", "notNil", "(", "targetDir", ",", "\"targetDir is mandatory\"", ")", ";", "const", "yamlSchemaContainers", "=", "generateSchema", "(", "modelParam", ",", "opts", ")", ";", "return", "yamlWriter", ".", "writeYamlsToFs", "(", "yamlSchemaContainers", ",", "targetDir", ",", "opts", ")", ";", "}" ]
Generates and saves into specified directory JSON schema files for inclusion in Swagger specifications from given Objection.js models @param {Model|Model[]} modelParam - model(s) to generate schemas for @param {string} targetDir - directory to write generated schemas to. Do not add '/' to the end. @param {Options} opts @returns {Promise} - promise that is resolved after schemas are written
[ "Generates", "and", "saves", "into", "specified", "directory", "JSON", "schema", "files", "for", "inclusion", "in", "Swagger", "specifications", "from", "given", "Objection", ".", "js", "models" ]
2109b58ce323e78252729a46bcc94e617035b541
https://github.com/kibertoad/objection-swagger/blob/2109b58ce323e78252729a46bcc94e617035b541/lib/objection-swagger.js#L77-L83
36,195
kibertoad/objection-swagger
lib/objection-swagger.js
saveNonModelSchema
function saveNonModelSchema(schemaParam, targetDir, opts = {}) { validate.notNil(schemaParam, "schemaParam is mandatory"); validate.notNil(targetDir, "targetDir is mandatory"); if (!Array.isArray(schemaParam)) { schemaParam = [schemaParam]; } const yamlSchemaContainers = schemaParam.map(schema => { const processedSchema = jsonSchemaTransformer.transformSchema(schema, opts); return { name: schema.title, schema: yaml.dump(processedSchema) }; }); return yamlWriter.writeYamlsToFs(yamlSchemaContainers, targetDir, opts); }
javascript
function saveNonModelSchema(schemaParam, targetDir, opts = {}) { validate.notNil(schemaParam, "schemaParam is mandatory"); validate.notNil(targetDir, "targetDir is mandatory"); if (!Array.isArray(schemaParam)) { schemaParam = [schemaParam]; } const yamlSchemaContainers = schemaParam.map(schema => { const processedSchema = jsonSchemaTransformer.transformSchema(schema, opts); return { name: schema.title, schema: yaml.dump(processedSchema) }; }); return yamlWriter.writeYamlsToFs(yamlSchemaContainers, targetDir, opts); }
[ "function", "saveNonModelSchema", "(", "schemaParam", ",", "targetDir", ",", "opts", "=", "{", "}", ")", "{", "validate", ".", "notNil", "(", "schemaParam", ",", "\"schemaParam is mandatory\"", ")", ";", "validate", ".", "notNil", "(", "targetDir", ",", "\"targetDir is mandatory\"", ")", ";", "if", "(", "!", "Array", ".", "isArray", "(", "schemaParam", ")", ")", "{", "schemaParam", "=", "[", "schemaParam", "]", ";", "}", "const", "yamlSchemaContainers", "=", "schemaParam", ".", "map", "(", "schema", "=>", "{", "const", "processedSchema", "=", "jsonSchemaTransformer", ".", "transformSchema", "(", "schema", ",", "opts", ")", ";", "return", "{", "name", ":", "schema", ".", "title", ",", "schema", ":", "yaml", ".", "dump", "(", "processedSchema", ")", "}", ";", "}", ")", ";", "return", "yamlWriter", ".", "writeYamlsToFs", "(", "yamlSchemaContainers", ",", "targetDir", ",", "opts", ")", ";", "}" ]
Generates and saves into specified directory JSON-schema YAML files for inclusion in Swagger specifications from given JSON-schemas @param {Object|Object[]} schemaParam - JSON-Schema(s) to generate yamls for. Title param is used as a filename @param {string} targetDir - directory to write generated schemas to. Do not add '/' to the end. @param {Options} opts @returns {Promise} - promise that is resolved after yamls are written
[ "Generates", "and", "saves", "into", "specified", "directory", "JSON", "-", "schema", "YAML", "files", "for", "inclusion", "in", "Swagger", "specifications", "from", "given", "JSON", "-", "schemas" ]
2109b58ce323e78252729a46bcc94e617035b541
https://github.com/kibertoad/objection-swagger/blob/2109b58ce323e78252729a46bcc94e617035b541/lib/objection-swagger.js#L93-L110
36,196
kibertoad/objection-swagger
lib/objection-swagger.js
saveQueryParamSchema
function saveQueryParamSchema(schemaParam, targetDir, opts = {}) { validate.notNil(schemaParam, "schemaParam is mandatory"); validate.notNil(targetDir, "targetDir is mandatory"); if (!Array.isArray(schemaParam)) { schemaParam = [schemaParam]; } const yamlSchemaContainers = schemaParam.map(schema => { const modelSchema = jsonSchemaTransformer.transformSchema(schema, opts); const queryParamSchema = queryParamTransformer.transformIntoQueryParamSchema( modelSchema ); return { name: schema.title, schema: yaml.dump(queryParamSchema) }; }); return yamlWriter.writeYamlsToFs(yamlSchemaContainers, targetDir, opts); }
javascript
function saveQueryParamSchema(schemaParam, targetDir, opts = {}) { validate.notNil(schemaParam, "schemaParam is mandatory"); validate.notNil(targetDir, "targetDir is mandatory"); if (!Array.isArray(schemaParam)) { schemaParam = [schemaParam]; } const yamlSchemaContainers = schemaParam.map(schema => { const modelSchema = jsonSchemaTransformer.transformSchema(schema, opts); const queryParamSchema = queryParamTransformer.transformIntoQueryParamSchema( modelSchema ); return { name: schema.title, schema: yaml.dump(queryParamSchema) }; }); return yamlWriter.writeYamlsToFs(yamlSchemaContainers, targetDir, opts); }
[ "function", "saveQueryParamSchema", "(", "schemaParam", ",", "targetDir", ",", "opts", "=", "{", "}", ")", "{", "validate", ".", "notNil", "(", "schemaParam", ",", "\"schemaParam is mandatory\"", ")", ";", "validate", ".", "notNil", "(", "targetDir", ",", "\"targetDir is mandatory\"", ")", ";", "if", "(", "!", "Array", ".", "isArray", "(", "schemaParam", ")", ")", "{", "schemaParam", "=", "[", "schemaParam", "]", ";", "}", "const", "yamlSchemaContainers", "=", "schemaParam", ".", "map", "(", "schema", "=>", "{", "const", "modelSchema", "=", "jsonSchemaTransformer", ".", "transformSchema", "(", "schema", ",", "opts", ")", ";", "const", "queryParamSchema", "=", "queryParamTransformer", ".", "transformIntoQueryParamSchema", "(", "modelSchema", ")", ";", "return", "{", "name", ":", "schema", ".", "title", ",", "schema", ":", "yaml", ".", "dump", "(", "queryParamSchema", ")", "}", ";", "}", ")", ";", "return", "yamlWriter", ".", "writeYamlsToFs", "(", "yamlSchemaContainers", ",", "targetDir", ",", "opts", ")", ";", "}" ]
Generates and saves into specified directory JSON-schema YAML files for inclusion in Swagger query param specifications from given JSON-schemas @param {Object|Object[]} schemaParam - JSON-Schema(s) to generate yamls for. Title param is used as a filename @param {string} targetDir - directory to write generated schemas to. Do not add '/' to the end. @param {Options} opts @returns {Promise} - promise that is resolved after yamls are written
[ "Generates", "and", "saves", "into", "specified", "directory", "JSON", "-", "schema", "YAML", "files", "for", "inclusion", "in", "Swagger", "query", "param", "specifications", "from", "given", "JSON", "-", "schemas" ]
2109b58ce323e78252729a46bcc94e617035b541
https://github.com/kibertoad/objection-swagger/blob/2109b58ce323e78252729a46bcc94e617035b541/lib/objection-swagger.js#L120-L140
36,197
ascartabelli/lamb
src/privates/_toInteger.js
_toInteger
function _toInteger (value) { var n = +value; if (n !== n) { // eslint-disable-line no-self-compare return 0; } else if (n % 1 === 0) { return n; } else { return Math.floor(Math.abs(n)) * (n < 0 ? -1 : 1); } }
javascript
function _toInteger (value) { var n = +value; if (n !== n) { // eslint-disable-line no-self-compare return 0; } else if (n % 1 === 0) { return n; } else { return Math.floor(Math.abs(n)) * (n < 0 ? -1 : 1); } }
[ "function", "_toInteger", "(", "value", ")", "{", "var", "n", "=", "+", "value", ";", "if", "(", "n", "!==", "n", ")", "{", "// eslint-disable-line no-self-compare", "return", "0", ";", "}", "else", "if", "(", "n", "%", "1", "===", "0", ")", "{", "return", "n", ";", "}", "else", "{", "return", "Math", ".", "floor", "(", "Math", ".", "abs", "(", "n", ")", ")", "*", "(", "n", "<", "0", "?", "-", "1", ":", "1", ")", ";", "}", "}" ]
Converts a value to an integer. @private @param {*} value @returns {Number}
[ "Converts", "a", "value", "to", "an", "integer", "." ]
d36e45945c4789e4f1a2d8805936514b53f32362
https://github.com/ascartabelli/lamb/blob/d36e45945c4789e4f1a2d8805936514b53f32362/src/privates/_toInteger.js#L7-L17
36,198
sven-piller/eslint-formatter-markdown
markdown.js
renderStats
function renderStats(stats) { /** * Creates table Header if necessary * @param {string} type error or warning * @returns {string} The formatted string */ function injectHeader(type) { return (stats[type]) ? '| rule | count | visual |\n| --- | --- | --- |\n' : ''; } /** * renders templates for each rule * @param {string} type error or warning * @returns {string} The formatted string, pluralized where necessary */ function output(type) { var statstype = stats[type]; return injectHeader(type) + lodash.map(statstype, function (ruleStats, ruleId) { return statsRowTemplate({ ruleId: ruleId, ruleCount: ruleStats, visual: lodash.repeat('X', lodash.min([ruleStats, 20])) }); }, '').join(''); } /** * render template for severity * @param {string} type severity * @returns {string} template */ function renderTemplate(type) { var lcType = lodash.lowerCase(type); if (lodash.size(stats[lcType])) { return statsTemplate({ title: '### ' + type, items: output(lcType) }); } else { return ''; } } return renderTemplate('Errors') + renderTemplate('Warnings'); }
javascript
function renderStats(stats) { /** * Creates table Header if necessary * @param {string} type error or warning * @returns {string} The formatted string */ function injectHeader(type) { return (stats[type]) ? '| rule | count | visual |\n| --- | --- | --- |\n' : ''; } /** * renders templates for each rule * @param {string} type error or warning * @returns {string} The formatted string, pluralized where necessary */ function output(type) { var statstype = stats[type]; return injectHeader(type) + lodash.map(statstype, function (ruleStats, ruleId) { return statsRowTemplate({ ruleId: ruleId, ruleCount: ruleStats, visual: lodash.repeat('X', lodash.min([ruleStats, 20])) }); }, '').join(''); } /** * render template for severity * @param {string} type severity * @returns {string} template */ function renderTemplate(type) { var lcType = lodash.lowerCase(type); if (lodash.size(stats[lcType])) { return statsTemplate({ title: '### ' + type, items: output(lcType) }); } else { return ''; } } return renderTemplate('Errors') + renderTemplate('Warnings'); }
[ "function", "renderStats", "(", "stats", ")", "{", "/**\n * Creates table Header if necessary\n * @param {string} type error or warning\n * @returns {string} The formatted string\n */", "function", "injectHeader", "(", "type", ")", "{", "return", "(", "stats", "[", "type", "]", ")", "?", "'| rule | count | visual |\\n| --- | --- | --- |\\n'", ":", "''", ";", "}", "/**\n * renders templates for each rule\n * @param {string} type error or warning\n * @returns {string} The formatted string, pluralized where necessary\n */", "function", "output", "(", "type", ")", "{", "var", "statstype", "=", "stats", "[", "type", "]", ";", "return", "injectHeader", "(", "type", ")", "+", "lodash", ".", "map", "(", "statstype", ",", "function", "(", "ruleStats", ",", "ruleId", ")", "{", "return", "statsRowTemplate", "(", "{", "ruleId", ":", "ruleId", ",", "ruleCount", ":", "ruleStats", ",", "visual", ":", "lodash", ".", "repeat", "(", "'X'", ",", "lodash", ".", "min", "(", "[", "ruleStats", ",", "20", "]", ")", ")", "}", ")", ";", "}", ",", "''", ")", ".", "join", "(", "''", ")", ";", "}", "/**\n * render template for severity\n * @param {string} type severity\n * @returns {string} template\n */", "function", "renderTemplate", "(", "type", ")", "{", "var", "lcType", "=", "lodash", ".", "lowerCase", "(", "type", ")", ";", "if", "(", "lodash", ".", "size", "(", "stats", "[", "lcType", "]", ")", ")", "{", "return", "statsTemplate", "(", "{", "title", ":", "'### '", "+", "type", ",", "items", ":", "output", "(", "lcType", ")", "}", ")", ";", "}", "else", "{", "return", "''", ";", "}", "}", "return", "renderTemplate", "(", "'Errors'", ")", "+", "renderTemplate", "(", "'Warnings'", ")", ";", "}" ]
Renders MARKDOWN for stats @param {Object} stats the rules and their stats @returns {string} The formatted string, pluralized where necessary
[ "Renders", "MARKDOWN", "for", "stats" ]
46fc4cb074b1f599f02df67d814a6a83b37de060
https://github.com/sven-piller/eslint-formatter-markdown/blob/46fc4cb074b1f599f02df67d814a6a83b37de060/markdown.js#L64-L109
36,199
sven-piller/eslint-formatter-markdown
markdown.js
output
function output(type) { var statstype = stats[type]; return injectHeader(type) + lodash.map(statstype, function (ruleStats, ruleId) { return statsRowTemplate({ ruleId: ruleId, ruleCount: ruleStats, visual: lodash.repeat('X', lodash.min([ruleStats, 20])) }); }, '').join(''); }
javascript
function output(type) { var statstype = stats[type]; return injectHeader(type) + lodash.map(statstype, function (ruleStats, ruleId) { return statsRowTemplate({ ruleId: ruleId, ruleCount: ruleStats, visual: lodash.repeat('X', lodash.min([ruleStats, 20])) }); }, '').join(''); }
[ "function", "output", "(", "type", ")", "{", "var", "statstype", "=", "stats", "[", "type", "]", ";", "return", "injectHeader", "(", "type", ")", "+", "lodash", ".", "map", "(", "statstype", ",", "function", "(", "ruleStats", ",", "ruleId", ")", "{", "return", "statsRowTemplate", "(", "{", "ruleId", ":", "ruleId", ",", "ruleCount", ":", "ruleStats", ",", "visual", ":", "lodash", ".", "repeat", "(", "'X'", ",", "lodash", ".", "min", "(", "[", "ruleStats", ",", "20", "]", ")", ")", "}", ")", ";", "}", ",", "''", ")", ".", "join", "(", "''", ")", ";", "}" ]
renders templates for each rule @param {string} type error or warning @returns {string} The formatted string, pluralized where necessary
[ "renders", "templates", "for", "each", "rule" ]
46fc4cb074b1f599f02df67d814a6a83b37de060
https://github.com/sven-piller/eslint-formatter-markdown/blob/46fc4cb074b1f599f02df67d814a6a83b37de060/markdown.js#L80-L89