repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
FormidableLabs/nodejs-dashboard
lib/views/index.js
function (customizations, layoutConfig) { var customization = customizations[layoutConfig.view.type]; if (!customization) { return layoutConfig; } return _.merge(layoutConfig, { view: customization }); }
javascript
function (customizations, layoutConfig) { var customization = customizations[layoutConfig.view.type]; if (!customization) { return layoutConfig; } return _.merge(layoutConfig, { view: customization }); }
[ "function", "(", "customizations", ",", "layoutConfig", ")", "{", "var", "customization", "=", "customizations", "[", "layoutConfig", ".", "view", ".", "type", "]", ";", "if", "(", "!", "customization", ")", "{", "return", "layoutConfig", ";", "}", "return",...
Customize view types based on a settings class
[ "Customize", "view", "types", "based", "on", "a", "settings", "class" ]
74ab60f04301476a6e78c21823bb8b8ffc086f5b
https://github.com/FormidableLabs/nodejs-dashboard/blob/74ab60f04301476a6e78c21823bb8b8ffc086f5b/lib/views/index.js#L32-L38
train
FormidableLabs/nodejs-dashboard
lib/providers/metrics-provider.js
MetricsProvider
function MetricsProvider(screen) { /** * Setup the process to aggregate the data as and when it is necessary. * * @returns {void} */ var setupAggregation = function setupAggregation() { // construct the aggregation container this._aggregation = _.reduce(AGGREGATE_TIME_...
javascript
function MetricsProvider(screen) { /** * Setup the process to aggregate the data as and when it is necessary. * * @returns {void} */ var setupAggregation = function setupAggregation() { // construct the aggregation container this._aggregation = _.reduce(AGGREGATE_TIME_...
[ "function", "MetricsProvider", "(", "screen", ")", "{", "/**\n * Setup the process to aggregate the data as and when it is necessary.\n *\n * @returns {void}\n */", "var", "setupAggregation", "=", "function", "setupAggregation", "(", ")", "{", "// construct the aggregat...
This is the constructor for the MetricsProvider @param {Object} screen The blessed screen object. @returns {void}
[ "This", "is", "the", "constructor", "for", "the", "MetricsProvider" ]
74ab60f04301476a6e78c21823bb8b8ffc086f5b
https://github.com/FormidableLabs/nodejs-dashboard/blob/74ab60f04301476a6e78c21823bb8b8ffc086f5b/lib/providers/metrics-provider.js#L27-L77
train
FormidableLabs/nodejs-dashboard
lib/providers/metrics-provider.js
getInitializedAverage
function getInitializedAverage(data) { return _.reduce(data, function (prev, a, dataKey) { // create a first-level object of the key prev[dataKey] = {}; _.each(data[dataKey], function (b, dataMetricKey) { // the metrics are properties inside this object prev[dataKey][dataMetricKey...
javascript
function getInitializedAverage(data) { return _.reduce(data, function (prev, a, dataKey) { // create a first-level object of the key prev[dataKey] = {}; _.each(data[dataKey], function (b, dataMetricKey) { // the metrics are properties inside this object prev[dataKey][dataMetricKey...
[ "function", "getInitializedAverage", "(", "data", ")", "{", "return", "_", ".", "reduce", "(", "data", ",", "function", "(", "prev", ",", "a", ",", "dataKey", ")", "{", "// create a first-level object of the key", "prev", "[", "dataKey", "]", "=", "{", "}", ...
Given a metric data object, construct an initialized average. @param {Object} data The metric data received. @returns {Object} The initialized average object is returned.
[ "Given", "a", "metric", "data", "object", "construct", "an", "initialized", "average", "." ]
74ab60f04301476a6e78c21823bb8b8ffc086f5b
https://github.com/FormidableLabs/nodejs-dashboard/blob/74ab60f04301476a6e78c21823bb8b8ffc086f5b/lib/providers/metrics-provider.js#L298-L310
train
FormidableLabs/nodejs-dashboard
lib/providers/metrics-provider.js
aggregateMetrics
function aggregateMetrics(currentTime, metricData) { var aggregateKey; /** * Place aggregate data into the specified slot. If the current zoom * level matches the aggregate level, the data is emitted to keep the * display in sync. * * @param {Number} index * The desired slot for ...
javascript
function aggregateMetrics(currentTime, metricData) { var aggregateKey; /** * Place aggregate data into the specified slot. If the current zoom * level matches the aggregate level, the data is emitted to keep the * display in sync. * * @param {Number} index * The desired slot for ...
[ "function", "aggregateMetrics", "(", "currentTime", ",", "metricData", ")", "{", "var", "aggregateKey", ";", "/**\n * Place aggregate data into the specified slot. If the current zoom\n * level matches the aggregate level, the data is emitted to keep the\n * display in sync.\n ...
Perform event-driven aggregation at all configured units of time. @param {Number} currentTime The current time of the aggregation. @param {Object} metricData The metric data template received. @this MetricsProvider @returns {void}
[ "Perform", "event", "-", "driven", "aggregation", "at", "all", "configured", "units", "of", "time", "." ]
74ab60f04301476a6e78c21823bb8b8ffc086f5b
https://github.com/FormidableLabs/nodejs-dashboard/blob/74ab60f04301476a6e78c21823bb8b8ffc086f5b/lib/providers/metrics-provider.js#L326-L475
train
FormidableLabs/nodejs-dashboard
lib/providers/metrics-provider.js
getAveragedAggregate
function getAveragedAggregate(rows, startIndex, endIndex) { var averagedAggregate = getInitializedAverage(metricData); // this is the number of elements we will aggregate var aggregateCount = endIndex - startIndex + 1; // you can compute an average of a set of numbers two ways ...
javascript
function getAveragedAggregate(rows, startIndex, endIndex) { var averagedAggregate = getInitializedAverage(metricData); // this is the number of elements we will aggregate var aggregateCount = endIndex - startIndex + 1; // you can compute an average of a set of numbers two ways ...
[ "function", "getAveragedAggregate", "(", "rows", ",", "startIndex", ",", "endIndex", ")", "{", "var", "averagedAggregate", "=", "getInitializedAverage", "(", "metricData", ")", ";", "// this is the number of elements we will aggregate", "var", "aggregateCount", "=", "endI...
After having detected a new sampling, aggregate the relevant data points @param {Object[]} rows The array reference. @param {Number} startIndex The starting index to derive an average. @param {Number} endIndex The ending index to derive an average. @returns {void}
[ "After", "having", "detected", "a", "new", "sampling", "aggregate", "the", "relevant", "data", "points" ]
74ab60f04301476a6e78c21823bb8b8ffc086f5b
https://github.com/FormidableLabs/nodejs-dashboard/blob/74ab60f04301476a6e78c21823bb8b8ffc086f5b/lib/providers/metrics-provider.js#L393-L420
train
FormidableLabs/nodejs-dashboard
lib/providers/metrics-provider.js
getFixedScrollOffset
function getFixedScrollOffset(offset, length) { if (offset && length + offset <= limit) { return Math.min(limit - length, 0); } return Math.min(offset, 0); }
javascript
function getFixedScrollOffset(offset, length) { if (offset && length + offset <= limit) { return Math.min(limit - length, 0); } return Math.min(offset, 0); }
[ "function", "getFixedScrollOffset", "(", "offset", ",", "length", ")", "{", "if", "(", "offset", "&&", "length", "+", "offset", "<=", "limit", ")", "{", "return", "Math", ".", "min", "(", "limit", "-", "length", ",", "0", ")", ";", "}", "return", "Ma...
Given an offset and length, get the corrected offset. @param {Number} offset The current offset value. @param {Number} length The length of available data to offset. @returns {Number} The corrected scroll offset is returned.
[ "Given", "an", "offset", "and", "length", "get", "the", "corrected", "offset", "." ]
74ab60f04301476a6e78c21823bb8b8ffc086f5b
https://github.com/FormidableLabs/nodejs-dashboard/blob/74ab60f04301476a6e78c21823bb8b8ffc086f5b/lib/providers/metrics-provider.js#L532-L537
train
CodeboxIDE/codebox
lib/utils/logger.js
function(logType, logSection) { if (!enabled) return; var args = Array.prototype.slice.call(arguments, 2); args.splice(0, 0, colors[logType][0]+"["+logType+"]"+colors[logType][1]+"["+logSection+"]"); console.log.apply(console, args); }
javascript
function(logType, logSection) { if (!enabled) return; var args = Array.prototype.slice.call(arguments, 2); args.splice(0, 0, colors[logType][0]+"["+logType+"]"+colors[logType][1]+"["+logSection+"]"); console.log.apply(console, args); }
[ "function", "(", "logType", ",", "logSection", ")", "{", "if", "(", "!", "enabled", ")", "return", ";", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "2", ")", ";", "args", ".", "splice", "(", "0",...
Base print method
[ "Base", "print", "method" ]
98b4710f1bdba615dddbab56011a86cd5f16897b
https://github.com/CodeboxIDE/codebox/blob/98b4710f1bdba615dddbab56011a86cd5f16897b/lib/utils/logger.js#L14-L20
train
CodeboxIDE/codebox
editor/utils/taphold.js
mousemove_callback
function mousemove_callback(e) { var x = e.pageX || e.originalEvent.touches[0].pageX; var y = e.pageY || e.originalEvent.touches[0].pageY; if (Math.abs(oX - x) > maxMove || Math.abs(oY - y) > maxMove) { if (timeout) clearTimeout(timeout); } }
javascript
function mousemove_callback(e) { var x = e.pageX || e.originalEvent.touches[0].pageX; var y = e.pageY || e.originalEvent.touches[0].pageY; if (Math.abs(oX - x) > maxMove || Math.abs(oY - y) > maxMove) { if (timeout) clearTimeout(timeout); } }
[ "function", "mousemove_callback", "(", "e", ")", "{", "var", "x", "=", "e", ".", "pageX", "||", "e", ".", "originalEvent", ".", "touches", "[", "0", "]", ".", "pageX", ";", "var", "y", "=", "e", ".", "pageY", "||", "e", ".", "originalEvent", ".", ...
mousemove or touchmove callback
[ "mousemove", "or", "touchmove", "callback" ]
98b4710f1bdba615dddbab56011a86cd5f16897b
https://github.com/CodeboxIDE/codebox/blob/98b4710f1bdba615dddbab56011a86cd5f16897b/editor/utils/taphold.js#L26-L33
train
CodeboxIDE/codebox
editor/models/package.js
function() { var context, main, pkgRequireConfig, pkgRequire, that = this var d = Q.defer(); if (!this.get("browser")) return Q(); logger.log("Load", this.get("name")); getScript(this.url()+"/pkg-build.js", function(err) { if (!err) return d.resolve(); ...
javascript
function() { var context, main, pkgRequireConfig, pkgRequire, that = this var d = Q.defer(); if (!this.get("browser")) return Q(); logger.log("Load", this.get("name")); getScript(this.url()+"/pkg-build.js", function(err) { if (!err) return d.resolve(); ...
[ "function", "(", ")", "{", "var", "context", ",", "main", ",", "pkgRequireConfig", ",", "pkgRequire", ",", "that", "=", "this", "var", "d", "=", "Q", ".", "defer", "(", ")", ";", "if", "(", "!", "this", ".", "get", "(", "\"browser\"", ")", ")", "...
Load the addon
[ "Load", "the", "addon" ]
98b4710f1bdba615dddbab56011a86cd5f16897b
https://github.com/CodeboxIDE/codebox/blob/98b4710f1bdba615dddbab56011a86cd5f16897b/editor/models/package.js#L59-L74
train
CodeboxIDE/codebox
lib/packages.js
cleanFolder
function cleanFolder(outPath) { try { var stat = fs.lstatSync(outPath); if (stat.isDirectory()) { wrench.rmdirSyncRecursive(outPath); } else { fs.unlinkSync(outPath); } } catch (e) { if (e.code != "ENOENT") throw e; } }
javascript
function cleanFolder(outPath) { try { var stat = fs.lstatSync(outPath); if (stat.isDirectory()) { wrench.rmdirSyncRecursive(outPath); } else { fs.unlinkSync(outPath); } } catch (e) { if (e.code != "ENOENT") throw e; } }
[ "function", "cleanFolder", "(", "outPath", ")", "{", "try", "{", "var", "stat", "=", "fs", ".", "lstatSync", "(", "outPath", ")", ";", "if", "(", "stat", ".", "isDirectory", "(", ")", ")", "{", "wrench", ".", "rmdirSyncRecursive", "(", "outPath", ")", ...
Remove output if folder or symlink
[ "Remove", "output", "if", "folder", "or", "symlink" ]
98b4710f1bdba615dddbab56011a86cd5f16897b
https://github.com/CodeboxIDE/codebox/blob/98b4710f1bdba615dddbab56011a86cd5f16897b/lib/packages.js#L17-L28
train
dbashford/textract
lib/extract.js
cleanseText
function cleanseText( options, cb ) { return function( error, text ) { if ( !error ) { // clean up text text = util.replaceBadCharacters( text ); if ( options.preserveLineBreaks || options.preserveOnlyMultipleLineBreaks ) { if ( options.preserveOnlyMultipleLineBreaks ) { text ...
javascript
function cleanseText( options, cb ) { return function( error, text ) { if ( !error ) { // clean up text text = util.replaceBadCharacters( text ); if ( options.preserveLineBreaks || options.preserveOnlyMultipleLineBreaks ) { if ( options.preserveOnlyMultipleLineBreaks ) { text ...
[ "function", "cleanseText", "(", "options", ",", "cb", ")", "{", "return", "function", "(", "error", ",", "text", ")", "{", "if", "(", "!", "error", ")", "{", "// clean up text", "text", "=", "util", ".", "replaceBadCharacters", "(", "text", ")", ";", "...
global, all file type, content cleansing
[ "global", "all", "file", "type", "content", "cleansing" ]
dc6004b78619c169044433d24a862228af6895fa
https://github.com/dbashford/textract/blob/dc6004b78619c169044433d24a862228af6895fa/lib/extract.js#L53-L76
train
dbashford/textract
lib/util.js
replaceBadCharacters
function replaceBadCharacters( text ) { var i, repl; for ( i = 0; i < rLen; i++ ) { repl = replacements[i]; text = text.replace( repl[0], repl[1] ); } return text; }
javascript
function replaceBadCharacters( text ) { var i, repl; for ( i = 0; i < rLen; i++ ) { repl = replacements[i]; text = text.replace( repl[0], repl[1] ); } return text; }
[ "function", "replaceBadCharacters", "(", "text", ")", "{", "var", "i", ",", "repl", ";", "for", "(", "i", "=", "0", ";", "i", "<", "rLen", ";", "i", "++", ")", "{", "repl", "=", "replacements", "[", "i", "]", ";", "text", "=", "text", ".", "rep...
replace nasty quotes with simple ones
[ "replace", "nasty", "quotes", "with", "simple", "ones" ]
dc6004b78619c169044433d24a862228af6895fa
https://github.com/dbashford/textract/blob/dc6004b78619c169044433d24a862228af6895fa/lib/util.js#L21-L28
train
dbashford/textract
lib/util.js
runExecIntoFile
function runExecIntoFile( label, filePath, options, execOptions, genCommand, cb ) { // escape the file paths var fileTempOutPath = path.join( outDir, path.basename( filePath, path.extname( filePath ) ) ) , escapedFilePath = filePath.replace( /\s/g, '\\ ' ) , escapedFileTempOutPath = fileTempOutPath.replace(...
javascript
function runExecIntoFile( label, filePath, options, execOptions, genCommand, cb ) { // escape the file paths var fileTempOutPath = path.join( outDir, path.basename( filePath, path.extname( filePath ) ) ) , escapedFilePath = filePath.replace( /\s/g, '\\ ' ) , escapedFileTempOutPath = fileTempOutPath.replace(...
[ "function", "runExecIntoFile", "(", "label", ",", "filePath", ",", "options", ",", "execOptions", ",", "genCommand", ",", "cb", ")", "{", "// escape the file paths", "var", "fileTempOutPath", "=", "path", ".", "join", "(", "outDir", ",", "path", ".", "basename...
1) builds an exec command using provided `genCommand` callback 2) runs that command against an input file path resulting in an output file 3) reads that output file in 4) cleans the output file up 5) executes a callback with the contents of the file @param {string} label Name for the extractor, e.g. `Tesseract` @param...
[ "1", ")", "builds", "an", "exec", "command", "using", "provided", "genCommand", "callback", "2", ")", "runs", "that", "command", "against", "an", "input", "file", "path", "resulting", "in", "an", "output", "file", "3", ")", "reads", "that", "output", "file...
dc6004b78619c169044433d24a862228af6895fa
https://github.com/dbashford/textract/blob/dc6004b78619c169044433d24a862228af6895fa/lib/util.js#L109-L154
train
dbashford/textract
lib/extractors/doc-osx.js
extractText
function extractText( filePath, options, cb ) { var result = '' , error = null , textutil = spawn( 'textutil', ['-convert', 'txt', '-stdout', filePath] ) ; textutil.stdout.on( 'data', function( buffer ) { result += buffer.toString(); }); textutil.stderr.on( 'error', function( buffer ) { if...
javascript
function extractText( filePath, options, cb ) { var result = '' , error = null , textutil = spawn( 'textutil', ['-convert', 'txt', '-stdout', filePath] ) ; textutil.stdout.on( 'data', function( buffer ) { result += buffer.toString(); }); textutil.stderr.on( 'error', function( buffer ) { if...
[ "function", "extractText", "(", "filePath", ",", "options", ",", "cb", ")", "{", "var", "result", "=", "''", ",", "error", "=", "null", ",", "textutil", "=", "spawn", "(", "'textutil'", ",", "[", "'-convert'", ",", "'txt'", ",", "'-stdout'", ",", "file...
textutil -convert txt -stdout foo.doc
[ "textutil", "-", "convert", "txt", "-", "stdout", "foo", ".", "doc" ]
dc6004b78619c169044433d24a862228af6895fa
https://github.com/dbashford/textract/blob/dc6004b78619c169044433d24a862228af6895fa/lib/extractors/doc-osx.js#L9-L35
train
APIDevTools/json-schema-ref-parser
lib/util/yaml.js
yamlParse
function yamlParse (text, reviver) { try { return yaml.safeLoad(text); } catch (e) { if (e instanceof Error) { throw e; } else { // https://github.com/nodeca/js-yaml/issues/153 throw ono(e, e.message); } } }
javascript
function yamlParse (text, reviver) { try { return yaml.safeLoad(text); } catch (e) { if (e instanceof Error) { throw e; } else { // https://github.com/nodeca/js-yaml/issues/153 throw ono(e, e.message); } } }
[ "function", "yamlParse", "(", "text", ",", "reviver", ")", "{", "try", "{", "return", "yaml", ".", "safeLoad", "(", "text", ")", ";", "}", "catch", "(", "e", ")", "{", "if", "(", "e", "instanceof", "Error", ")", "{", "throw", "e", ";", "}", "else...
Parses a YAML string and returns the value. @param {string} text - The YAML string to be parsed @param {function} [reviver] - Not currently supported. Provided for consistency with {@link JSON.parse} @returns {*}
[ "Parses", "a", "YAML", "string", "and", "returns", "the", "value", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/util/yaml.js#L18-L31
train
APIDevTools/json-schema-ref-parser
lib/util/yaml.js
yamlStringify
function yamlStringify (value, replacer, space) { try { var indent = (typeof space === "string" ? space.length : space) || 2; return yaml.safeDump(value, { indent: indent }); } catch (e) { if (e instanceof Error) { throw e; } else { // https://github.com/nodeca/...
javascript
function yamlStringify (value, replacer, space) { try { var indent = (typeof space === "string" ? space.length : space) || 2; return yaml.safeDump(value, { indent: indent }); } catch (e) { if (e instanceof Error) { throw e; } else { // https://github.com/nodeca/...
[ "function", "yamlStringify", "(", "value", ",", "replacer", ",", "space", ")", "{", "try", "{", "var", "indent", "=", "(", "typeof", "space", "===", "\"string\"", "?", "space", ".", "length", ":", "space", ")", "||", "2", ";", "return", "yaml", ".", ...
Converts a JavaScript value to a YAML string. @param {*} value - The value to convert to YAML @param {function|array} replacer - Not currently supported. Provided for consistency with {@link JSON.stringify} @param {string|number} space - The number of spaces to use for indentation, or a string containing the num...
[ "Converts", "a", "JavaScript", "value", "to", "a", "YAML", "string", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/util/yaml.js#L41-L55
train
APIDevTools/json-schema-ref-parser
lib/parsers/json.js
parseJSON
function parseJSON (file) { return new Promise(function (resolve, reject) { var data = file.data; if (Buffer.isBuffer(data)) { data = data.toString(); } if (typeof data === "string") { if (data.trim().length === 0) { resolve(undefined); // This mirrors the YAML be...
javascript
function parseJSON (file) { return new Promise(function (resolve, reject) { var data = file.data; if (Buffer.isBuffer(data)) { data = data.toString(); } if (typeof data === "string") { if (data.trim().length === 0) { resolve(undefined); // This mirrors the YAML be...
[ "function", "parseJSON", "(", "file", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "var", "data", "=", "file", ".", "data", ";", "if", "(", "Buffer", ".", "isBuffer", "(", "data", ")", ")", "{", "d...
Parses the given file as JSON @param {object} file - An object containing information about the referenced file @param {string} file.url - The full URL of the referenced file @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.) @param {*} file.data - The...
[ "Parses", "the", "given", "file", "as", "JSON" ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/parsers/json.js#L37-L57
train
APIDevTools/json-schema-ref-parser
lib/parse.js
parse
function parse (path, $refs, options) { try { // Remove the URL fragment, if any path = url.stripHash(path); // Add a new $Ref for this file, even though we don't have the value yet. // This ensures that we don't simultaneously read & parse the same file multiple times var $ref = $refs._add(path)...
javascript
function parse (path, $refs, options) { try { // Remove the URL fragment, if any path = url.stripHash(path); // Add a new $Ref for this file, even though we don't have the value yet. // This ensures that we don't simultaneously read & parse the same file multiple times var $ref = $refs._add(path)...
[ "function", "parse", "(", "path", ",", "$refs", ",", "options", ")", "{", "try", "{", "// Remove the URL fragment, if any", "path", "=", "url", ".", "stripHash", "(", "path", ")", ";", "// Add a new $Ref for this file, even though we don't have the value yet.", "// This...
Reads and parses the specified file path or URL. @param {string} path - This path MUST already be resolved, since `read` doesn't know the resolution context @param {$Refs} $refs @param {$RefParserOptions} options @returns {Promise} The promise resolves with the parsed file contents, NOT the raw (Buffer) contents.
[ "Reads", "and", "parses", "the", "specified", "file", "path", "or", "URL", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/parse.js#L19-L49
train
APIDevTools/json-schema-ref-parser
lib/parse.js
parseFile
function parseFile (file, options) { return new Promise(function (resolve, reject) { // console.log('Parsing %s', file.url); // Find the parsers that can read this file type. // If none of the parsers are an exact match for this file, then we'll try ALL of them. // This handles situations where the f...
javascript
function parseFile (file, options) { return new Promise(function (resolve, reject) { // console.log('Parsing %s', file.url); // Find the parsers that can read this file type. // If none of the parsers are an exact match for this file, then we'll try ALL of them. // This handles situations where the f...
[ "function", "parseFile", "(", "file", ",", "options", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "// console.log('Parsing %s', file.url);", "// Find the parsers that can read this file type.", "// If none of the parsers a...
Parses the given file's contents, using the configured parser plugins. @param {object} file - An object containing information about the referenced file @param {string} file.url - The full URL of the referenced file @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", e...
[ "Parses", "the", "given", "file", "s", "contents", "using", "the", "configured", "parser", "plugins", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/parse.js#L100-L135
train
APIDevTools/json-schema-ref-parser
lib/parse.js
isEmpty
function isEmpty (value) { return value === undefined || (typeof value === "object" && Object.keys(value).length === 0) || (typeof value === "string" && value.trim().length === 0) || (Buffer.isBuffer(value) && value.length === 0); }
javascript
function isEmpty (value) { return value === undefined || (typeof value === "object" && Object.keys(value).length === 0) || (typeof value === "string" && value.trim().length === 0) || (Buffer.isBuffer(value) && value.length === 0); }
[ "function", "isEmpty", "(", "value", ")", "{", "return", "value", "===", "undefined", "||", "(", "typeof", "value", "===", "\"object\"", "&&", "Object", ".", "keys", "(", "value", ")", ".", "length", "===", "0", ")", "||", "(", "typeof", "value", "==="...
Determines whether the parsed value is "empty". @param {*} value @returns {boolean}
[ "Determines", "whether", "the", "parsed", "value", "is", "empty", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/parse.js#L143-L148
train
APIDevTools/json-schema-ref-parser
lib/options.js
merge
function merge (target, source) { if (isMergeable(source)) { var keys = Object.keys(source); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var sourceSetting = source[key]; var targetSetting = target[key]; if (isMergeable(sourceSetting)) { // It's a nested object, ...
javascript
function merge (target, source) { if (isMergeable(source)) { var keys = Object.keys(source); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var sourceSetting = source[key]; var targetSetting = target[key]; if (isMergeable(sourceSetting)) { // It's a nested object, ...
[ "function", "merge", "(", "target", ",", "source", ")", "{", "if", "(", "isMergeable", "(", "source", ")", ")", "{", "var", "keys", "=", "Object", ".", "keys", "(", "source", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "keys", "....
Merges the properties of the source object into the target object. @param {object} target - The object that we're populating @param {?object} source - The options that are being merged @returns {object}
[ "Merges", "the", "properties", "of", "the", "source", "object", "into", "the", "target", "object", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/options.js#L80-L99
train
APIDevTools/json-schema-ref-parser
lib/options.js
isMergeable
function isMergeable (val) { return val && (typeof val === "object") && !Array.isArray(val) && !(val instanceof RegExp) && !(val instanceof Date); }
javascript
function isMergeable (val) { return val && (typeof val === "object") && !Array.isArray(val) && !(val instanceof RegExp) && !(val instanceof Date); }
[ "function", "isMergeable", "(", "val", ")", "{", "return", "val", "&&", "(", "typeof", "val", "===", "\"object\"", ")", "&&", "!", "Array", ".", "isArray", "(", "val", ")", "&&", "!", "(", "val", "instanceof", "RegExp", ")", "&&", "!", "(", "val", ...
Determines whether the given value can be merged, or if it is a scalar value that should just override the target value. @param {*} val @returns {Boolean}
[ "Determines", "whether", "the", "given", "value", "can", "be", "merged", "or", "if", "it", "is", "a", "scalar", "value", "that", "should", "just", "override", "the", "target", "value", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/options.js#L108-L114
train
APIDevTools/json-schema-ref-parser
lib/resolve-external.js
crawl
function crawl (obj, path, $refs, options) { var promises = []; if (obj && typeof obj === "object") { if ($Ref.isExternal$Ref(obj)) { promises.push(resolve$Ref(obj, path, $refs, options)); } else { Object.keys(obj).forEach(function (key) { var keyPath = Pointer.join(path, key); ...
javascript
function crawl (obj, path, $refs, options) { var promises = []; if (obj && typeof obj === "object") { if ($Ref.isExternal$Ref(obj)) { promises.push(resolve$Ref(obj, path, $refs, options)); } else { Object.keys(obj).forEach(function (key) { var keyPath = Pointer.join(path, key); ...
[ "function", "crawl", "(", "obj", ",", "path", ",", "$refs", ",", "options", ")", "{", "var", "promises", "=", "[", "]", ";", "if", "(", "obj", "&&", "typeof", "obj", "===", "\"object\"", ")", "{", "if", "(", "$Ref", ".", "isExternal$Ref", "(", "obj...
Recursively crawls the given value, and resolves any external JSON references. @param {*} obj - The value to crawl. If it's not an object or array, it will be ignored. @param {string} path - The full path of `obj`, possibly with a JSON Pointer in the hash @param {$Refs} $refs @param {$RefParserOptions} options @retur...
[ "Recursively", "crawls", "the", "given", "value", "and", "resolves", "any", "external", "JSON", "references", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/resolve-external.js#L53-L76
train
APIDevTools/json-schema-ref-parser
lib/resolve-external.js
resolve$Ref
function resolve$Ref ($ref, path, $refs, options) { // console.log('Resolving $ref pointer "%s" at %s', $ref.$ref, path); var resolvedPath = url.resolve(path, $ref.$ref); var withoutHash = url.stripHash(resolvedPath); // Do we already have this $ref? $ref = $refs._$refs[withoutHash]; if ($ref) { // We...
javascript
function resolve$Ref ($ref, path, $refs, options) { // console.log('Resolving $ref pointer "%s" at %s', $ref.$ref, path); var resolvedPath = url.resolve(path, $ref.$ref); var withoutHash = url.stripHash(resolvedPath); // Do we already have this $ref? $ref = $refs._$refs[withoutHash]; if ($ref) { // We...
[ "function", "resolve$Ref", "(", "$ref", ",", "path", ",", "$refs", ",", "options", ")", "{", "// console.log('Resolving $ref pointer \"%s\" at %s', $ref.$ref, path);", "var", "resolvedPath", "=", "url", ".", "resolve", "(", "path", ",", "$ref", ".", "$ref", ")", "...
Resolves the given JSON Reference, and then crawls the resulting value. @param {{$ref: string}} $ref - The JSON Reference to resolve @param {string} path - The full path of `$ref`, possibly with a JSON Pointer in the hash @param {$Refs} $refs @param {$RefParserOptions} options @returns {Promise} The promise resolves ...
[ "Resolves", "the", "given", "JSON", "Reference", "and", "then", "crawls", "the", "resulting", "value", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/resolve-external.js#L90-L111
train
APIDevTools/json-schema-ref-parser
lib/bundle.js
crawl
function crawl (parent, key, path, pathFromRoot, indirections, inventory, $refs, options) { var obj = key === null ? parent : parent[key]; if (obj && typeof obj === "object") { if ($Ref.isAllowed$Ref(obj)) { inventory$Ref(parent, key, path, pathFromRoot, indirections, inventory, $refs, options); } ...
javascript
function crawl (parent, key, path, pathFromRoot, indirections, inventory, $refs, options) { var obj = key === null ? parent : parent[key]; if (obj && typeof obj === "object") { if ($Ref.isAllowed$Ref(obj)) { inventory$Ref(parent, key, path, pathFromRoot, indirections, inventory, $refs, options); } ...
[ "function", "crawl", "(", "parent", ",", "key", ",", "path", ",", "pathFromRoot", ",", "indirections", ",", "inventory", ",", "$refs", ",", "options", ")", "{", "var", "obj", "=", "key", "===", "null", "?", "parent", ":", "parent", "[", "key", "]", "...
Recursively crawls the given value, and inventories all JSON references. @param {object} parent - The object containing the value to crawl. If the value is not an object or array, it will be ignored. @param {string} key - The property key of `parent` to be crawled @param {string} path - The full path of the property b...
[ "Recursively", "crawls", "the", "given", "value", "and", "inventories", "all", "JSON", "references", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/bundle.js#L39-L81
train
APIDevTools/json-schema-ref-parser
lib/parsers/text.js
parseText
function parseText (file) { if (typeof file.data === "string") { return file.data; } else if (Buffer.isBuffer(file.data)) { return file.data.toString(this.encoding); } else { throw new Error("data is not text"); } }
javascript
function parseText (file) { if (typeof file.data === "string") { return file.data; } else if (Buffer.isBuffer(file.data)) { return file.data.toString(this.encoding); } else { throw new Error("data is not text"); } }
[ "function", "parseText", "(", "file", ")", "{", "if", "(", "typeof", "file", ".", "data", "===", "\"string\"", ")", "{", "return", "file", ".", "data", ";", "}", "else", "if", "(", "Buffer", ".", "isBuffer", "(", "file", ".", "data", ")", ")", "{",...
Parses the given file as text @param {object} file - An object containing information about the referenced file @param {string} file.url - The full URL of the referenced file @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.) @param {*} file.data - The...
[ "Parses", "the", "given", "file", "as", "text" ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/parsers/text.js#L53-L63
train
APIDevTools/json-schema-ref-parser
lib/refs.js
getPaths
function getPaths ($refs, types) { var paths = Object.keys($refs); // Filter the paths by type types = Array.isArray(types[0]) ? types[0] : Array.prototype.slice.call(types); if (types.length > 0 && types[0]) { paths = paths.filter(function (key) { return types.indexOf($refs[key].pathType) !==...
javascript
function getPaths ($refs, types) { var paths = Object.keys($refs); // Filter the paths by type types = Array.isArray(types[0]) ? types[0] : Array.prototype.slice.call(types); if (types.length > 0 && types[0]) { paths = paths.filter(function (key) { return types.indexOf($refs[key].pathType) !==...
[ "function", "getPaths", "(", "$refs", ",", "types", ")", "{", "var", "paths", "=", "Object", ".", "keys", "(", "$refs", ")", ";", "// Filter the paths by type\r", "types", "=", "Array", ".", "isArray", "(", "types", "[", "0", "]", ")", "?", "types", "[...
Returns the encoded and decoded paths keys of the given object. @param {object} $refs - The object whose keys are URL-encoded paths @param {...string|string[]} [types] - Only return paths of the given types ("file", "http", etc.) @returns {object[]}
[ "Returns", "the", "encoded", "and", "decoded", "paths", "keys", "of", "the", "given", "object", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/refs.js#L178-L196
train
APIDevTools/json-schema-ref-parser
lib/pointer.js
Pointer
function Pointer ($ref, path, friendlyPath) { /** * The {@link $Ref} object that contains this {@link Pointer} object. * @type {$Ref} */ this.$ref = $ref; /** * The file path or URL, containing the JSON pointer in the hash. * This path is relative to the path of the main JSON schema file. * @ty...
javascript
function Pointer ($ref, path, friendlyPath) { /** * The {@link $Ref} object that contains this {@link Pointer} object. * @type {$Ref} */ this.$ref = $ref; /** * The file path or URL, containing the JSON pointer in the hash. * This path is relative to the path of the main JSON schema file. * @ty...
[ "function", "Pointer", "(", "$ref", ",", "path", ",", "friendlyPath", ")", "{", "/**\n * The {@link $Ref} object that contains this {@link Pointer} object.\n * @type {$Ref}\n */", "this", ".", "$ref", "=", "$ref", ";", "/**\n * The file path or URL, containing the JSON poin...
This class represents a single JSON pointer and its resolved value. @param {$Ref} $ref @param {string} path @param {string} [friendlyPath] - The original user-specified path (used for error messages) @constructor
[ "This", "class", "represents", "a", "single", "JSON", "pointer", "and", "its", "resolved", "value", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/pointer.js#L21-L60
train
APIDevTools/json-schema-ref-parser
lib/dereference.js
dereference
function dereference (parser, options) { // console.log('Dereferencing $ref pointers in %s', parser.$refs._root$Ref.path); var dereferenced = crawl(parser.schema, parser.$refs._root$Ref.path, "#", [], parser.$refs, options); parser.$refs.circular = dereferenced.circular; parser.schema = dereferenced.value; ...
javascript
function dereference (parser, options) { // console.log('Dereferencing $ref pointers in %s', parser.$refs._root$Ref.path); var dereferenced = crawl(parser.schema, parser.$refs._root$Ref.path, "#", [], parser.$refs, options); parser.$refs.circular = dereferenced.circular; parser.schema = dereferenced.value; ...
[ "function", "dereference", "(", "parser", ",", "options", ")", "{", "// console.log('Dereferencing $ref pointers in %s', parser.$refs._root$Ref.path);\r", "var", "dereferenced", "=", "crawl", "(", "parser", ".", "schema", ",", "parser", ".", "$refs", ".", "_root$Ref", "...
Crawls the JSON schema, finds all JSON references, and dereferences them. This method mutates the JSON schema object, replacing JSON references with their resolved value. @param {$RefParser} parser @param {$RefParserOptions} options
[ "Crawls", "the", "JSON", "schema", "finds", "all", "JSON", "references", "and", "dereferences", "them", ".", "This", "method", "mutates", "the", "JSON", "schema", "object", "replacing", "JSON", "references", "with", "their", "resolved", "value", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/dereference.js#L17-L22
train
APIDevTools/json-schema-ref-parser
lib/dereference.js
crawl
function crawl (obj, path, pathFromRoot, parents, $refs, options) { var dereferenced; var result = { value: obj, circular: false }; if (obj && typeof obj === "object") { parents.push(obj); if ($Ref.isAllowed$Ref(obj, options)) { dereferenced = dereference$Ref(obj, path, pathFr...
javascript
function crawl (obj, path, pathFromRoot, parents, $refs, options) { var dereferenced; var result = { value: obj, circular: false }; if (obj && typeof obj === "object") { parents.push(obj); if ($Ref.isAllowed$Ref(obj, options)) { dereferenced = dereference$Ref(obj, path, pathFr...
[ "function", "crawl", "(", "obj", ",", "path", ",", "pathFromRoot", ",", "parents", ",", "$refs", ",", "options", ")", "{", "var", "dereferenced", ";", "var", "result", "=", "{", "value", ":", "obj", ",", "circular", ":", "false", "}", ";", "if", "(",...
Recursively crawls the given value, and dereferences any JSON references. @param {*} obj - The value to crawl. If it's not an object or array, it will be ignored. @param {string} path - The full path of `obj`, possibly with a JSON Pointer in the hash @param {string} pathFromRoot - The path of `obj` from the schema roo...
[ "Recursively", "crawls", "the", "given", "value", "and", "dereferences", "any", "JSON", "references", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/dereference.js#L35-L82
train
APIDevTools/json-schema-ref-parser
lib/dereference.js
dereference$Ref
function dereference$Ref ($ref, path, pathFromRoot, parents, $refs, options) { // console.log('Dereferencing $ref pointer "%s" at %s', $ref.$ref, path); var $refPath = url.resolve(path, $ref.$ref); var pointer = $refs._resolve($refPath, options); // Check for circular references var directCircular = ...
javascript
function dereference$Ref ($ref, path, pathFromRoot, parents, $refs, options) { // console.log('Dereferencing $ref pointer "%s" at %s', $ref.$ref, path); var $refPath = url.resolve(path, $ref.$ref); var pointer = $refs._resolve($refPath, options); // Check for circular references var directCircular = ...
[ "function", "dereference$Ref", "(", "$ref", ",", "path", ",", "pathFromRoot", ",", "parents", ",", "$refs", ",", "options", ")", "{", "// console.log('Dereferencing $ref pointer \"%s\" at %s', $ref.$ref, path);\r", "var", "$refPath", "=", "url", ".", "resolve", "(", "...
Dereferences the given JSON Reference, and then crawls the resulting value. @param {{$ref: string}} $ref - The JSON Reference to resolve @param {string} path - The full path of `$ref`, possibly with a JSON Pointer in the hash @param {string} pathFromRoot - The path of `$ref` from the schema root @param {object[]} pare...
[ "Dereferences", "the", "given", "JSON", "Reference", "and", "then", "crawls", "the", "resulting", "value", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/dereference.js#L95-L132
train
APIDevTools/json-schema-ref-parser
lib/resolvers/http.js
readHttp
function readHttp (file) { var u = url.parse(file.url); if (process.browser && !u.protocol) { // Use the protocol of the current page u.protocol = url.parse(location.href).protocol; } return download(u, this); }
javascript
function readHttp (file) { var u = url.parse(file.url); if (process.browser && !u.protocol) { // Use the protocol of the current page u.protocol = url.parse(location.href).protocol; } return download(u, this); }
[ "function", "readHttp", "(", "file", ")", "{", "var", "u", "=", "url", ".", "parse", "(", "file", ".", "url", ")", ";", "if", "(", "process", ".", "browser", "&&", "!", "u", ".", "protocol", ")", "{", "// Use the protocol of the current page", "u", "."...
Reads the given URL and returns its raw contents as a Buffer. @param {object} file - An object containing information about the referenced file @param {string} file.url - The full URL of the referenced file @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.) @ret...
[ "Reads", "the", "given", "URL", "and", "returns", "its", "raw", "contents", "as", "a", "Buffer", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/resolvers/http.js#L74-L83
train
APIDevTools/json-schema-ref-parser
lib/resolvers/http.js
get
function get (u, httpOptions) { return new Promise(function (resolve, reject) { // console.log('GET', u.href); var protocol = u.protocol === "https:" ? https : http; var req = protocol.get({ hostname: u.hostname, port: u.port, path: u.path, auth: u.auth, protocol: u.protocol...
javascript
function get (u, httpOptions) { return new Promise(function (resolve, reject) { // console.log('GET', u.href); var protocol = u.protocol === "https:" ? https : http; var req = protocol.get({ hostname: u.hostname, port: u.port, path: u.path, auth: u.auth, protocol: u.protocol...
[ "function", "get", "(", "u", ",", "httpOptions", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "// console.log('GET', u.href);", "var", "protocol", "=", "u", ".", "protocol", "===", "\"https:\"", "?", "https"...
Sends an HTTP GET request. @param {Url} u - A parsed {@link Url} object @param {object} httpOptions - The `options.resolve.http` object @returns {Promise<Response>} The promise resolves with the HTTP Response object.
[ "Sends", "an", "HTTP", "GET", "request", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/resolvers/http.js#L140-L179
train
APIDevTools/json-schema-ref-parser
lib/util/plugins.js
getResult
function getResult (obj, prop, file, callback) { var value = obj[prop]; if (typeof value === "function") { return value.apply(obj, [file, callback]); } if (!callback) { // The synchronous plugin functions (canParse and canRead) // allow a "shorthand" syntax, where the user can match // files b...
javascript
function getResult (obj, prop, file, callback) { var value = obj[prop]; if (typeof value === "function") { return value.apply(obj, [file, callback]); } if (!callback) { // The synchronous plugin functions (canParse and canRead) // allow a "shorthand" syntax, where the user can match // files b...
[ "function", "getResult", "(", "obj", ",", "prop", ",", "file", ",", "callback", ")", "{", "var", "value", "=", "obj", "[", "prop", "]", ";", "if", "(", "typeof", "value", "===", "\"function\"", ")", "{", "return", "value", ".", "apply", "(", "obj", ...
Returns the value of the given property. If the property is a function, then the result of the function is returned. If the value is a RegExp, then it will be tested against the file URL. If the value is an aray, then it will be compared against the file extension. @param {object} obj - The object whose pro...
[ "Returns", "the", "value", "of", "the", "given", "property", ".", "If", "the", "property", "is", "a", "function", "then", "the", "result", "of", "the", "function", "is", "returned", ".", "If", "the", "value", "is", "a", "RegExp", "then", "it", "will", ...
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/util/plugins.js#L131-L154
train
APIDevTools/json-schema-ref-parser
lib/parsers/yaml.js
parseYAML
function parseYAML (file) { return new Promise(function (resolve, reject) { var data = file.data; if (Buffer.isBuffer(data)) { data = data.toString(); } if (typeof data === "string") { resolve(YAML.parse(data)); } else { // data is already a JavaScript va...
javascript
function parseYAML (file) { return new Promise(function (resolve, reject) { var data = file.data; if (Buffer.isBuffer(data)) { data = data.toString(); } if (typeof data === "string") { resolve(YAML.parse(data)); } else { // data is already a JavaScript va...
[ "function", "parseYAML", "(", "file", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "var", "data", "=", "file", ".", "data", ";", "if", "(", "Buffer", ".", "isBuffer", "(", "data", ")", ")", "{", "d...
JSON is valid YAML Parses the given file as YAML @param {object} file - An object containing information about the referenced file @param {string} file.url - The full URL of the referenced file @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.) @param {*} ...
[ "JSON", "is", "valid", "YAML", "Parses", "the", "given", "file", "as", "YAML" ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/parsers/yaml.js#L39-L54
train
APIDevTools/json-schema-ref-parser
lib/normalize-args.js
normalizeArgs
function normalizeArgs (args) { var path, schema, options, callback; args = Array.prototype.slice.call(args); if (typeof args[args.length - 1] === "function") { // The last parameter is a callback function callback = args.pop(); } if (typeof args[0] === "string") { // The first parameter is the ...
javascript
function normalizeArgs (args) { var path, schema, options, callback; args = Array.prototype.slice.call(args); if (typeof args[args.length - 1] === "function") { // The last parameter is a callback function callback = args.pop(); } if (typeof args[0] === "string") { // The first parameter is the ...
[ "function", "normalizeArgs", "(", "args", ")", "{", "var", "path", ",", "schema", ",", "options", ",", "callback", ";", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "args", ")", ";", "if", "(", "typeof", "args", "[", "args"...
Normalizes the given arguments, accounting for optional args. @param {Arguments} args @returns {object}
[ "Normalizes", "the", "given", "arguments", "accounting", "for", "optional", "args", "." ]
29ea8693e288e5ced3ebd670d545925f16a4ed17
https://github.com/APIDevTools/json-schema-ref-parser/blob/29ea8693e288e5ced3ebd670d545925f16a4ed17/lib/normalize-args.js#L13-L53
train
cyrus-and/chrome-remote-interface
lib/devtools.js
promisesWrapper
function promisesWrapper(func) { return (options, callback) => { // options is an optional argument if (typeof options === 'function') { callback = options; options = undefined; } options = options || {}; // just call the function otherwise wrap a prom...
javascript
function promisesWrapper(func) { return (options, callback) => { // options is an optional argument if (typeof options === 'function') { callback = options; options = undefined; } options = options || {}; // just call the function otherwise wrap a prom...
[ "function", "promisesWrapper", "(", "func", ")", "{", "return", "(", "options", ",", "callback", ")", "=>", "{", "// options is an optional argument", "if", "(", "typeof", "options", "===", "'function'", ")", "{", "callback", "=", "options", ";", "options", "=...
wrapper that allows to return a promise if the callback is omitted, it works for DevTools methods
[ "wrapper", "that", "allows", "to", "return", "a", "promise", "if", "the", "callback", "is", "omitted", "it", "works", "for", "DevTools", "methods" ]
68309828ce3a08136fda1fc5224fababb49769f1
https://github.com/cyrus-and/chrome-remote-interface/blob/68309828ce3a08136fda1fc5224fababb49769f1/lib/devtools.js#L20-L44
train
xCss/Valine
src/utils/domReady.js
domReady
function domReady(callback) { if (doc.readyState === "complete" || (doc.readyState !== "loading" && !doc.documentElement.doScroll)) setTimeout(() => callback && callback(), 0) else { let handler = () => { doc.removeEventListener("DOMContentLoaded", handler, false) win.rem...
javascript
function domReady(callback) { if (doc.readyState === "complete" || (doc.readyState !== "loading" && !doc.documentElement.doScroll)) setTimeout(() => callback && callback(), 0) else { let handler = () => { doc.removeEventListener("DOMContentLoaded", handler, false) win.rem...
[ "function", "domReady", "(", "callback", ")", "{", "if", "(", "doc", ".", "readyState", "===", "\"complete\"", "||", "(", "doc", ".", "readyState", "!==", "\"loading\"", "&&", "!", "doc", ".", "documentElement", ".", "doScroll", ")", ")", "setTimeout", "("...
Detection DOM is Ready @param {Function} callback
[ "Detection", "DOM", "is", "Ready" ]
fd1b2ecf8b0bfffe57da84f978053316c4d1897f
https://github.com/xCss/Valine/blob/fd1b2ecf8b0bfffe57da84f978053316c4d1897f/src/utils/domReady.js#L7-L19
train
xCss/Valine
src/utils/index.js
oReady
function oReady(o, callback) { !!o && (callback && callback()) || setTimeout(() => oReady(o, callback), 10) }
javascript
function oReady(o, callback) { !!o && (callback && callback()) || setTimeout(() => oReady(o, callback), 10) }
[ "function", "oReady", "(", "o", ",", "callback", ")", "{", "!", "!", "o", "&&", "(", "callback", "&&", "callback", "(", ")", ")", "||", "setTimeout", "(", "(", ")", "=>", "oReady", "(", "o", ",", "callback", ")", ",", "10", ")", "}" ]
Detection target Object is ready @param {Object} o @param {Function} callback
[ "Detection", "target", "Object", "is", "ready" ]
fd1b2ecf8b0bfffe57da84f978053316c4d1897f
https://github.com/xCss/Valine/blob/fd1b2ecf8b0bfffe57da84f978053316c4d1897f/src/utils/index.js#L16-L18
train
xCss/Valine
src/utils/deepClone.js
isCyclic
function isCyclic (data) { // Create an array that will store the nodes of the array that have already been iterated over let seenObjects = []; function detect (data) { // If the data pass is an object if (data && getType(data) === "Object") { // If the data is...
javascript
function isCyclic (data) { // Create an array that will store the nodes of the array that have already been iterated over let seenObjects = []; function detect (data) { // If the data pass is an object if (data && getType(data) === "Object") { // If the data is...
[ "function", "isCyclic", "(", "data", ")", "{", "// Create an array that will store the nodes of the array that have already been iterated over", "let", "seenObjects", "=", "[", "]", ";", "function", "detect", "(", "data", ")", "{", "// If the data pass is an object", "if", ...
Create a method to detect whether an object contains a circular reference
[ "Create", "a", "method", "to", "detect", "whether", "an", "object", "contains", "a", "circular", "reference" ]
fd1b2ecf8b0bfffe57da84f978053316c4d1897f
https://github.com/xCss/Valine/blob/fd1b2ecf8b0bfffe57da84f978053316c4d1897f/src/utils/deepClone.js#L12-L43
train
flightjs/flight
lib/component.js
teardownAll
function teardownAll() { var componentInfo = registry.findComponentInfo(this); componentInfo && Object.keys(componentInfo.instances).forEach(function(k) { var info = componentInfo.instances[k]; // It's possible that a previous teardown caused another component to teardown, // so we ...
javascript
function teardownAll() { var componentInfo = registry.findComponentInfo(this); componentInfo && Object.keys(componentInfo.instances).forEach(function(k) { var info = componentInfo.instances[k]; // It's possible that a previous teardown caused another component to teardown, // so we ...
[ "function", "teardownAll", "(", ")", "{", "var", "componentInfo", "=", "registry", ".", "findComponentInfo", "(", "this", ")", ";", "componentInfo", "&&", "Object", ".", "keys", "(", "componentInfo", ".", "instances", ")", ".", "forEach", "(", "function", "(...
teardown for all instances of this constructor
[ "teardown", "for", "all", "instances", "of", "this", "constructor" ]
f15b32277d2c55c6c595845a87109b09c913c556
https://github.com/flightjs/flight/blob/f15b32277d2c55c6c595845a87109b09c913c556/lib/component.js#L25-L36
train
twitter/hogan.js
web/builds/1.0.5/hogan-1.0.5.js
function(name, context, partials, indent) { var partial = partials[name]; if (!partial) { return ''; } if (this.c && typeof partial == 'string') { partial = this.c.compile(partial, this.options); } return partial.ri(context, partials, indent); }
javascript
function(name, context, partials, indent) { var partial = partials[name]; if (!partial) { return ''; } if (this.c && typeof partial == 'string') { partial = this.c.compile(partial, this.options); } return partial.ri(context, partials, indent); }
[ "function", "(", "name", ",", "context", ",", "partials", ",", "indent", ")", "{", "var", "partial", "=", "partials", "[", "name", "]", ";", "if", "(", "!", "partial", ")", "{", "return", "''", ";", "}", "if", "(", "this", ".", "c", "&&", "typeof...
tries to find a partial in the curent scope and render it
[ "tries", "to", "find", "a", "partial", "in", "the", "curent", "scope", "and", "render", "it" ]
7e340e9e4dde8faebd1ff34e62abc1c5dd8adb55
https://github.com/twitter/hogan.js/blob/7e340e9e4dde8faebd1ff34e62abc1c5dd8adb55/web/builds/1.0.5/hogan-1.0.5.js#L49-L61
train
twitter/hogan.js
web/builds/1.0.5/hogan-1.0.5.js
function(val, ctx, partials, inverted, start, end, tags) { var cx = ctx[ctx.length - 1], t = null; if (!inverted && this.c && val.length > 0) { return this.ho(val, cx, partials, this.text.substring(start, end), tags); } t = val.call(cx); if (typeof t == 'function') { ...
javascript
function(val, ctx, partials, inverted, start, end, tags) { var cx = ctx[ctx.length - 1], t = null; if (!inverted && this.c && val.length > 0) { return this.ho(val, cx, partials, this.text.substring(start, end), tags); } t = val.call(cx); if (typeof t == 'function') { ...
[ "function", "(", "val", ",", "ctx", ",", "partials", ",", "inverted", ",", "start", ",", "end", ",", "tags", ")", "{", "var", "cx", "=", "ctx", "[", "ctx", ".", "length", "-", "1", "]", ",", "t", "=", "null", ";", "if", "(", "!", "inverted", ...
lambda replace section
[ "lambda", "replace", "section" ]
7e340e9e4dde8faebd1ff34e62abc1c5dd8adb55
https://github.com/twitter/hogan.js/blob/7e340e9e4dde8faebd1ff34e62abc1c5dd8adb55/web/builds/1.0.5/hogan-1.0.5.js#L177-L196
train
twitter/hogan.js
web/builds/1.0.5/hogan-1.0.5.js
function(val, ctx, partials) { var cx = ctx[ctx.length - 1]; var result = val.call(cx); if (typeof result == 'function') { result = result.call(cx); } result = coerceToString(result); if (this.c && ~result.indexOf("{\u007B")) { return this.c.compile(result, this.opti...
javascript
function(val, ctx, partials) { var cx = ctx[ctx.length - 1]; var result = val.call(cx); if (typeof result == 'function') { result = result.call(cx); } result = coerceToString(result); if (this.c && ~result.indexOf("{\u007B")) { return this.c.compile(result, this.opti...
[ "function", "(", "val", ",", "ctx", ",", "partials", ")", "{", "var", "cx", "=", "ctx", "[", "ctx", ".", "length", "-", "1", "]", ";", "var", "result", "=", "val", ".", "call", "(", "cx", ")", ";", "if", "(", "typeof", "result", "==", "'functio...
lambda replace variable
[ "lambda", "replace", "variable" ]
7e340e9e4dde8faebd1ff34e62abc1c5dd8adb55
https://github.com/twitter/hogan.js/blob/7e340e9e4dde8faebd1ff34e62abc1c5dd8adb55/web/builds/1.0.5/hogan-1.0.5.js#L199-L212
train
webtorrent/bittorrent-tracker
server.js
getOrCreateSwarm
function getOrCreateSwarm (cb) { self.getSwarm(params.info_hash, (err, swarm) => { if (err) return cb(err) if (swarm) return cb(null, swarm) self.createSwarm(params.info_hash, (err, swarm) => { if (err) return cb(err) cb(null, swarm) }) }) }
javascript
function getOrCreateSwarm (cb) { self.getSwarm(params.info_hash, (err, swarm) => { if (err) return cb(err) if (swarm) return cb(null, swarm) self.createSwarm(params.info_hash, (err, swarm) => { if (err) return cb(err) cb(null, swarm) }) }) }
[ "function", "getOrCreateSwarm", "(", "cb", ")", "{", "self", ".", "getSwarm", "(", "params", ".", "info_hash", ",", "(", "err", ",", "swarm", ")", "=>", "{", "if", "(", "err", ")", "return", "cb", "(", "err", ")", "if", "(", "swarm", ")", "return",...
Get existing swarm, or create one if one does not exist
[ "Get", "existing", "swarm", "or", "create", "one", "if", "one", "does", "not", "exist" ]
c0331ea5418b9fb8927a337172623d6985a7a403
https://github.com/webtorrent/bittorrent-tracker/blob/c0331ea5418b9fb8927a337172623d6985a7a403/server.js#L651-L660
train
webtorrent/bittorrent-tracker
lib/server/parse-udp.js
fromUInt64
function fromUInt64 (buf) { var high = buf.readUInt32BE(0) | 0 // force var low = buf.readUInt32BE(4) | 0 var lowUnsigned = (low >= 0) ? low : TWO_PWR_32 + low return (high * TWO_PWR_32) + lowUnsigned }
javascript
function fromUInt64 (buf) { var high = buf.readUInt32BE(0) | 0 // force var low = buf.readUInt32BE(4) | 0 var lowUnsigned = (low >= 0) ? low : TWO_PWR_32 + low return (high * TWO_PWR_32) + lowUnsigned }
[ "function", "fromUInt64", "(", "buf", ")", "{", "var", "high", "=", "buf", ".", "readUInt32BE", "(", "0", ")", "|", "0", "// force", "var", "low", "=", "buf", ".", "readUInt32BE", "(", "4", ")", "|", "0", "var", "lowUnsigned", "=", "(", "low", ">="...
Return the closest floating-point representation to the buffer value. Precision will be lost for big numbers.
[ "Return", "the", "closest", "floating", "-", "point", "representation", "to", "the", "buffer", "value", ".", "Precision", "will", "be", "lost", "for", "big", "numbers", "." ]
c0331ea5418b9fb8927a337172623d6985a7a403
https://github.com/webtorrent/bittorrent-tracker/blob/c0331ea5418b9fb8927a337172623d6985a7a403/lib/server/parse-udp.js#L69-L75
train
Mermade/oas-kit
packages/reftools/lib/clone.js
shallowClone
function shallowClone(obj) { let result = {}; for (let p in obj) { if (obj.hasOwnProperty(p)) { result[p] = obj[p]; } } return result; }
javascript
function shallowClone(obj) { let result = {}; for (let p in obj) { if (obj.hasOwnProperty(p)) { result[p] = obj[p]; } } return result; }
[ "function", "shallowClone", "(", "obj", ")", "{", "let", "result", "=", "{", "}", ";", "for", "(", "let", "p", "in", "obj", ")", "{", "if", "(", "obj", ".", "hasOwnProperty", "(", "p", ")", ")", "{", "result", "[", "p", "]", "=", "obj", "[", ...
clones the given object's properties shallowly, ignores properties from prototype @param obj the object to clone @return the cloned object
[ "clones", "the", "given", "object", "s", "properties", "shallowly", "ignores", "properties", "from", "prototype" ]
4eecb5c1689726e413734c536a0bd1f93a334c02
https://github.com/Mermade/oas-kit/blob/4eecb5c1689726e413734c536a0bd1f93a334c02/packages/reftools/lib/clone.js#L32-L40
train
Mermade/oas-kit
packages/reftools/lib/clone.js
deepClone
function deepClone(obj) { let result = Array.isArray(obj) ? [] : {}; for (let p in obj) { if (obj.hasOwnProperty(p) || Array.isArray(obj)) { result[p] = (typeof obj[p] === 'object') ? deepClone(obj[p]) : obj[p]; } } return result; }
javascript
function deepClone(obj) { let result = Array.isArray(obj) ? [] : {}; for (let p in obj) { if (obj.hasOwnProperty(p) || Array.isArray(obj)) { result[p] = (typeof obj[p] === 'object') ? deepClone(obj[p]) : obj[p]; } } return result; }
[ "function", "deepClone", "(", "obj", ")", "{", "let", "result", "=", "Array", ".", "isArray", "(", "obj", ")", "?", "[", "]", ":", "{", "}", ";", "for", "(", "let", "p", "in", "obj", ")", "{", "if", "(", "obj", ".", "hasOwnProperty", "(", "p", ...
clones the given object's properties deeply, ignores properties from prototype @param obj the object to clone @return the cloned object
[ "clones", "the", "given", "object", "s", "properties", "deeply", "ignores", "properties", "from", "prototype" ]
4eecb5c1689726e413734c536a0bd1f93a334c02
https://github.com/Mermade/oas-kit/blob/4eecb5c1689726e413734c536a0bd1f93a334c02/packages/reftools/lib/clone.js#L47-L55
train
Mermade/oas-kit
packages/reftools/lib/recurse.js
recurse
function recurse(object, state, callback) { if (!state) state = {depth:0}; if (!state.depth) { state = Object.assign({},defaultState(),state); } if (typeof object !== 'object') return; let oPath = state.path; for (let key in object) { state.key = key; state.path = state.p...
javascript
function recurse(object, state, callback) { if (!state) state = {depth:0}; if (!state.depth) { state = Object.assign({},defaultState(),state); } if (typeof object !== 'object') return; let oPath = state.path; for (let key in object) { state.key = key; state.path = state.p...
[ "function", "recurse", "(", "object", ",", "state", ",", "callback", ")", "{", "if", "(", "!", "state", ")", "state", "=", "{", "depth", ":", "0", "}", ";", "if", "(", "!", "state", ".", "depth", ")", "{", "state", "=", "Object", ".", "assign", ...
recurses through the properties of an object, given an optional starting state anything you pass in state.payload is passed to the callback each time @param object the object to recurse through @param state optional starting state, can be set to null or {} @param callback the function which receives object,key,state on...
[ "recurses", "through", "the", "properties", "of", "an", "object", "given", "an", "optional", "starting", "state", "anything", "you", "pass", "in", "state", ".", "payload", "is", "passed", "to", "the", "callback", "each", "time" ]
4eecb5c1689726e413734c536a0bd1f93a334c02
https://github.com/Mermade/oas-kit/blob/4eecb5c1689726e413734c536a0bd1f93a334c02/packages/reftools/lib/recurse.js#L25-L55
train
Mermade/oas-kit
packages/oas-schema-walker/index.js
getDefaultState
function getDefaultState() { return { depth: 0, seen: new WeakMap(), top: true, combine: false, allowRefSiblings: false }; }
javascript
function getDefaultState() { return { depth: 0, seen: new WeakMap(), top: true, combine: false, allowRefSiblings: false }; }
[ "function", "getDefaultState", "(", ")", "{", "return", "{", "depth", ":", "0", ",", "seen", ":", "new", "WeakMap", "(", ")", ",", "top", ":", "true", ",", "combine", ":", "false", ",", "allowRefSiblings", ":", "false", "}", ";", "}" ]
functions to walk an OpenAPI schema object and traverse all subschemas calling a callback function on each one obtains the default starting state for the `state` object used by walkSchema @return the state object suitable for use in walkSchema
[ "functions", "to", "walk", "an", "OpenAPI", "schema", "object", "and", "traverse", "all", "subschemas", "calling", "a", "callback", "function", "on", "each", "one", "obtains", "the", "default", "starting", "state", "for", "the", "state", "object", "used", "by"...
4eecb5c1689726e413734c536a0bd1f93a334c02
https://github.com/Mermade/oas-kit/blob/4eecb5c1689726e413734c536a0bd1f93a334c02/packages/oas-schema-walker/index.js#L13-L15
train
Mermade/oas-kit
packages/reftools/lib/toposort.js
hasIncomingEdge
function hasIncomingEdge(list, node) { for (var i = 0, l = list.length; i < l; ++i) { if (list[i].links.find(function(e,i,a){ return node._id == e; })) return true; } return false; }
javascript
function hasIncomingEdge(list, node) { for (var i = 0, l = list.length; i < l; ++i) { if (list[i].links.find(function(e,i,a){ return node._id == e; })) return true; } return false; }
[ "function", "hasIncomingEdge", "(", "list", ",", "node", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "list", ".", "length", ";", "i", "<", "l", ";", "++", "i", ")", "{", "if", "(", "list", "[", "i", "]", ".", "links", ".", "f...
Test if a node has got any incoming edges
[ "Test", "if", "a", "node", "has", "got", "any", "incoming", "edges" ]
4eecb5c1689726e413734c536a0bd1f93a334c02
https://github.com/Mermade/oas-kit/blob/4eecb5c1689726e413734c536a0bd1f93a334c02/packages/reftools/lib/toposort.js#L41-L48
train
Mermade/oas-kit
packages/reftools/lib/flatten.js
flatten
function flatten(obj,callback) { let arr = []; let iDepth, oDepth = 0; let state = {identityDetection:true}; recurse(obj,state,function(obj,key,state){ let entry = {}; entry.name = key; entry.value = obj[key]; entry.path = state.path; entry.parent = obj; e...
javascript
function flatten(obj,callback) { let arr = []; let iDepth, oDepth = 0; let state = {identityDetection:true}; recurse(obj,state,function(obj,key,state){ let entry = {}; entry.name = key; entry.value = obj[key]; entry.path = state.path; entry.parent = obj; e...
[ "function", "flatten", "(", "obj", ",", "callback", ")", "{", "let", "arr", "=", "[", "]", ";", "let", "iDepth", ",", "oDepth", "=", "0", ";", "let", "state", "=", "{", "identityDetection", ":", "true", "}", ";", "recurse", "(", "obj", ",", "state"...
flattens an object into an array of properties @param obj the object to flatten @param callback a function which can mutate or filter the entries (by returning null) @return the flattened object as an array of properties
[ "flattens", "an", "object", "into", "an", "array", "of", "properties" ]
4eecb5c1689726e413734c536a0bd1f93a334c02
https://github.com/Mermade/oas-kit/blob/4eecb5c1689726e413734c536a0bd1f93a334c02/packages/reftools/lib/flatten.js#L11-L36
train
Mermade/oas-kit
packages/oas-resolver/index.js
optionalResolve
function optionalResolve(options) { setupOptions(options); return new Promise(function (res, rej) { if (options.resolve) loopReferences(options, res, rej) else res(options); }); }
javascript
function optionalResolve(options) { setupOptions(options); return new Promise(function (res, rej) { if (options.resolve) loopReferences(options, res, rej) else res(options); }); }
[ "function", "optionalResolve", "(", "options", ")", "{", "setupOptions", "(", "options", ")", ";", "return", "new", "Promise", "(", "function", "(", "res", ",", "rej", ")", "{", "if", "(", "options", ".", "resolve", ")", "loopReferences", "(", "options", ...
compatibility function for swagger2openapi
[ "compatibility", "function", "for", "swagger2openapi" ]
4eecb5c1689726e413734c536a0bd1f93a334c02
https://github.com/Mermade/oas-kit/blob/4eecb5c1689726e413734c536a0bd1f93a334c02/packages/oas-resolver/index.js#L474-L482
train
jeffijoe/awilix
examples/simple/services/functionalService.js
getStuffAndDeleteSecret
function getStuffAndDeleteSecret(opts, someArgument) { // We depend on "stuffs" repository. const stuffs = opts.stuffs // We may now carry on. return stuffs.getStuff(someArgument).then(stuff => { // Modify return value. Just to prove this is testable. delete stuff.secret return stuff }) }
javascript
function getStuffAndDeleteSecret(opts, someArgument) { // We depend on "stuffs" repository. const stuffs = opts.stuffs // We may now carry on. return stuffs.getStuff(someArgument).then(stuff => { // Modify return value. Just to prove this is testable. delete stuff.secret return stuff }) }
[ "function", "getStuffAndDeleteSecret", "(", "opts", ",", "someArgument", ")", "{", "// We depend on \"stuffs\" repository.", "const", "stuffs", "=", "opts", ".", "stuffs", "// We may now carry on.", "return", "stuffs", ".", "getStuff", "(", "someArgument", ")", ".", "...
By exporting this function as-is, we can inject mocks as the first argument!!!!!
[ "By", "exporting", "this", "function", "as", "-", "is", "we", "can", "inject", "mocks", "as", "the", "first", "argument!!!!!" ]
7dec4cc462b8d2886a0be72811c1687ca761586a
https://github.com/jeffijoe/awilix/blob/7dec4cc462b8d2886a0be72811c1687ca761586a/examples/simple/services/functionalService.js#L15-L25
train
EventSource/eventsource
lib/eventsource.js
get
function get () { var listener = this.listeners(method)[0] return listener ? (listener._listener ? listener._listener : listener) : undefined }
javascript
function get () { var listener = this.listeners(method)[0] return listener ? (listener._listener ? listener._listener : listener) : undefined }
[ "function", "get", "(", ")", "{", "var", "listener", "=", "this", ".", "listeners", "(", "method", ")", "[", "0", "]", "return", "listener", "?", "(", "listener", ".", "_listener", "?", "listener", ".", "_listener", ":", "listener", ")", ":", "undefine...
Returns the current listener @return {Mixed} the set function or undefined @api private
[ "Returns", "the", "current", "listener" ]
82d38b0b0028ba92e861240eb6a943cbcafc8dff
https://github.com/EventSource/eventsource/blob/82d38b0b0028ba92e861240eb6a943cbcafc8dff/lib/eventsource.js#L311-L314
train
zhangyuanwei/node-images
scripts/util/extensions.js
getBinaryUrl
function getBinaryUrl() { var site = getArgument('--fis-binary-site') || process.env.FIS_BINARY_SITE || process.env.npm_config_FIS_binary_site || (pkg.nodeConfig && pkg.nodeConfig.binarySite) || 'https://github.com/' + repositoryName + '/releases/download'; retu...
javascript
function getBinaryUrl() { var site = getArgument('--fis-binary-site') || process.env.FIS_BINARY_SITE || process.env.npm_config_FIS_binary_site || (pkg.nodeConfig && pkg.nodeConfig.binarySite) || 'https://github.com/' + repositoryName + '/releases/download'; retu...
[ "function", "getBinaryUrl", "(", ")", "{", "var", "site", "=", "getArgument", "(", "'--fis-binary-site'", ")", "||", "process", ".", "env", ".", "FIS_BINARY_SITE", "||", "process", ".", "env", ".", "npm_config_FIS_binary_site", "||", "(", "pkg", ".", "nodeConf...
Determine the URL to fetch binary file from. By default fetch from the addon for fis distribution site on GitHub. The default URL can be overriden using the environment variable FIS_BINARY_SITE, .npmrc variable FIS_binary_site or or a command line option --fis-binary-site: node scripts/install.js --fis-binary-site ht...
[ "Determine", "the", "URL", "to", "fetch", "binary", "file", "from", ".", "By", "default", "fetch", "from", "the", "addon", "for", "fis", "distribution", "site", "on", "GitHub", "." ]
634bd909a7fb9cf0656b70b7bcb98dbe4f7f1920
https://github.com/zhangyuanwei/node-images/blob/634bd909a7fb9cf0656b70b7bcb98dbe4f7f1920/scripts/util/extensions.js#L239-L247
train
qiqiboy/react-formutil
dist/react-formutil.cjs.development.js
deepClone
function deepClone(obj) { if (obj && typeof obj === 'object') { if (Array.isArray(obj)) { var newObj = []; for (var i = 0, j = obj.length; i < j; i++) { newObj[i] = deepClone(obj[i]); } return newObj; } else if (isPlainObj(obj)) { var _newObj = {}; for (var _i in...
javascript
function deepClone(obj) { if (obj && typeof obj === 'object') { if (Array.isArray(obj)) { var newObj = []; for (var i = 0, j = obj.length; i < j; i++) { newObj[i] = deepClone(obj[i]); } return newObj; } else if (isPlainObj(obj)) { var _newObj = {}; for (var _i in...
[ "function", "deepClone", "(", "obj", ")", "{", "if", "(", "obj", "&&", "typeof", "obj", "===", "'object'", ")", "{", "if", "(", "Array", ".", "isArray", "(", "obj", ")", ")", "{", "var", "newObj", "=", "[", "]", ";", "for", "(", "var", "i", "="...
quick clone deeply
[ "quick", "clone", "deeply" ]
5ca93ce18dd7df80ca62491e3f671a7b1282cb41
https://github.com/qiqiboy/react-formutil/blob/5ca93ce18dd7df80ca62491e3f671a7b1282cb41/dist/react-formutil.cjs.development.js#L221-L243
train
openid/AppAuth-JS
built/logger.js
profile
function profile(target, propertyKey, descriptor) { if (flags_1.IS_PROFILE) { return performProfile(target, propertyKey, descriptor); } else { // return as-is return descriptor; } }
javascript
function profile(target, propertyKey, descriptor) { if (flags_1.IS_PROFILE) { return performProfile(target, propertyKey, descriptor); } else { // return as-is return descriptor; } }
[ "function", "profile", "(", "target", ",", "propertyKey", ",", "descriptor", ")", "{", "if", "(", "flags_1", ".", "IS_PROFILE", ")", "{", "return", "performProfile", "(", "target", ",", "propertyKey", ",", "descriptor", ")", ";", "}", "else", "{", "// retu...
A decorator that can profile a function.
[ "A", "decorator", "that", "can", "profile", "a", "function", "." ]
9b502f68857432939013864c74e37deab12abb14
https://github.com/openid/AppAuth-JS/blob/9b502f68857432939013864c74e37deab12abb14/built/logger.js#L39-L47
train
BetterJS/badjs-report
dist/bj-report-tryjs.js
function(foo, self) { return function() { var arg, tmp, args = []; for (var i = 0, l = arguments.length; i < l; i++) { arg = arguments[i]; if (_isFunction(arg)) { if (arg.tryWrap) { arg = arg.tryWrap; ...
javascript
function(foo, self) { return function() { var arg, tmp, args = []; for (var i = 0, l = arguments.length; i < l; i++) { arg = arguments[i]; if (_isFunction(arg)) { if (arg.tryWrap) { arg = arg.tryWrap; ...
[ "function", "(", "foo", ",", "self", ")", "{", "return", "function", "(", ")", "{", "var", "arg", ",", "tmp", ",", "args", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ",", "l", "=", "arguments", ".", "length", ";", "i", "<", "l", ...
makeArgsTry wrap a function's arguments with try & catch @param {Function} foo @param {Object} self @returns {Function}
[ "makeArgsTry", "wrap", "a", "function", "s", "arguments", "with", "try", "&", "catch" ]
a4444c7d790edc1c9b79d79cf46d8719598bd91e
https://github.com/BetterJS/badjs-report/blob/a4444c7d790edc1c9b79d79cf46d8719598bd91e/dist/bj-report-tryjs.js#L689-L707
train
BetterJS/badjs-report
dist/bj-report-tryjs.js
function(obj) { var key, value; for (key in obj) { value = obj[key]; if (_isFunction(value)) obj[key] = cat(value); } return obj; }
javascript
function(obj) { var key, value; for (key in obj) { value = obj[key]; if (_isFunction(value)) obj[key] = cat(value); } return obj; }
[ "function", "(", "obj", ")", "{", "var", "key", ",", "value", ";", "for", "(", "key", "in", "obj", ")", "{", "value", "=", "obj", "[", "key", "]", ";", "if", "(", "_isFunction", "(", "value", ")", ")", "obj", "[", "key", "]", "=", "cat", "(",...
makeObjTry wrap a object's all value with try & catch @param {Function} foo @param {Object} self @returns {Function}
[ "makeObjTry", "wrap", "a", "object", "s", "all", "value", "with", "try", "&", "catch" ]
a4444c7d790edc1c9b79d79cf46d8719598bd91e
https://github.com/BetterJS/badjs-report/blob/a4444c7d790edc1c9b79d79cf46d8719598bd91e/dist/bj-report-tryjs.js#L716-L723
train
filamentgroup/tablesaw
dist/tablesaw.js
encasedCallback
function encasedCallback( e, namespace, triggeredElement ){ var result; if( e._namespace && e._namespace !== namespace ) { return; } e.data = data; e.namespace = e._namespace; var returnTrue = function(){ return true; }; e.isDefaultPrevented = function(){ return false; }; ...
javascript
function encasedCallback( e, namespace, triggeredElement ){ var result; if( e._namespace && e._namespace !== namespace ) { return; } e.data = data; e.namespace = e._namespace; var returnTrue = function(){ return true; }; e.isDefaultPrevented = function(){ return false; }; ...
[ "function", "encasedCallback", "(", "e", ",", "namespace", ",", "triggeredElement", ")", "{", "var", "result", ";", "if", "(", "e", ".", "_namespace", "&&", "e", ".", "_namespace", "!==", "namespace", ")", "{", "return", ";", "}", "e", ".", "data", "="...
NOTE the `triggeredElement` is purely for custom events from IE
[ "NOTE", "the", "triggeredElement", "is", "purely", "for", "custom", "events", "from", "IE" ]
6c3387b71d659773e1c7dcb5d7aa5bcb83f53932
https://github.com/filamentgroup/tablesaw/blob/6c3387b71d659773e1c7dcb5d7aa5bcb83f53932/dist/tablesaw.js#L1442-L1490
train
panva/node-openid-client
lib/client.js
checkBasicSupport
function checkBasicSupport(client, metadata, properties) { try { const supported = client.issuer.token_endpoint_auth_methods_supported; if (!supported.includes(properties.token_endpoint_auth_method)) { if (supported.includes('client_secret_post')) { properties.token_endpoint_auth_method = 'clien...
javascript
function checkBasicSupport(client, metadata, properties) { try { const supported = client.issuer.token_endpoint_auth_methods_supported; if (!supported.includes(properties.token_endpoint_auth_method)) { if (supported.includes('client_secret_post')) { properties.token_endpoint_auth_method = 'clien...
[ "function", "checkBasicSupport", "(", "client", ",", "metadata", ",", "properties", ")", "{", "try", "{", "const", "supported", "=", "client", ".", "issuer", ".", "token_endpoint_auth_methods_supported", ";", "if", "(", "!", "supported", ".", "includes", "(", ...
if an OP doesnt support client_secret_basic but supports client_secret_post, use it instead this is in place to take care of most common pitfalls when first using discovered Issuers without the support for default values defined by Discovery 1.0
[ "if", "an", "OP", "doesnt", "support", "client_secret_basic", "but", "supports", "client_secret_post", "use", "it", "instead", "this", "is", "in", "place", "to", "take", "care", "of", "most", "common", "pitfalls", "when", "first", "using", "discovered", "Issuers...
571d9011c7a9b12731cda3e7b0b2e33bfd785bf0
https://github.com/panva/node-openid-client/blob/571d9011c7a9b12731cda3e7b0b2e33bfd785bf0/lib/client.js#L157-L166
train
chenz24/vue-blu
build/vue-markdown-loader2/index.js
function (html) { var $ = cheerio.load(html, { decodeEntities: false, lowerCaseAttributeNames: false, lowerCaseTags: false }); var output = { style: $.html('style'), script: $.html('script') }; var result; $('style').remove(); $('script').remove(); result = '<template><section>' +...
javascript
function (html) { var $ = cheerio.load(html, { decodeEntities: false, lowerCaseAttributeNames: false, lowerCaseTags: false }); var output = { style: $.html('style'), script: $.html('script') }; var result; $('style').remove(); $('script').remove(); result = '<template><section>' +...
[ "function", "(", "html", ")", "{", "var", "$", "=", "cheerio", ".", "load", "(", "html", ",", "{", "decodeEntities", ":", "false", ",", "lowerCaseAttributeNames", ":", "false", ",", "lowerCaseTags", ":", "false", "}", ")", ";", "var", "output", "=", "{...
html => vue file template @param {[type]} html [description] @return {[type]} [description]
[ "html", "=", ">", "vue", "file", "template" ]
2db168776a8fbcd28263e14f8e0043aa258c0fa6
https://github.com/chenz24/vue-blu/blob/2db168776a8fbcd28263e14f8e0043aa258c0fa6/build/vue-markdown-loader2/index.js#L48-L69
train
jantimon/favicons-webpack-plugin
index.js
guessAppName
function guessAppName (compilerWorkingDirectory) { var packageJson = path.resolve(compilerWorkingDirectory, 'package.json'); if (!fs.existsSync(packageJson)) { packageJson = path.resolve(compilerWorkingDirectory, '../package.json'); if (!fs.existsSync(packageJson)) { return 'Webpack App'; } } ...
javascript
function guessAppName (compilerWorkingDirectory) { var packageJson = path.resolve(compilerWorkingDirectory, 'package.json'); if (!fs.existsSync(packageJson)) { packageJson = path.resolve(compilerWorkingDirectory, '../package.json'); if (!fs.existsSync(packageJson)) { return 'Webpack App'; } } ...
[ "function", "guessAppName", "(", "compilerWorkingDirectory", ")", "{", "var", "packageJson", "=", "path", ".", "resolve", "(", "compilerWorkingDirectory", ",", "'package.json'", ")", ";", "if", "(", "!", "fs", ".", "existsSync", "(", "packageJson", ")", ")", "...
Tries to guess the name from the package.json
[ "Tries", "to", "guess", "the", "name", "from", "the", "package", ".", "json" ]
7845e4f20a54776555674ecc0537ca3d89aa2ccd
https://github.com/jantimon/favicons-webpack-plugin/blob/7845e4f20a54776555674ecc0537ca3d89aa2ccd/index.js#L94-L103
train
jantimon/favicons-webpack-plugin
lib/cache.js
emitCacheInformationFile
function emitCacheInformationFile (loader, query, cacheFile, fileHash, iconResult) { if (!query.persistentCache) { return; } loader.emitFile(cacheFile, JSON.stringify({ hash: fileHash, version: pluginVersion, optionHash: generateHashForOptions(query), result: iconResult })); }
javascript
function emitCacheInformationFile (loader, query, cacheFile, fileHash, iconResult) { if (!query.persistentCache) { return; } loader.emitFile(cacheFile, JSON.stringify({ hash: fileHash, version: pluginVersion, optionHash: generateHashForOptions(query), result: iconResult })); }
[ "function", "emitCacheInformationFile", "(", "loader", ",", "query", ",", "cacheFile", ",", "fileHash", ",", "iconResult", ")", "{", "if", "(", "!", "query", ".", "persistentCache", ")", "{", "return", ";", "}", "loader", ".", "emitFile", "(", "cacheFile", ...
Stores the given iconResult together with the control hashes as JSON file
[ "Stores", "the", "given", "iconResult", "together", "with", "the", "control", "hashes", "as", "JSON", "file" ]
7845e4f20a54776555674ecc0537ca3d89aa2ccd
https://github.com/jantimon/favicons-webpack-plugin/blob/7845e4f20a54776555674ecc0537ca3d89aa2ccd/lib/cache.js#L15-L25
train
jantimon/favicons-webpack-plugin
lib/cache.js
isCacheValid
function isCacheValid (cache, fileHash, query) { // Verify that the source file is the same return cache.hash === fileHash && // Verify that the options are the same cache.optionHash === generateHashForOptions(query) && // Verify that the favicons version of the cache maches this version cache.versi...
javascript
function isCacheValid (cache, fileHash, query) { // Verify that the source file is the same return cache.hash === fileHash && // Verify that the options are the same cache.optionHash === generateHashForOptions(query) && // Verify that the favicons version of the cache maches this version cache.versi...
[ "function", "isCacheValid", "(", "cache", ",", "fileHash", ",", "query", ")", "{", "// Verify that the source file is the same", "return", "cache", ".", "hash", "===", "fileHash", "&&", "// Verify that the options are the same", "cache", ".", "optionHash", "===", "gener...
Checks if the given cache object is still valid
[ "Checks", "if", "the", "given", "cache", "object", "is", "still", "valid" ]
7845e4f20a54776555674ecc0537ca3d89aa2ccd
https://github.com/jantimon/favicons-webpack-plugin/blob/7845e4f20a54776555674ecc0537ca3d89aa2ccd/lib/cache.js#L30-L37
train
jantimon/favicons-webpack-plugin
lib/cache.js
loadIconsFromDiskCache
function loadIconsFromDiskCache (loader, query, cacheFile, fileHash, callback) { // Stop if cache is disabled if (!query.persistentCache) return callback(null); var resolvedCacheFile = path.resolve(loader._compiler.parentCompilation.compiler.outputPath, cacheFile); fs.exists(resolvedCacheFile, function (exists...
javascript
function loadIconsFromDiskCache (loader, query, cacheFile, fileHash, callback) { // Stop if cache is disabled if (!query.persistentCache) return callback(null); var resolvedCacheFile = path.resolve(loader._compiler.parentCompilation.compiler.outputPath, cacheFile); fs.exists(resolvedCacheFile, function (exists...
[ "function", "loadIconsFromDiskCache", "(", "loader", ",", "query", ",", "cacheFile", ",", "fileHash", ",", "callback", ")", "{", "// Stop if cache is disabled", "if", "(", "!", "query", ".", "persistentCache", ")", "return", "callback", "(", "null", ")", ";", ...
Try to load the file from the disc cache
[ "Try", "to", "load", "the", "file", "from", "the", "disc", "cache" ]
7845e4f20a54776555674ecc0537ca3d89aa2ccd
https://github.com/jantimon/favicons-webpack-plugin/blob/7845e4f20a54776555674ecc0537ca3d89aa2ccd/lib/cache.js#L42-L64
train
jantimon/favicons-webpack-plugin
lib/cache.js
generateHashForOptions
function generateHashForOptions (options) { var hash = crypto.createHash('md5'); hash.update(JSON.stringify(options)); return hash.digest('hex'); }
javascript
function generateHashForOptions (options) { var hash = crypto.createHash('md5'); hash.update(JSON.stringify(options)); return hash.digest('hex'); }
[ "function", "generateHashForOptions", "(", "options", ")", "{", "var", "hash", "=", "crypto", ".", "createHash", "(", "'md5'", ")", ";", "hash", ".", "update", "(", "JSON", ".", "stringify", "(", "options", ")", ")", ";", "return", "hash", ".", "digest",...
Generates a md5 hash for the given options
[ "Generates", "a", "md5", "hash", "for", "the", "given", "options" ]
7845e4f20a54776555674ecc0537ca3d89aa2ccd
https://github.com/jantimon/favicons-webpack-plugin/blob/7845e4f20a54776555674ecc0537ca3d89aa2ccd/lib/cache.js#L69-L73
train
davestewart/vuex-pathify
src/services/store.js
getValueIfEnabled
function getValueIfEnabled(expr, source, path) { if (!options.deep && expr.includes('@')) { console.error(`[Vuex Pathify] Unable to access sub-property for path '${expr}': - Set option 'deep' to 1 to allow it`) return } return getValue(source, path) }
javascript
function getValueIfEnabled(expr, source, path) { if (!options.deep && expr.includes('@')) { console.error(`[Vuex Pathify] Unable to access sub-property for path '${expr}': - Set option 'deep' to 1 to allow it`) return } return getValue(source, path) }
[ "function", "getValueIfEnabled", "(", "expr", ",", "source", ",", "path", ")", "{", "if", "(", "!", "options", ".", "deep", "&&", "expr", ".", "includes", "(", "'@'", ")", ")", "{", "console", ".", "error", "(", "`", "${", "expr", "}", "`", ")", ...
Utility function to get value from store, but only if options allow @param {string} expr The full path expression @param {object} source The source object to get property from @param {string} path The full dot-path on the source object @returns {*}
[ "Utility", "function", "to", "get", "value", "from", "store", "but", "only", "if", "options", "allow" ]
c5480a86f4f25b772862ffe68927988d81ca7306
https://github.com/davestewart/vuex-pathify/blob/c5480a86f4f25b772862ffe68927988d81ca7306/src/services/store.js#L96-L103
train
davestewart/vuex-pathify
src/helpers/decorators.js
Get
function Get(path) { if (typeof path !== 'string' || arguments.length > 1) { throw new Error('Property decorators can be used for single property access') } return createDecorator((options, key) => { if (!options.computed) options.computed = {} options.computed[key] = get(path) }) }
javascript
function Get(path) { if (typeof path !== 'string' || arguments.length > 1) { throw new Error('Property decorators can be used for single property access') } return createDecorator((options, key) => { if (!options.computed) options.computed = {} options.computed[key] = get(path) }) }
[ "function", "Get", "(", "path", ")", "{", "if", "(", "typeof", "path", "!==", "'string'", "||", "arguments", ".", "length", ">", "1", ")", "{", "throw", "new", "Error", "(", "'Property decorators can be used for single property access'", ")", "}", "return", "c...
Decortaor for `get` component helper. @param {string} path - Path in store @returns {VueDecorator} - Vue decortaor to be used in cue class component.
[ "Decortaor", "for", "get", "component", "helper", "." ]
c5480a86f4f25b772862ffe68927988d81ca7306
https://github.com/davestewart/vuex-pathify/blob/c5480a86f4f25b772862ffe68927988d81ca7306/src/helpers/decorators.js#L25-L31
train
davestewart/vuex-pathify
src/helpers/decorators.js
Sync
function Sync(path) { if (typeof path !== 'string' || arguments.length > 1) { throw new Error('Property decorators can be used for single property access') } return createDecorator((options, key) => { if (!options.computed) options.computed = {} options.computed[key] = sync(path) }) }
javascript
function Sync(path) { if (typeof path !== 'string' || arguments.length > 1) { throw new Error('Property decorators can be used for single property access') } return createDecorator((options, key) => { if (!options.computed) options.computed = {} options.computed[key] = sync(path) }) }
[ "function", "Sync", "(", "path", ")", "{", "if", "(", "typeof", "path", "!==", "'string'", "||", "arguments", ".", "length", ">", "1", ")", "{", "throw", "new", "Error", "(", "'Property decorators can be used for single property access'", ")", "}", "return", "...
Decortaor for `sync` component helper. @param {string} path - Path in store @returns {VueDecorator} - Vue decortaor to be used in cue class component.
[ "Decortaor", "for", "sync", "component", "helper", "." ]
c5480a86f4f25b772862ffe68927988d81ca7306
https://github.com/davestewart/vuex-pathify/blob/c5480a86f4f25b772862ffe68927988d81ca7306/src/helpers/decorators.js#L38-L44
train
davestewart/vuex-pathify
src/helpers/decorators.js
Call
function Call(path) { if (typeof path !== 'string' || arguments.length > 1) { throw new Error('Property decorators can be used for single property access') } return createDecorator((options, key) => { if (!options.methods) options.methods = {} options.methods[key] = call(path) }) }
javascript
function Call(path) { if (typeof path !== 'string' || arguments.length > 1) { throw new Error('Property decorators can be used for single property access') } return createDecorator((options, key) => { if (!options.methods) options.methods = {} options.methods[key] = call(path) }) }
[ "function", "Call", "(", "path", ")", "{", "if", "(", "typeof", "path", "!==", "'string'", "||", "arguments", ".", "length", ">", "1", ")", "{", "throw", "new", "Error", "(", "'Property decorators can be used for single property access'", ")", "}", "return", "...
Decortaor for `call` component helper. @param {string} path - Path in store @returns {VueDecorator} - Vue decortaor to be used in cue class component.
[ "Decortaor", "for", "call", "component", "helper", "." ]
c5480a86f4f25b772862ffe68927988d81ca7306
https://github.com/davestewart/vuex-pathify/blob/c5480a86f4f25b772862ffe68927988d81ca7306/src/helpers/decorators.js#L51-L57
train
davestewart/vuex-pathify
docs/assets/js/plugins.js
fixAnchors
function fixAnchors (hook) { hook.afterEach(function (html, next) { // find all headings and replace them html = html.replace(/<(h\d).+?<\/\1>/g, function (html) { // create temp node var div = document.createElement('div') div.innerHTML = html // get anchor var link = div.qu...
javascript
function fixAnchors (hook) { hook.afterEach(function (html, next) { // find all headings and replace them html = html.replace(/<(h\d).+?<\/\1>/g, function (html) { // create temp node var div = document.createElement('div') div.innerHTML = html // get anchor var link = div.qu...
[ "function", "fixAnchors", "(", "hook", ")", "{", "hook", ".", "afterEach", "(", "function", "(", "html", ",", "next", ")", "{", "// find all headings and replace them", "html", "=", "html", ".", "replace", "(", "/", "<(h\\d).+?<\\/\\1>", "/", "g", ",", "func...
Fix anchors for all headings with code in them @param hook
[ "Fix", "anchors", "for", "all", "headings", "with", "code", "in", "them" ]
c5480a86f4f25b772862ffe68927988d81ca7306
https://github.com/davestewart/vuex-pathify/blob/c5480a86f4f25b772862ffe68927988d81ca7306/docs/assets/js/plugins.js#L84-L125
train
infinitered/ignite-andross
boilerplate.js
function(context) { const androidHome = process.env['ANDROID_HOME'] const hasAndroidEnv = !context.strings.isBlank(androidHome) const hasAndroid = hasAndroidEnv && context.filesystem.exists(`${androidHome}/tools`) === 'dir' return Boolean(hasAndroid) }
javascript
function(context) { const androidHome = process.env['ANDROID_HOME'] const hasAndroidEnv = !context.strings.isBlank(androidHome) const hasAndroid = hasAndroidEnv && context.filesystem.exists(`${androidHome}/tools`) === 'dir' return Boolean(hasAndroid) }
[ "function", "(", "context", ")", "{", "const", "androidHome", "=", "process", ".", "env", "[", "'ANDROID_HOME'", "]", "const", "hasAndroidEnv", "=", "!", "context", ".", "strings", ".", "isBlank", "(", "androidHome", ")", "const", "hasAndroid", "=", "hasAndr...
Is Android installed? $ANDROID_HOME/tools folder has to exist. @param {*} context - The gluegun context. @returns {boolean}
[ "Is", "Android", "installed?" ]
f1548bf721d36fb724af1b4ea95288f4e576ee94
https://github.com/infinitered/ignite-andross/blob/f1548bf721d36fb724af1b4ea95288f4e576ee94/boilerplate.js#L13-L19
train
dwyl/aws-sdk-mock
index.js
restoreService
function restoreService(service) { if (services[service]) { restoreAllMethods(service); if (services[service].stub) services[service].stub.restore(); delete services[service]; } else { console.log('Service ' + service + ' was never instantiated yet you try to restore it.'); } }
javascript
function restoreService(service) { if (services[service]) { restoreAllMethods(service); if (services[service].stub) services[service].stub.restore(); delete services[service]; } else { console.log('Service ' + service + ' was never instantiated yet you try to restore it.'); } }
[ "function", "restoreService", "(", "service", ")", "{", "if", "(", "services", "[", "service", "]", ")", "{", "restoreAllMethods", "(", "service", ")", ";", "if", "(", "services", "[", "service", "]", ".", "stub", ")", "services", "[", "service", "]", ...
Restores a single mocked service and its corresponding methods.
[ "Restores", "a", "single", "mocked", "service", "and", "its", "corresponding", "methods", "." ]
5607af878387515beb71e130a651017dfe6e7107
https://github.com/dwyl/aws-sdk-mock/blob/5607af878387515beb71e130a651017dfe6e7107/index.js#L250-L259
train
Microsoft/fast-dna
build/copy-readme.js
copyReadmeFiles
function copyReadmeFiles() { const resolvedSrcReadmePaths = path.resolve(rootDir, srcReadmePaths); glob(resolvedSrcReadmePaths, void(0), function(error, files) { files.forEach((filePath) => { const destReadmePath = filePath.replace(/(\bsrc\b)(?!.*\1)/, destDir); fs.copyFileSync(file...
javascript
function copyReadmeFiles() { const resolvedSrcReadmePaths = path.resolve(rootDir, srcReadmePaths); glob(resolvedSrcReadmePaths, void(0), function(error, files) { files.forEach((filePath) => { const destReadmePath = filePath.replace(/(\bsrc\b)(?!.*\1)/, destDir); fs.copyFileSync(file...
[ "function", "copyReadmeFiles", "(", ")", "{", "const", "resolvedSrcReadmePaths", "=", "path", ".", "resolve", "(", "rootDir", ",", "srcReadmePaths", ")", ";", "glob", "(", "resolvedSrcReadmePaths", ",", "void", "(", "0", ")", ",", "function", "(", "error", "...
Function to copy readme files to their dist folder
[ "Function", "to", "copy", "readme", "files", "to", "their", "dist", "folder" ]
807a3ad3252ef8685da95e57490f5015287b0566
https://github.com/Microsoft/fast-dna/blob/807a3ad3252ef8685da95e57490f5015287b0566/build/copy-readme.js#L16-L25
train
Microsoft/fast-dna
build/documentation/generate-typedocs.js
execute
function execute() { if (dryRun) { console.log(`In ${destDir}, this script would...`); } else { console.log(`Generating API documentation using TypeDoc...`); } const packages = path.resolve(rootDir, srcDir); glob(packages, {realpath:true}, function(error, srcFiles) { ...
javascript
function execute() { if (dryRun) { console.log(`In ${destDir}, this script would...`); } else { console.log(`Generating API documentation using TypeDoc...`); } const packages = path.resolve(rootDir, srcDir); glob(packages, {realpath:true}, function(error, srcFiles) { ...
[ "function", "execute", "(", ")", "{", "if", "(", "dryRun", ")", "{", "console", ".", "log", "(", "`", "${", "destDir", "}", "`", ")", ";", "}", "else", "{", "console", ".", "log", "(", "`", "`", ")", ";", "}", "const", "packages", "=", "path", ...
Generate TypeDocs for each package
[ "Generate", "TypeDocs", "for", "each", "package" ]
807a3ad3252ef8685da95e57490f5015287b0566
https://github.com/Microsoft/fast-dna/blob/807a3ad3252ef8685da95e57490f5015287b0566/build/documentation/generate-typedocs.js#L72-L106
train
Microsoft/fast-dna
build/documentation/generate-typedocs.js
addHeaderToReadme
function addHeaderToReadme(packageName) { const readmePath = path.join(destDir, packageName, 'api', 'README.md'); const readmeText = fs.readFileSync(readmePath).toString(); var docusaurusHeader = `---\n` + `id: index\n` + `---\n\n`; try { fs.writeFileSync(readmePath, docusaurusH...
javascript
function addHeaderToReadme(packageName) { const readmePath = path.join(destDir, packageName, 'api', 'README.md'); const readmeText = fs.readFileSync(readmePath).toString(); var docusaurusHeader = `---\n` + `id: index\n` + `---\n\n`; try { fs.writeFileSync(readmePath, docusaurusH...
[ "function", "addHeaderToReadme", "(", "packageName", ")", "{", "const", "readmePath", "=", "path", ".", "join", "(", "destDir", ",", "packageName", ",", "'api'", ",", "'README.md'", ")", ";", "const", "readmeText", "=", "fs", ".", "readFileSync", "(", "readm...
If the TypeDoc readme doesn't have this header It won't be accessible in docusaurus
[ "If", "the", "TypeDoc", "readme", "doesn", "t", "have", "this", "header", "It", "won", "t", "be", "accessible", "in", "docusaurus" ]
807a3ad3252ef8685da95e57490f5015287b0566
https://github.com/Microsoft/fast-dna/blob/807a3ad3252ef8685da95e57490f5015287b0566/build/documentation/generate-typedocs.js#L157-L174
train
Microsoft/fast-dna
build/documentation/generate-typedocs.js
addAPILinkToReadme
function addAPILinkToReadme(packageName) { var readmePath = path.join(destDir, packageName, 'README.md'); var apiLink = "api"; var usageText = "\n" + `[API Reference](${apiLink})`; fs.appendFile(readmePath, usageText, function (err) { if (err) { console.log(chalk...
javascript
function addAPILinkToReadme(packageName) { var readmePath = path.join(destDir, packageName, 'README.md'); var apiLink = "api"; var usageText = "\n" + `[API Reference](${apiLink})`; fs.appendFile(readmePath, usageText, function (err) { if (err) { console.log(chalk...
[ "function", "addAPILinkToReadme", "(", "packageName", ")", "{", "var", "readmePath", "=", "path", ".", "join", "(", "destDir", ",", "packageName", ",", "'README.md'", ")", ";", "var", "apiLink", "=", "\"api\"", ";", "var", "usageText", "=", "\"\\n\"", "+", ...
Creates link in package readme.md docs used by Docusaurus Said link routes to the TypeDoc API docs generated by this script
[ "Creates", "link", "in", "package", "readme", ".", "md", "docs", "used", "by", "Docusaurus", "Said", "link", "routes", "to", "the", "TypeDoc", "API", "docs", "generated", "by", "this", "script" ]
807a3ad3252ef8685da95e57490f5015287b0566
https://github.com/Microsoft/fast-dna/blob/807a3ad3252ef8685da95e57490f5015287b0566/build/documentation/generate-typedocs.js#L180-L195
train
Microsoft/fast-dna
build/documentation/copy-package-readme.js
createDirectory
function createDirectory(dir) { if (!fs.existsSync(dir)) { dryRun ? console.log(`...CREATE the '${dir}' folder.`) : fs.mkdirSync(dir); } }
javascript
function createDirectory(dir) { if (!fs.existsSync(dir)) { dryRun ? console.log(`...CREATE the '${dir}' folder.`) : fs.mkdirSync(dir); } }
[ "function", "createDirectory", "(", "dir", ")", "{", "if", "(", "!", "fs", ".", "existsSync", "(", "dir", ")", ")", "{", "dryRun", "?", "console", ".", "log", "(", "`", "${", "dir", "}", "`", ")", ":", "fs", ".", "mkdirSync", "(", "dir", ")", "...
Utility function that creates new folders based off dir argument
[ "Utility", "function", "that", "creates", "new", "folders", "based", "off", "dir", "argument" ]
807a3ad3252ef8685da95e57490f5015287b0566
https://github.com/Microsoft/fast-dna/blob/807a3ad3252ef8685da95e57490f5015287b0566/build/documentation/copy-package-readme.js#L156-L160
train
Microsoft/fast-dna
build/convert-readme.js
exportReadme
function exportReadme(readmePath) { const readmePaths = path.resolve(process.cwd(), srcDir); glob(readmePaths, void(0), function(error, files) { files.forEach((filePath) => { let documentation = startFile; const markdown = fs.readFileSync(filePath, "utf8"); const exp...
javascript
function exportReadme(readmePath) { const readmePaths = path.resolve(process.cwd(), srcDir); glob(readmePaths, void(0), function(error, files) { files.forEach((filePath) => { let documentation = startFile; const markdown = fs.readFileSync(filePath, "utf8"); const exp...
[ "function", "exportReadme", "(", "readmePath", ")", "{", "const", "readmePaths", "=", "path", ".", "resolve", "(", "process", ".", "cwd", "(", ")", ",", "srcDir", ")", ";", "glob", "(", "readmePaths", ",", "void", "(", "0", ")", ",", "function", "(", ...
Function to create string exports of a given path
[ "Function", "to", "create", "string", "exports", "of", "a", "given", "path" ]
807a3ad3252ef8685da95e57490f5015287b0566
https://github.com/Microsoft/fast-dna/blob/807a3ad3252ef8685da95e57490f5015287b0566/build/convert-readme.js#L46-L70
train
Microsoft/fast-dna
build/clean.js
cleanPath
function cleanPath(cleanPath) { const removePath = path.resolve(process.cwd(), cleanPath) rimraf(removePath, () => { console.log(removePath, "cleaned"); }); }
javascript
function cleanPath(cleanPath) { const removePath = path.resolve(process.cwd(), cleanPath) rimraf(removePath, () => { console.log(removePath, "cleaned"); }); }
[ "function", "cleanPath", "(", "cleanPath", ")", "{", "const", "removePath", "=", "path", ".", "resolve", "(", "process", ".", "cwd", "(", ")", ",", "cleanPath", ")", "rimraf", "(", "removePath", ",", "(", ")", "=>", "{", "console", ".", "log", "(", "...
Function to remove a given path
[ "Function", "to", "remove", "a", "given", "path" ]
807a3ad3252ef8685da95e57490f5015287b0566
https://github.com/Microsoft/fast-dna/blob/807a3ad3252ef8685da95e57490f5015287b0566/build/clean.js#L17-L22
train
Microsoft/fast-dna
build/copy-schemas.js
copySchemaFiles
function copySchemaFiles() { const resolvedSrcSchemaPaths = path.resolve(rootDir, srcSchemaPaths); glob(resolvedSrcSchemaPaths, void(0), function(error, files) { files.forEach((filePath) => { const destSchemaPath = filePath.replace(/(\bsrc\b)(?!.*\1)/, destDir); fs.copyFileSync(file...
javascript
function copySchemaFiles() { const resolvedSrcSchemaPaths = path.resolve(rootDir, srcSchemaPaths); glob(resolvedSrcSchemaPaths, void(0), function(error, files) { files.forEach((filePath) => { const destSchemaPath = filePath.replace(/(\bsrc\b)(?!.*\1)/, destDir); fs.copyFileSync(file...
[ "function", "copySchemaFiles", "(", ")", "{", "const", "resolvedSrcSchemaPaths", "=", "path", ".", "resolve", "(", "rootDir", ",", "srcSchemaPaths", ")", ";", "glob", "(", "resolvedSrcSchemaPaths", ",", "void", "(", "0", ")", ",", "function", "(", "error", "...
Function to copy schema files to their dist folder
[ "Function", "to", "copy", "schema", "files", "to", "their", "dist", "folder" ]
807a3ad3252ef8685da95e57490f5015287b0566
https://github.com/Microsoft/fast-dna/blob/807a3ad3252ef8685da95e57490f5015287b0566/build/copy-schemas.js#L16-L25
train
weareoutman/clockpicker
gulpfile.js
js
function js(prefix) { gulp.src('src/clockpicker.js') .pipe(rename({ prefix: prefix + '-' })) .pipe(replace(versionRegExp, version)) .pipe(gulp.dest('dist')) .pipe(uglify({ preserveComments: 'some' })) .pipe(rename({ suffix: '.min' })) .pipe(gulp.dest('dist')); }
javascript
function js(prefix) { gulp.src('src/clockpicker.js') .pipe(rename({ prefix: prefix + '-' })) .pipe(replace(versionRegExp, version)) .pipe(gulp.dest('dist')) .pipe(uglify({ preserveComments: 'some' })) .pipe(rename({ suffix: '.min' })) .pipe(gulp.dest('dist')); }
[ "function", "js", "(", "prefix", ")", "{", "gulp", ".", "src", "(", "'src/clockpicker.js'", ")", ".", "pipe", "(", "rename", "(", "{", "prefix", ":", "prefix", "+", "'-'", "}", ")", ")", ".", "pipe", "(", "replace", "(", "versionRegExp", ",", "versio...
Rename and uglify scripts
[ "Rename", "and", "uglify", "scripts" ]
e6ac014b3c167281ac37cf122ab19b6967d8fae4
https://github.com/weareoutman/clockpicker/blob/e6ac014b3c167281ac37cf122ab19b6967d8fae4/gulpfile.js#L13-L27
train
weareoutman/clockpicker
gulpfile.js
css
function css(prefix) { var stream; if (prefix === 'bootstrap') { stream = gulp.src('src/clockpicker.css'); } else { // Concat with some styles picked from bootstrap stream = gulp.src(['src/standalone.css', 'src/clockpicker.css']) .pipe(concat('clockpicker.css')); } stream.pipe(rename({ prefix: prefix +...
javascript
function css(prefix) { var stream; if (prefix === 'bootstrap') { stream = gulp.src('src/clockpicker.css'); } else { // Concat with some styles picked from bootstrap stream = gulp.src(['src/standalone.css', 'src/clockpicker.css']) .pipe(concat('clockpicker.css')); } stream.pipe(rename({ prefix: prefix +...
[ "function", "css", "(", "prefix", ")", "{", "var", "stream", ";", "if", "(", "prefix", "===", "'bootstrap'", ")", "{", "stream", "=", "gulp", ".", "src", "(", "'src/clockpicker.css'", ")", ";", "}", "else", "{", "// Concat with some styles picked from bootstra...
Rename, concat and minify stylesheets
[ "Rename", "concat", "and", "minify", "stylesheets" ]
e6ac014b3c167281ac37cf122ab19b6967d8fae4
https://github.com/weareoutman/clockpicker/blob/e6ac014b3c167281ac37cf122ab19b6967d8fae4/gulpfile.js#L30-L51
train
tangrams/tangram
src/leaflet_layer.js
function (layer, targetCenter, targetZoom) { map._stop(); var startZoom = map._zoom; targetCenter = L.latLng(targetCenter); targetZoom = targetZoom === undefined ? startZoom : targetZoom; targetZoom...
javascript
function (layer, targetCenter, targetZoom) { map._stop(); var startZoom = map._zoom; targetCenter = L.latLng(targetCenter); targetZoom = targetZoom === undefined ? startZoom : targetZoom; targetZoom...
[ "function", "(", "layer", ",", "targetCenter", ",", "targetZoom", ")", "{", "map", ".", "_stop", "(", ")", ";", "var", "startZoom", "=", "map", ".", "_zoom", ";", "targetCenter", "=", "L", ".", "latLng", "(", "targetCenter", ")", ";", "targetZoom", "="...
Simplified version of Leaflet's flyTo, for short animations zooming around a point
[ "Simplified", "version", "of", "Leaflet", "s", "flyTo", "for", "short", "animations", "zooming", "around", "a", "point" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/src/leaflet_layer.js#L314-L343
train
tangrams/tangram
src/tile/tile.js
addDebugLayers
function addDebugLayers (node, tree) { for (let layer in node) { let counts = node[layer]; addLayerDebugEntry(tree, layer, counts.features, counts.geoms, counts.styles, counts.base); if (counts.layers) { tree[layer].layers = tree[layer].layers || {}; addDebugLayers(co...
javascript
function addDebugLayers (node, tree) { for (let layer in node) { let counts = node[layer]; addLayerDebugEntry(tree, layer, counts.features, counts.geoms, counts.styles, counts.base); if (counts.layers) { tree[layer].layers = tree[layer].layers || {}; addDebugLayers(co...
[ "function", "addDebugLayers", "(", "node", ",", "tree", ")", "{", "for", "(", "let", "layer", "in", "node", ")", "{", "let", "counts", "=", "node", "[", "layer", "]", ";", "addLayerDebugEntry", "(", "tree", ",", "layer", ",", "counts", ".", "features",...
build debug stats layer tree
[ "build", "debug", "stats", "layer", "tree" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/src/tile/tile.js#L631-L640
train
tangrams/tangram
src/tile/tile_manager.js
meshSetString
function meshSetString (tiles) { return JSON.stringify( Object.entries(tiles).map(([,t]) => { return Object.entries(t.meshes).map(([,s]) => { return s.map(m => m.created_at); }); }) ); }
javascript
function meshSetString (tiles) { return JSON.stringify( Object.entries(tiles).map(([,t]) => { return Object.entries(t.meshes).map(([,s]) => { return s.map(m => m.created_at); }); }) ); }
[ "function", "meshSetString", "(", "tiles", ")", "{", "return", "JSON", ".", "stringify", "(", "Object", ".", "entries", "(", "tiles", ")", ".", "map", "(", "(", "[", ",", "t", "]", ")", "=>", "{", "return", "Object", ".", "entries", "(", "t", ".", ...
Create a string representing the current set of meshes for a given set of tiles, based on their created timestamp. Used to determine when tiles should be re-collided.
[ "Create", "a", "string", "representing", "the", "current", "set", "of", "meshes", "for", "a", "given", "set", "of", "tiles", "based", "on", "their", "created", "timestamp", ".", "Used", "to", "determine", "when", "tiles", "should", "be", "re", "-", "collid...
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/src/tile/tile_manager.js#L462-L470
train
tangrams/tangram
src/sources/geojson.js
getCentroidFeatureForPolygon
function getCentroidFeatureForPolygon (coordinates, properties, newProperties) { let centroid = Geo.centroid(coordinates); if (!centroid) { return; } // clone properties and mixix newProperties let centroid_properties = {}; Object.assign(centroid_properties, properties, newProperties); ...
javascript
function getCentroidFeatureForPolygon (coordinates, properties, newProperties) { let centroid = Geo.centroid(coordinates); if (!centroid) { return; } // clone properties and mixix newProperties let centroid_properties = {}; Object.assign(centroid_properties, properties, newProperties); ...
[ "function", "getCentroidFeatureForPolygon", "(", "coordinates", ",", "properties", ",", "newProperties", ")", "{", "let", "centroid", "=", "Geo", ".", "centroid", "(", "coordinates", ")", ";", "if", "(", "!", "centroid", ")", "{", "return", ";", "}", "// clo...
Helper function to create centroid point feature from polygon coordinates and provided feature meta-data
[ "Helper", "function", "to", "create", "centroid", "point", "feature", "from", "polygon", "coordinates", "and", "provided", "feature", "meta", "-", "data" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/src/sources/geojson.js#L255-L273
train
tangrams/tangram
src/scene/scene_loader.js
flattenProperties
function flattenProperties (obj, prefix = null, globals = {}) { prefix = prefix ? (prefix + '.') : 'global.'; for (const p in obj) { const key = prefix + p; const val = obj[p]; globals[key] = val; if (typeof val === 'object' && !Array.isArray(val)) { flattenProperti...
javascript
function flattenProperties (obj, prefix = null, globals = {}) { prefix = prefix ? (prefix + '.') : 'global.'; for (const p in obj) { const key = prefix + p; const val = obj[p]; globals[key] = val; if (typeof val === 'object' && !Array.isArray(val)) { flattenProperti...
[ "function", "flattenProperties", "(", "obj", ",", "prefix", "=", "null", ",", "globals", "=", "{", "}", ")", "{", "prefix", "=", "prefix", "?", "(", "prefix", "+", "'.'", ")", ":", "'global.'", ";", "for", "(", "const", "p", "in", "obj", ")", "{", ...
Flatten nested properties for simpler string look-ups
[ "Flatten", "nested", "properties", "for", "simpler", "string", "look", "-", "ups" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/src/scene/scene_loader.js#L388-L401
train
tangrams/tangram
demos/lib/keymaster.js
compareArray
function compareArray(a1, a2) { if (a1.length != a2.length) return false; for (var i = 0; i < a1.length; i++) { if (a1[i] !== a2[i]) return false; } return true; }
javascript
function compareArray(a1, a2) { if (a1.length != a2.length) return false; for (var i = 0; i < a1.length; i++) { if (a1[i] !== a2[i]) return false; } return true; }
[ "function", "compareArray", "(", "a1", ",", "a2", ")", "{", "if", "(", "a1", ".", "length", "!=", "a2", ".", "length", ")", "return", "false", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "a1", ".", "length", ";", "i", "++", ")", "{"...
for comparing mods before unassignment
[ "for", "comparing", "mods", "before", "unassignment" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/demos/lib/keymaster.js#L47-L53
train
tangrams/tangram
demos/lib/keymaster.js
unbindKey
function unbindKey(key, scope) { var multipleKeys, keys, mods = [], i, j, obj; multipleKeys = getKeys(key); for (j = 0; j < multipleKeys.length; j++) { keys = multipleKeys[j].split('+'); if (keys.length > 1) { mods = getMods(keys); key = keys[keys.length - 1]; ...
javascript
function unbindKey(key, scope) { var multipleKeys, keys, mods = [], i, j, obj; multipleKeys = getKeys(key); for (j = 0; j < multipleKeys.length; j++) { keys = multipleKeys[j].split('+'); if (keys.length > 1) { mods = getMods(keys); key = keys[keys.length - 1]; ...
[ "function", "unbindKey", "(", "key", ",", "scope", ")", "{", "var", "multipleKeys", ",", "keys", ",", "mods", "=", "[", "]", ",", "i", ",", "j", ",", "obj", ";", "multipleKeys", "=", "getKeys", "(", "key", ")", ";", "for", "(", "j", "=", "0", "...
unbind all handlers for given key in current scope
[ "unbind", "all", "handlers", "for", "given", "key", "in", "current", "scope" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/demos/lib/keymaster.js#L167-L198
train
tangrams/tangram
demos/lib/keymaster.js
deleteScope
function deleteScope(scope){ var key, handlers, i; for (key in _handlers) { handlers = _handlers[key]; for (i = 0; i < handlers.length; ) { if (handlers[i].scope === scope) handlers.splice(i, 1); else i++; } } }
javascript
function deleteScope(scope){ var key, handlers, i; for (key in _handlers) { handlers = _handlers[key]; for (i = 0; i < handlers.length; ) { if (handlers[i].scope === scope) handlers.splice(i, 1); else i++; } } }
[ "function", "deleteScope", "(", "scope", ")", "{", "var", "key", ",", "handlers", ",", "i", ";", "for", "(", "key", "in", "_handlers", ")", "{", "handlers", "=", "_handlers", "[", "key", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "handle...
delete all handlers for a given scope
[ "delete", "all", "handlers", "for", "a", "given", "scope" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/demos/lib/keymaster.js#L227-L237
train
tangrams/tangram
demos/lib/keymaster.js
getKeys
function getKeys(key) { var keys; key = key.replace(/\s/g, ''); keys = key.split(','); if ((keys[keys.length - 1]) == '') { keys[keys.length - 2] += ','; } return keys; }
javascript
function getKeys(key) { var keys; key = key.replace(/\s/g, ''); keys = key.split(','); if ((keys[keys.length - 1]) == '') { keys[keys.length - 2] += ','; } return keys; }
[ "function", "getKeys", "(", "key", ")", "{", "var", "keys", ";", "key", "=", "key", ".", "replace", "(", "/", "\\s", "/", "g", ",", "''", ")", ";", "keys", "=", "key", ".", "split", "(", "','", ")", ";", "if", "(", "(", "keys", "[", "keys", ...
abstract key logic for assign and unassign
[ "abstract", "key", "logic", "for", "assign", "and", "unassign" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/demos/lib/keymaster.js#L240-L248
train
tangrams/tangram
demos/lib/keymaster.js
getMods
function getMods(key) { var mods = key.slice(0, key.length - 1); for (var mi = 0; mi < mods.length; mi++) mods[mi] = _MODIFIERS[mods[mi]]; return mods; }
javascript
function getMods(key) { var mods = key.slice(0, key.length - 1); for (var mi = 0; mi < mods.length; mi++) mods[mi] = _MODIFIERS[mods[mi]]; return mods; }
[ "function", "getMods", "(", "key", ")", "{", "var", "mods", "=", "key", ".", "slice", "(", "0", ",", "key", ".", "length", "-", "1", ")", ";", "for", "(", "var", "mi", "=", "0", ";", "mi", "<", "mods", ".", "length", ";", "mi", "++", ")", "...
abstract mods logic for assign and unassign
[ "abstract", "mods", "logic", "for", "assign", "and", "unassign" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/demos/lib/keymaster.js#L251-L256
train
tangrams/tangram
src/utils/worker_broker.js
freeTransferables
function freeTransferables(transferables) { if (!Array.isArray(transferables)) { return; } transferables.filter(t => t.parent && t.property).forEach(t => delete t.parent[t.property]); }
javascript
function freeTransferables(transferables) { if (!Array.isArray(transferables)) { return; } transferables.filter(t => t.parent && t.property).forEach(t => delete t.parent[t.property]); }
[ "function", "freeTransferables", "(", "transferables", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "transferables", ")", ")", "{", "return", ";", "}", "transferables", ".", "filter", "(", "t", "=>", "t", ".", "parent", "&&", "t", ".", "prop...
Remove neutered transferables from parent objects, as they should no longer be accessed after transfer
[ "Remove", "neutered", "transferables", "from", "parent", "objects", "as", "they", "should", "no", "longer", "be", "accessed", "after", "transfer" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/src/utils/worker_broker.js#L500-L505
train
tangrams/tangram
demos/main.js
onHover
function onHover (selection) { var feature = selection.feature; if (feature) { if (selection.changed) { var info; if (scene.introspection) { info = getFeaturePropsHTML(feature); } else { v...
javascript
function onHover (selection) { var feature = selection.feature; if (feature) { if (selection.changed) { var info; if (scene.introspection) { info = getFeaturePropsHTML(feature); } else { v...
[ "function", "onHover", "(", "selection", ")", "{", "var", "feature", "=", "selection", ".", "feature", ";", "if", "(", "feature", ")", "{", "if", "(", "selection", ".", "changed", ")", "{", "var", "info", ";", "if", "(", "scene", ".", "introspection", ...
close tooltip when zooming
[ "close", "tooltip", "when", "zooming" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/demos/main.js#L82-L108
train
tangrams/tangram
demos/main.js
getFeaturePropsHTML
function getFeaturePropsHTML (feature) { var props = ['name', 'kind', 'kind_detail', 'id']; // show these properties first if available Object.keys(feature.properties) // show rest of proeprties alphabetized .sort() .forEach(function(p) { if (props.indexOf(p) === ...
javascript
function getFeaturePropsHTML (feature) { var props = ['name', 'kind', 'kind_detail', 'id']; // show these properties first if available Object.keys(feature.properties) // show rest of proeprties alphabetized .sort() .forEach(function(p) { if (props.indexOf(p) === ...
[ "function", "getFeaturePropsHTML", "(", "feature", ")", "{", "var", "props", "=", "[", "'name'", ",", "'kind'", ",", "'kind_detail'", ",", "'id'", "]", ";", "// show these properties first if available", "Object", ".", "keys", "(", "feature", ".", "properties", ...
Get an HTML fragment with feature properties
[ "Get", "an", "HTML", "fragment", "with", "feature", "properties" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/demos/main.js#L136-L157
train
tangrams/tangram
src/builders/polylines.js
getNextNonBoundarySegment
function getNextNonBoundarySegment (line, startIndex, tolerance) { var endIndex = startIndex; while (line[endIndex + 1] && outsideTile(line[endIndex], line[endIndex + 1], tolerance)) { endIndex++; } // If there is a line segment remaining that is within the tile, push it to the lines array ...
javascript
function getNextNonBoundarySegment (line, startIndex, tolerance) { var endIndex = startIndex; while (line[endIndex + 1] && outsideTile(line[endIndex], line[endIndex + 1], tolerance)) { endIndex++; } // If there is a line segment remaining that is within the tile, push it to the lines array ...
[ "function", "getNextNonBoundarySegment", "(", "line", ",", "startIndex", ",", "tolerance", ")", "{", "var", "endIndex", "=", "startIndex", ";", "while", "(", "line", "[", "endIndex", "+", "1", "]", "&&", "outsideTile", "(", "line", "[", "endIndex", "]", ",...
Iterate through line from startIndex to find a segment not on a tile boundary, if any.
[ "Iterate", "through", "line", "from", "startIndex", "to", "find", "a", "segment", "not", "on", "a", "tile", "boundary", "if", "any", "." ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/src/builders/polylines.js#L264-L272
train
tangrams/tangram
src/builders/polylines.js
endPolygon
function endPolygon(coordCurr, normPrev, normNext, join_type, v, context) { // If polygon ends on a tile boundary, don't add a join if (isCoordOutsideTile(coordCurr)) { addVertex(coordCurr, normPrev, normPrev, 1, v, context, 1); addVertex(coordCurr, normPrev, normPrev, 0, v, context, -1); ...
javascript
function endPolygon(coordCurr, normPrev, normNext, join_type, v, context) { // If polygon ends on a tile boundary, don't add a join if (isCoordOutsideTile(coordCurr)) { addVertex(coordCurr, normPrev, normPrev, 1, v, context, 1); addVertex(coordCurr, normPrev, normPrev, 0, v, context, -1); ...
[ "function", "endPolygon", "(", "coordCurr", ",", "normPrev", ",", "normNext", ",", "join_type", ",", "v", ",", "context", ")", "{", "// If polygon ends on a tile boundary, don't add a join", "if", "(", "isCoordOutsideTile", "(", "coordCurr", ")", ")", "{", "addVerte...
End a polygon appropriately
[ "End", "a", "polygon", "appropriately" ]
e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11
https://github.com/tangrams/tangram/blob/e1368e3784f143cfdbecbf5a0b0fdaa4b430ed11/src/builders/polylines.js#L294-L320
train