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
dcodeIO/MetaScript
MetaScript.js
function(sourceOrProgram, filename) { if (!(this instanceof MetaScript)) { __version = Array.prototype.join.call(arguments, '.'); return; } // Whether constructing from a meta program or, otherwise, a source var isProgram = (sourceOrProgram+="")....
javascript
function(sourceOrProgram, filename) { if (!(this instanceof MetaScript)) { __version = Array.prototype.join.call(arguments, '.'); return; } // Whether constructing from a meta program or, otherwise, a source var isProgram = (sourceOrProgram+="")....
[ "function", "(", "sourceOrProgram", ",", "filename", ")", "{", "if", "(", "!", "(", "this", "instanceof", "MetaScript", ")", ")", "{", "__version", "=", "Array", ".", "prototype", ".", "join", ".", "call", "(", "arguments", ",", "'.'", ")", ";", "retur...
Constructs a new MetaScript instance. @exports MetaScript @param {string} sourceOrProgram Source to compile or meta program to run @param {string=} filename Source file name if known, defaults to `"main"`. @constructor
[ "Constructs", "a", "new", "MetaScript", "instance", "." ]
dc7caf5eae2f2b2467f6c6467203dbcd05f23549
https://github.com/dcodeIO/MetaScript/blob/dc7caf5eae2f2b2467f6c6467203dbcd05f23549/MetaScript.js#L38-L65
train
dcodeIO/MetaScript
MetaScript.js
evaluate
function evaluate(expr) { if (expr.substring(0, 2) === '==') { return 'write(JSON.stringify('+expr.substring(2).trim()+'));\n'; } else if (expr.substring(0, 1) === '=') { return 'write('+expr.substring(1).trim()+');\n'; } else if (expr.substring(0, 3) ...
javascript
function evaluate(expr) { if (expr.substring(0, 2) === '==') { return 'write(JSON.stringify('+expr.substring(2).trim()+'));\n'; } else if (expr.substring(0, 1) === '=') { return 'write('+expr.substring(1).trim()+');\n'; } else if (expr.substring(0, 3) ...
[ "function", "evaluate", "(", "expr", ")", "{", "if", "(", "expr", ".", "substring", "(", "0", ",", "2", ")", "===", "'=='", ")", "{", "return", "'write(JSON.stringify('", "+", "expr", ".", "substring", "(", "2", ")", ".", "trim", "(", ")", "+", "')...
Evaluates a meta expression
[ "Evaluates", "a", "meta", "expression" ]
dc7caf5eae2f2b2467f6c6467203dbcd05f23549
https://github.com/dcodeIO/MetaScript/blob/dc7caf5eae2f2b2467f6c6467203dbcd05f23549/MetaScript.js#L103-L115
train
dcodeIO/MetaScript
MetaScript.js
append
function append(source) { if (s === '') return; var index = 0, expr = /\n/g, s, match; while (match = expr.exec(source)) { s = source.substring(index, match.index+1); if (s !== '') out.push(' write(\''+e...
javascript
function append(source) { if (s === '') return; var index = 0, expr = /\n/g, s, match; while (match = expr.exec(source)) { s = source.substring(index, match.index+1); if (s !== '') out.push(' write(\''+e...
[ "function", "append", "(", "source", ")", "{", "if", "(", "s", "===", "''", ")", "return", ";", "var", "index", "=", "0", ",", "expr", "=", "/", "\\n", "/", "g", ",", "s", ",", "match", ";", "while", "(", "match", "=", "expr", ".", "exec", "(...
Appends additional content to the program, if not empty
[ "Appends", "additional", "content", "to", "the", "program", "if", "not", "empty" ]
dc7caf5eae2f2b2467f6c6467203dbcd05f23549
https://github.com/dcodeIO/MetaScript/blob/dc7caf5eae2f2b2467f6c6467203dbcd05f23549/MetaScript.js#L118-L131
train
dcodeIO/MetaScript
MetaScript.js
indent
function indent(str, indent) { if (typeof indent === 'number') { var indent_str = ''; while (indent_str.length < indent) indent_str += ' '; indent = indent_str; } var lines = str.split(/\n/); for (var i=0; i<lines.length; i+...
javascript
function indent(str, indent) { if (typeof indent === 'number') { var indent_str = ''; while (indent_str.length < indent) indent_str += ' '; indent = indent_str; } var lines = str.split(/\n/); for (var i=0; i<lines.length; i+...
[ "function", "indent", "(", "str", ",", "indent", ")", "{", "if", "(", "typeof", "indent", "===", "'number'", ")", "{", "var", "indent_str", "=", "''", ";", "while", "(", "indent_str", ".", "length", "<", "indent", ")", "indent_str", "+=", "' '", ";", ...
Indents a block of text. @function indent @param {string} str Text to indent @param {string|number} indent Whitespace text to use for indentation or the number of whitespaces to use @returns {string} Indented text
[ "Indents", "a", "block", "of", "text", "." ]
dc7caf5eae2f2b2467f6c6467203dbcd05f23549
https://github.com/dcodeIO/MetaScript/blob/dc7caf5eae2f2b2467f6c6467203dbcd05f23549/MetaScript.js#L317-L329
train
dcodeIO/MetaScript
MetaScript.js
include
function include(filename, absolute) { filename = absolute ? filename : __dirname + '/' + filename; var _program = __program, // Previous meta program _source = __source, // Previous source _filename = __filename, // Previous ...
javascript
function include(filename, absolute) { filename = absolute ? filename : __dirname + '/' + filename; var _program = __program, // Previous meta program _source = __source, // Previous source _filename = __filename, // Previous ...
[ "function", "include", "(", "filename", ",", "absolute", ")", "{", "filename", "=", "absolute", "?", "filename", ":", "__dirname", "+", "'/'", "+", "filename", ";", "var", "_program", "=", "__program", ",", "// Previous meta program", "_source", "=", "__source...
Includes another source file. @function include @param {string} filename File to include. May be a glob expression on node.js. @param {boolean} absolute Whether the path is absolute, defaults to `false` for a relative path
[ "Includes", "another", "source", "file", "." ]
dc7caf5eae2f2b2467f6c6467203dbcd05f23549
https://github.com/dcodeIO/MetaScript/blob/dc7caf5eae2f2b2467f6c6467203dbcd05f23549/MetaScript.js#L337-L366
train
dcodeIO/MetaScript
MetaScript.js
escapestr
function escapestr(s) { return s.replace(/\\/g, '\\\\') .replace(/'/g, '\\\'') .replace(/"/g, '\\"') .replace(/\r/g, '\\r') .replace(/\n/g, '\\n'); }
javascript
function escapestr(s) { return s.replace(/\\/g, '\\\\') .replace(/'/g, '\\\'') .replace(/"/g, '\\"') .replace(/\r/g, '\\r') .replace(/\n/g, '\\n'); }
[ "function", "escapestr", "(", "s", ")", "{", "return", "s", ".", "replace", "(", "/", "\\\\", "/", "g", ",", "'\\\\\\\\'", ")", ".", "replace", "(", "/", "'", "/", "g", ",", "'\\\\\\''", ")", ".", "replace", "(", "/", "\"", "/", "g", ",", "'\\\...
Escaoes a string to be used inside of a single or double quote enclosed JavaScript string. @function escapestr @param {string} s String to escape @returns {string} Escaped string
[ "Escaoes", "a", "string", "to", "be", "used", "inside", "of", "a", "single", "or", "double", "quote", "enclosed", "JavaScript", "string", "." ]
dc7caf5eae2f2b2467f6c6467203dbcd05f23549
https://github.com/dcodeIO/MetaScript/blob/dc7caf5eae2f2b2467f6c6467203dbcd05f23549/MetaScript.js#L374-L380
train
dcodeIO/MetaScript
MetaScript.js
__err2code
function __err2code(program, err) { if (typeof err.stack !== 'string') return indent(program, 4); var match = /<anonymous>:(\d+):(\d+)\)/.exec(err.stack); if (!match) { return indent(program, 4); } var line = parseInt(match[1], ...
javascript
function __err2code(program, err) { if (typeof err.stack !== 'string') return indent(program, 4); var match = /<anonymous>:(\d+):(\d+)\)/.exec(err.stack); if (!match) { return indent(program, 4); } var line = parseInt(match[1], ...
[ "function", "__err2code", "(", "program", ",", "err", ")", "{", "if", "(", "typeof", "err", ".", "stack", "!==", "'string'", ")", "return", "indent", "(", "program", ",", "4", ")", ";", "var", "match", "=", "/", "<anonymous>:(\\d+):(\\d+)\\)", "/", ".", ...
Generates a code view of eval'ed code from an Error. @param {string} program Failed program @param {!Error} err Error caught @returns {string} Code view @inner @private
[ "Generates", "a", "code", "view", "of", "eval", "ed", "code", "from", "an", "Error", "." ]
dc7caf5eae2f2b2467f6c6467203dbcd05f23549
https://github.com/dcodeIO/MetaScript/blob/dc7caf5eae2f2b2467f6c6467203dbcd05f23549/MetaScript.js#L408-L428
train
ExpressenAB/exp-amqp-connection
index.js
function(callback) { bootstrap(behaviour, (bootstrapErr, bootstrapRes) => { if (bootstrapErr) api.emit("error", bootstrapErr); if (bootstrapRes && bootstrapRes.virgin) { bootstrapRes.connection.on("error", (err) => api.emit("error", err)); bootstrapRes.connection.on("close", (why) => api...
javascript
function(callback) { bootstrap(behaviour, (bootstrapErr, bootstrapRes) => { if (bootstrapErr) api.emit("error", bootstrapErr); if (bootstrapRes && bootstrapRes.virgin) { bootstrapRes.connection.on("error", (err) => api.emit("error", err)); bootstrapRes.connection.on("close", (why) => api...
[ "function", "(", "callback", ")", "{", "bootstrap", "(", "behaviour", ",", "(", "bootstrapErr", ",", "bootstrapRes", ")", "=>", "{", "if", "(", "bootstrapErr", ")", "api", ".", "emit", "(", "\"error\"", ",", "bootstrapErr", ")", ";", "if", "(", "bootstra...
get connnection and add event listeners if it's brand new.
[ "get", "connnection", "and", "add", "event", "listeners", "if", "it", "s", "brand", "new", "." ]
999240feee6f0861ddd7404b58b3e6600bd36062
https://github.com/ExpressenAB/exp-amqp-connection/blob/999240feee6f0861ddd7404b58b3e6600bd36062/index.js#L35-L48
train
healthsparq/ember-fountainhead
lib/create-dirs.js
mkdirSync
function mkdirSync(dirPath) { // Get relative path to output const relativePath = dirPath.replace(`${CWD}${pathSep}`, ''); const dirs = relativePath.split(pathSep); let currentDir = CWD; // Check if each dir exists, and if not, create it dirs.forEach(dir => { currentDir = path.resolve(curre...
javascript
function mkdirSync(dirPath) { // Get relative path to output const relativePath = dirPath.replace(`${CWD}${pathSep}`, ''); const dirs = relativePath.split(pathSep); let currentDir = CWD; // Check if each dir exists, and if not, create it dirs.forEach(dir => { currentDir = path.resolve(curre...
[ "function", "mkdirSync", "(", "dirPath", ")", "{", "// Get relative path to output", "const", "relativePath", "=", "dirPath", ".", "replace", "(", "`", "${", "CWD", "}", "${", "pathSep", "}", "`", ",", "''", ")", ";", "const", "dirs", "=", "relativePath", ...
Synchronous mkdir that handles creating a potentially nested directory @method mkdirSync @param {string} dirPath Directory path to create, can be nested @return {undefined}
[ "Synchronous", "mkdir", "that", "handles", "creating", "a", "potentially", "nested", "directory" ]
3577546719b251385ca1093f812889590459205a
https://github.com/healthsparq/ember-fountainhead/blob/3577546719b251385ca1093f812889590459205a/lib/create-dirs.js#L26-L39
train
mia-js/mia-js-core
lib/baseModel/lib/baseModel.js
function (values, options, callback) { var deferred = Q.defer(); var args = ArgumentHelpers.prepareArguments(options, callback) , wrapper = {}; options = args.options; callback = Qext.makeNodeResolver(deferred, args.callback); ...
javascript
function (values, options, callback) { var deferred = Q.defer(); var args = ArgumentHelpers.prepareArguments(options, callback) , wrapper = {}; options = args.options; callback = Qext.makeNodeResolver(deferred, args.callback); ...
[ "function", "(", "values", ",", "options", ",", "callback", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "var", "args", "=", "ArgumentHelpers", ".", "prepareArguments", "(", "options", ",", "callback", ")", ",", "wrapper", "=", "...
Validates provided 'values' against this model. @param values @param callback
[ "Validates", "provided", "values", "against", "this", "model", "." ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/baseModel/lib/baseModel.js#L202-L265
train
mia-js/mia-js-core
lib/baseModel/lib/baseModel.js
function (callback) { var self = this; var deferred = Q.defer(); callback = Qext.makeNodeResolver(deferred, callback); var breakExec = {}; Async.waterfall([ function (next) { if (!self.collectio...
javascript
function (callback) { var self = this; var deferred = Q.defer(); callback = Qext.makeNodeResolver(deferred, callback); var breakExec = {}; Async.waterfall([ function (next) { if (!self.collectio...
[ "function", "(", "callback", ")", "{", "var", "self", "=", "this", ";", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "callback", "=", "Qext", ".", "makeNodeResolver", "(", "deferred", ",", "callback", ")", ";", "var", "breakExec", "=", "...
Gets the collection of this model. Collection is specified in the 'collectionName' property of the model.
[ "Gets", "the", "collection", "of", "this", "model", ".", "Collection", "is", "specified", "in", "the", "collectionName", "property", "of", "the", "model", "." ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/baseModel/lib/baseModel.js#L286-L381
train
mia-js/mia-js-core
lib/baseModel/lib/baseModel.js
function (arguments) { var argData = ArgumentHelpers.prepareCallback(arguments); var callback = argData.callback; var args = argData.arguments; if (callback) { args.pop(); } return args; }
javascript
function (arguments) { var argData = ArgumentHelpers.prepareCallback(arguments); var callback = argData.callback; var args = argData.arguments; if (callback) { args.pop(); } return args; }
[ "function", "(", "arguments", ")", "{", "var", "argData", "=", "ArgumentHelpers", ".", "prepareCallback", "(", "arguments", ")", ";", "var", "callback", "=", "argData", ".", "callback", ";", "var", "args", "=", "argData", ".", "arguments", ";", "if", "(", ...
Removes callback function from arguments and returns the arguments @param {Object} arguments @returns {Array} @private
[ "Removes", "callback", "function", "from", "arguments", "and", "returns", "the", "arguments" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/baseModel/lib/baseModel.js#L389-L397
train
mia-js/mia-js-core
lib/baseModel/lib/baseModel.js
function (functionName, arguments) { var self = this; var args = self._getArgs(arguments); var callback = self._getCallback(arguments); return self._generic(functionName, args) .nodeify(callback); }
javascript
function (functionName, arguments) { var self = this; var args = self._getArgs(arguments); var callback = self._getCallback(arguments); return self._generic(functionName, args) .nodeify(callback); }
[ "function", "(", "functionName", ",", "arguments", ")", "{", "var", "self", "=", "this", ";", "var", "args", "=", "self", ".", "_getArgs", "(", "arguments", ")", ";", "var", "callback", "=", "self", ".", "_getCallback", "(", "arguments", ")", ";", "ret...
Calls generic driver functions @param {String} functionName @param {Object} arguments @returns {*} @private
[ "Calls", "generic", "driver", "functions" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/baseModel/lib/baseModel.js#L417-L424
train
mia-js/mia-js-core
lib/baseModel/lib/baseModel.js
function (args) { var shardKey = this.prototype.shardKey; var query = !_.isUndefined(args[0]) ? args[0] : {}; var options = !_.isUndefined(args[1]) ? args[1] : {}; var ignoreShardKey = MemberHelpers.getPathPropertyValue(options, 'ignoreShardKey') ? true : ...
javascript
function (args) { var shardKey = this.prototype.shardKey; var query = !_.isUndefined(args[0]) ? args[0] : {}; var options = !_.isUndefined(args[1]) ? args[1] : {}; var ignoreShardKey = MemberHelpers.getPathPropertyValue(options, 'ignoreShardKey') ? true : ...
[ "function", "(", "args", ")", "{", "var", "shardKey", "=", "this", ".", "prototype", ".", "shardKey", ";", "var", "query", "=", "!", "_", ".", "isUndefined", "(", "args", "[", "0", "]", ")", "?", "args", "[", "0", "]", ":", "{", "}", ";", "var"...
Checks whether there is a shard key and if it is in the query @param {Object} args @returns {*} @private
[ "Checks", "whether", "there", "is", "a", "shard", "key", "and", "if", "it", "is", "in", "the", "query" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/baseModel/lib/baseModel.js#L469-L491
train
jbaicoianu/elation
components/utils/scripts/events.js
function(event) { if (typeof event.touches != 'undefined' && event.touches.length > 0) { var c = { x: event.touches[0].pageX, y: event.touches[0].pageY }; } else { var c = { x: (event.pageX || (event.clientX + document.body.scrollLeft)), y: (event.pageY || (ev...
javascript
function(event) { if (typeof event.touches != 'undefined' && event.touches.length > 0) { var c = { x: event.touches[0].pageX, y: event.touches[0].pageY }; } else { var c = { x: (event.pageX || (event.clientX + document.body.scrollLeft)), y: (event.pageY || (ev...
[ "function", "(", "event", ")", "{", "if", "(", "typeof", "event", ".", "touches", "!=", "'undefined'", "&&", "event", ".", "touches", ".", "length", ">", "0", ")", "{", "var", "c", "=", "{", "x", ":", "event", ".", "touches", "[", "0", "]", ".", ...
returns mouse or all finger touch coords
[ "returns", "mouse", "or", "all", "finger", "touch", "coords" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/scripts/events.js#L397-L411
train
mia-js/mia-js-core
lib/routesHandler/lib/swaggerDocs.js
function (bodySchemaModels, defName) { for (var i in bodySchemaModels) { if (bodySchemaModels[i]["name"] == defName) { return bodySchemaModels[i]; } } return null; }
javascript
function (bodySchemaModels, defName) { for (var i in bodySchemaModels) { if (bodySchemaModels[i]["name"] == defName) { return bodySchemaModels[i]; } } return null; }
[ "function", "(", "bodySchemaModels", ",", "defName", ")", "{", "for", "(", "var", "i", "in", "bodySchemaModels", ")", "{", "if", "(", "bodySchemaModels", "[", "i", "]", "[", "\"name\"", "]", "==", "defName", ")", "{", "return", "bodySchemaModels", "[", "...
Create swagger compatible schema for body parameters @param bodySchemaModels @param obj @param defName @returns {{bodySchemaModels: *, attributes: {}}} @private
[ "Create", "swagger", "compatible", "schema", "for", "body", "parameters" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/routesHandler/lib/swaggerDocs.js#L20-L27
train
mia-js/mia-js-core
lib/modelValidator/lib/modelValidator.js
function (values, schema) { var publicList = find(schema, 'public') , arrElem; for (var value in values) { if (publicList[value]) { if (_.isArray(publicList[value])) { for (var thisArrayElem in publicList[value]) { if (!_.isArray(values[value]))...
javascript
function (values, schema) { var publicList = find(schema, 'public') , arrElem; for (var value in values) { if (publicList[value]) { if (_.isArray(publicList[value])) { for (var thisArrayElem in publicList[value]) { if (!_.isArray(values[value]))...
[ "function", "(", "values", ",", "schema", ")", "{", "var", "publicList", "=", "find", "(", "schema", ",", "'public'", ")", ",", "arrElem", ";", "for", "(", "var", "value", "in", "values", ")", "{", "if", "(", "publicList", "[", "value", "]", ")", "...
Remove values where schema setting public.set false @param values @param schema @returns {*}
[ "Remove", "values", "where", "schema", "setting", "public", ".", "set", "false" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/modelValidator/lib/modelValidator.js#L724-L763
train
mia-js/mia-js-core
lib/modelValidator/lib/modelValidator.js
function (values, schema, options) { var virtualList = find(schema, 'virtual'); //Set default value for virtual if not exists in values if (options && options.query === true) { } else { for (var virtual in virtualList) { if (_.isArray(virtualList[virtual])) { f...
javascript
function (values, schema, options) { var virtualList = find(schema, 'virtual'); //Set default value for virtual if not exists in values if (options && options.query === true) { } else { for (var virtual in virtualList) { if (_.isArray(virtualList[virtual])) { f...
[ "function", "(", "values", ",", "schema", ",", "options", ")", "{", "var", "virtualList", "=", "find", "(", "schema", ",", "'virtual'", ")", ";", "//Set default value for virtual if not exists in values", "if", "(", "options", "&&", "options", ".", "query", "===...
Apply virtual functions defined in schema @param values @param model @param options @returns {*}
[ "Apply", "virtual", "functions", "defined", "in", "schema" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/modelValidator/lib/modelValidator.js#L772-L840
train
mia-js/mia-js-core
lib/modelValidator/lib/modelValidator.js
function (model, filter, value) { if (!_.isString(filter)) { return null; } if (model.data) { var list = findKeys(model.data, filter) , values = []; for (var res in list) { if (value === undefined || list[res][filter] === value) { values.pu...
javascript
function (model, filter, value) { if (!_.isString(filter)) { return null; } if (model.data) { var list = findKeys(model.data, filter) , values = []; for (var res in list) { if (value === undefined || list[res][filter] === value) { values.pu...
[ "function", "(", "model", ",", "filter", ",", "value", ")", "{", "if", "(", "!", "_", ".", "isString", "(", "filter", ")", ")", "{", "return", "null", ";", "}", "if", "(", "model", ".", "data", ")", "{", "var", "list", "=", "findKeys", "(", "mo...
Finds all nodes with filter property in given model and returns array list of nodes @param model @param filter @returns {*}
[ "Finds", "all", "nodes", "with", "filter", "property", "in", "given", "model", "and", "returns", "array", "list", "of", "nodes" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/modelValidator/lib/modelValidator.js#L977-L997
train
mia-js/mia-js-core
lib/modelValidator/lib/modelValidator.js
function (schema) { var extendList = find(schema, 'extend'); for (var extendElem in extendList) { if (extendList[extendElem] && extendList[extendElem].extend && _.isFunction(extendList[extendElem].extend)) { schema[extendElem] = extendList[extendElem].extend(); } } return sc...
javascript
function (schema) { var extendList = find(schema, 'extend'); for (var extendElem in extendList) { if (extendList[extendElem] && extendList[extendElem].extend && _.isFunction(extendList[extendElem].extend)) { schema[extendElem] = extendList[extendElem].extend(); } } return sc...
[ "function", "(", "schema", ")", "{", "var", "extendList", "=", "find", "(", "schema", ",", "'extend'", ")", ";", "for", "(", "var", "extendElem", "in", "extendList", ")", "{", "if", "(", "extendList", "[", "extendElem", "]", "&&", "extendList", "[", "e...
Extend schema by dynamic functions. Write a function that defined the schema settings for a node @param schema @returns {*}
[ "Extend", "schema", "by", "dynamic", "functions", ".", "Write", "a", "function", "that", "defined", "the", "schema", "settings", "for", "a", "node" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/modelValidator/lib/modelValidator.js#L1004-L1013
train
jonschlinkert/plasma
index.js
name
function name(fp, options) { var opts = options || {}; if (typeof opts.namespace === 'function') { return opts.namespace(fp, opts); } if (typeof opts.namespace === false) { return fp; } var ext = path.extname(fp); return path.basename(fp, ext); }
javascript
function name(fp, options) { var opts = options || {}; if (typeof opts.namespace === 'function') { return opts.namespace(fp, opts); } if (typeof opts.namespace === false) { return fp; } var ext = path.extname(fp); return path.basename(fp, ext); }
[ "function", "name", "(", "fp", ",", "options", ")", "{", "var", "opts", "=", "options", "||", "{", "}", ";", "if", "(", "typeof", "opts", ".", "namespace", "===", "'function'", ")", "{", "return", "opts", ".", "namespace", "(", "fp", ",", "opts", "...
Default `namespace` function. Pass a function on `options.namespace` to customize. @param {String} `fp` @param {Object} `opts` @return {String} @api private
[ "Default", "namespace", "function", ".", "Pass", "a", "function", "on", "options", ".", "namespace", "to", "customize", "." ]
573027b52817ceb2f1295779bc2b3bceefa74d11
https://github.com/jonschlinkert/plasma/blob/573027b52817ceb2f1295779bc2b3bceefa74d11/index.js#L229-L239
train
jonschlinkert/plasma
index.js
read
function read(fp, opts) { if (opts && opts.read) { return opts.read(fp, opts); } return readData.call(this, fp, opts); }
javascript
function read(fp, opts) { if (opts && opts.read) { return opts.read(fp, opts); } return readData.call(this, fp, opts); }
[ "function", "read", "(", "fp", ",", "opts", ")", "{", "if", "(", "opts", "&&", "opts", ".", "read", ")", "{", "return", "opts", ".", "read", "(", "fp", ",", "opts", ")", ";", "}", "return", "readData", ".", "call", "(", "this", ",", "fp", ",", ...
Default `read` function. Pass a function on `options.read` to customize. @param {String} `fp` @param {Object} `opts` @return {String} @api private
[ "Default", "read", "function", ".", "Pass", "a", "function", "on", "options", ".", "read", "to", "customize", "." ]
573027b52817ceb2f1295779bc2b3bceefa74d11
https://github.com/jonschlinkert/plasma/blob/573027b52817ceb2f1295779bc2b3bceefa74d11/index.js#L251-L256
train
jonschlinkert/plasma
index.js
readData
function readData(fp, options) { // shallow clone options var opts = utils.extend({}, options); // get the loader for this file. var ext = opts.lang || path.extname(fp); if (ext && ext.charAt(0) !== '.') { ext = '.' + ext; } if (!this.dataLoaders.hasOwnProperty(ext)) { return this.dataLoader('read...
javascript
function readData(fp, options) { // shallow clone options var opts = utils.extend({}, options); // get the loader for this file. var ext = opts.lang || path.extname(fp); if (ext && ext.charAt(0) !== '.') { ext = '.' + ext; } if (!this.dataLoaders.hasOwnProperty(ext)) { return this.dataLoader('read...
[ "function", "readData", "(", "fp", ",", "options", ")", "{", "// shallow clone options", "var", "opts", "=", "utils", ".", "extend", "(", "{", "}", ",", "options", ")", ";", "// get the loader for this file.", "var", "ext", "=", "opts", ".", "lang", "||", ...
Utility for reading data files. @param {String} `fp` Filepath to read. @param {Object} `options` Options to pass to [js-yaml] @api private
[ "Utility", "for", "reading", "data", "files", "." ]
573027b52817ceb2f1295779bc2b3bceefa74d11
https://github.com/jonschlinkert/plasma/blob/573027b52817ceb2f1295779bc2b3bceefa74d11/index.js#L266-L278
train
jbaicoianu/elation
components/utils/scripts/ajaxlib.js
function() { if (common.inlinescripts.length > 0) { var script_text = ''; for (var i = 0; i < common.inlinescripts.length; i++) { if (!common.inlinescripts[i] || typeof common.inlinescripts[i] == 'undefined') continue; else script_text += common.inlines...
javascript
function() { if (common.inlinescripts.length > 0) { var script_text = ''; for (var i = 0; i < common.inlinescripts.length; i++) { if (!common.inlinescripts[i] || typeof common.inlinescripts[i] == 'undefined') continue; else script_text += common.inlines...
[ "function", "(", ")", "{", "if", "(", "common", ".", "inlinescripts", ".", "length", ">", "0", ")", "{", "var", "script_text", "=", "''", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "common", ".", "inlinescripts", ".", "length", ";", "i...
Execute all inline scripts
[ "Execute", "all", "inline", "scripts" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/scripts/ajaxlib.js#L229-L244
train
healthsparq/ember-fountainhead
lib/generate-fountainhead-data.js
saveObjectToJSON
function saveObjectToJSON(filePath, data) { try { data = JSON.stringify(data, null, 2); writeFileSync(filePath, data, { encoding: 'utf8' }); return true; } catch(ex) { console.warn('Unable to save class JSON'); return false; } // NOTE: ASYNC REQUIRES PROMISIFYING ALL OPERA...
javascript
function saveObjectToJSON(filePath, data) { try { data = JSON.stringify(data, null, 2); writeFileSync(filePath, data, { encoding: 'utf8' }); return true; } catch(ex) { console.warn('Unable to save class JSON'); return false; } // NOTE: ASYNC REQUIRES PROMISIFYING ALL OPERA...
[ "function", "saveObjectToJSON", "(", "filePath", ",", "data", ")", "{", "try", "{", "data", "=", "JSON", ".", "stringify", "(", "data", ",", "null", ",", "2", ")", ";", "writeFileSync", "(", "filePath", ",", "data", ",", "{", "encoding", ":", "'utf8'",...
Call to handle saving data to a file. Requires a file path and data to save. If data is not a string, it will be stringified @method saveObjectToJSON @param {string} filePath Path to save file at @param {Object|string} data Data to save in file @return {boolean} True for successful operation, false for failu...
[ "Call", "to", "handle", "saving", "data", "to", "a", "file", ".", "Requires", "a", "file", "path", "and", "data", "to", "save", ".", "If", "data", "is", "not", "a", "string", "it", "will", "be", "stringified" ]
3577546719b251385ca1093f812889590459205a
https://github.com/healthsparq/ember-fountainhead/blob/3577546719b251385ca1093f812889590459205a/lib/generate-fountainhead-data.js#L58-L72
train
kuzzleio/kuzzle-common-objects
lib/utils/assertType.js
assertObject
function assertObject(attr, data) { if (data === null || data === undefined) { return null; } if (typeof data !== 'object' || Array.isArray(data)) { throw new ParseError(`Attribute ${attr} must be of type "object"`); } return data; }
javascript
function assertObject(attr, data) { if (data === null || data === undefined) { return null; } if (typeof data !== 'object' || Array.isArray(data)) { throw new ParseError(`Attribute ${attr} must be of type "object"`); } return data; }
[ "function", "assertObject", "(", "attr", ",", "data", ")", "{", "if", "(", "data", "===", "null", "||", "data", "===", "undefined", ")", "{", "return", "null", ";", "}", "if", "(", "typeof", "data", "!==", "'object'", "||", "Array", ".", "isArray", "...
Throws if the provided data is not an object. Returns the unmodified data if validated @throws @param {string} attr - tested attribute name @param {*} data @return {object}
[ "Throws", "if", "the", "provided", "data", "is", "not", "an", "object", ".", "Returns", "the", "unmodified", "data", "if", "validated" ]
7a7bac8245d9a34ea14c8e7326e95a1f13b9acc2
https://github.com/kuzzleio/kuzzle-common-objects/blob/7a7bac8245d9a34ea14c8e7326e95a1f13b9acc2/lib/utils/assertType.js#L14-L24
train
kuzzleio/kuzzle-common-objects
lib/utils/assertType.js
assertArray
function assertArray(attr, data, type) { if (data === null || data === undefined) { return []; } if (!Array.isArray(data)) { throw new ParseError(`Attribute ${attr} must be of type "array"`); } const clone = []; for (const d of data) { if (d !== undefined && d !== null) { if (typeof d !...
javascript
function assertArray(attr, data, type) { if (data === null || data === undefined) { return []; } if (!Array.isArray(data)) { throw new ParseError(`Attribute ${attr} must be of type "array"`); } const clone = []; for (const d of data) { if (d !== undefined && d !== null) { if (typeof d !...
[ "function", "assertArray", "(", "attr", ",", "data", ",", "type", ")", "{", "if", "(", "data", "===", "null", "||", "data", "===", "undefined", ")", "{", "return", "[", "]", ";", "}", "if", "(", "!", "Array", ".", "isArray", "(", "data", ")", ")"...
Throws if the provided data is not an array containing exclusively values of the specified "type" Returns a clone of the provided array if valid @throws @param {string} attr - tested attribute name @param {*} data @return {array}
[ "Throws", "if", "the", "provided", "data", "is", "not", "an", "array", "containing", "exclusively", "values", "of", "the", "specified", "type", "Returns", "a", "clone", "of", "the", "provided", "array", "if", "valid" ]
7a7bac8245d9a34ea14c8e7326e95a1f13b9acc2
https://github.com/kuzzleio/kuzzle-common-objects/blob/7a7bac8245d9a34ea14c8e7326e95a1f13b9acc2/lib/utils/assertType.js#L36-L58
train
kuzzleio/kuzzle-common-objects
lib/utils/assertType.js
assertUniTypeObject
function assertUniTypeObject(attr, data, type) { data = assertObject(attr, data); if (data === null) { return null; } Object.keys(data).forEach(key => { if (type === undefined) { type = typeof data[key]; } type = type.toLowerCase(); let msg = `Attribute ${attr} must be of type "obje...
javascript
function assertUniTypeObject(attr, data, type) { data = assertObject(attr, data); if (data === null) { return null; } Object.keys(data).forEach(key => { if (type === undefined) { type = typeof data[key]; } type = type.toLowerCase(); let msg = `Attribute ${attr} must be of type "obje...
[ "function", "assertUniTypeObject", "(", "attr", ",", "data", ",", "type", ")", "{", "data", "=", "assertObject", "(", "attr", ",", "data", ")", ";", "if", "(", "data", "===", "null", ")", "{", "return", "null", ";", "}", "Object", ".", "keys", "(", ...
Throws if the provided object is not an object or if it contains heterogeaous typed properties. Returns the unmodified data if validated. @throws {ParseError} @param {string} attr - tested attribute name @param {*} data @param {string} [type] - expected type for data properties @returns {object|null}
[ "Throws", "if", "the", "provided", "object", "is", "not", "an", "object", "or", "if", "it", "contains", "heterogeaous", "typed", "properties", ".", "Returns", "the", "unmodified", "data", "if", "validated", "." ]
7a7bac8245d9a34ea14c8e7326e95a1f13b9acc2
https://github.com/kuzzleio/kuzzle-common-objects/blob/7a7bac8245d9a34ea14c8e7326e95a1f13b9acc2/lib/utils/assertType.js#L70-L102
train
kuzzleio/kuzzle-common-objects
lib/utils/assertType.js
assertString
function assertString(attr, data) { if (data === null || data === undefined) { return null; } if (typeof data !== 'string') { throw new ParseError(`Attribute ${attr} must be of type "string"`); } return data; }
javascript
function assertString(attr, data) { if (data === null || data === undefined) { return null; } if (typeof data !== 'string') { throw new ParseError(`Attribute ${attr} must be of type "string"`); } return data; }
[ "function", "assertString", "(", "attr", ",", "data", ")", "{", "if", "(", "data", "===", "null", "||", "data", "===", "undefined", ")", "{", "return", "null", ";", "}", "if", "(", "typeof", "data", "!==", "'string'", ")", "{", "throw", "new", "Parse...
Throws if the provided data is not a string Returns the unmodified data if validated @throws @param {string} attr - tested attribute name @param {*} data @return {null|string}
[ "Throws", "if", "the", "provided", "data", "is", "not", "a", "string", "Returns", "the", "unmodified", "data", "if", "validated" ]
7a7bac8245d9a34ea14c8e7326e95a1f13b9acc2
https://github.com/kuzzleio/kuzzle-common-objects/blob/7a7bac8245d9a34ea14c8e7326e95a1f13b9acc2/lib/utils/assertType.js#L114-L124
train
mia-js/mia-js-core
lib/routesHandler/lib/preconditionsCheck.js
function (values, model, type) { var deferred = Q.defer(); var modelData = {data: model}; ModelValidator.validate(values, modelData, function (err, data) { deferred.resolve({data: data, err: err, type: type}); }); return deferred.promise; }
javascript
function (values, model, type) { var deferred = Q.defer(); var modelData = {data: model}; ModelValidator.validate(values, modelData, function (err, data) { deferred.resolve({data: data, err: err, type: type}); }); return deferred.promise; }
[ "function", "(", "values", ",", "model", ",", "type", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "var", "modelData", "=", "{", "data", ":", "model", "}", ";", "ModelValidator", ".", "validate", "(", "values", ",", "modelData"...
Validate given values using given model @param values @param model @param type @returns {*} @private
[ "Validate", "given", "values", "using", "given", "model" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/routesHandler/lib/preconditionsCheck.js#L82-L90
train
mia-js/mia-js-core
lib/routesHandler/lib/preconditionsCheck.js
function (req, controller) { var parameters = []; if (controller.conditions && controller.conditions.parameters && controller.conditions.parameters.header) { parameters.push(_checkValues(req.headers, controller.conditions.parameters.header, "header")) } if (controller.condit...
javascript
function (req, controller) { var parameters = []; if (controller.conditions && controller.conditions.parameters && controller.conditions.parameters.header) { parameters.push(_checkValues(req.headers, controller.conditions.parameters.header, "header")) } if (controller.condit...
[ "function", "(", "req", ",", "controller", ")", "{", "var", "parameters", "=", "[", "]", ";", "if", "(", "controller", ".", "conditions", "&&", "controller", ".", "conditions", ".", "parameters", "&&", "controller", ".", "conditions", ".", "parameters", "....
Parse parameter model of controller and validate all request parameters for header,query and body @param req @param controller @returns {*} @private
[ "Parse", "parameter", "model", "of", "controller", "and", "validate", "all", "request", "parameters", "for", "header", "query", "and", "body" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/routesHandler/lib/preconditionsCheck.js#L99-L149
train
mia-js/mia-js-core
lib/routesHandler/lib/preconditionsCheck.js
function (req, res, next) { var hostId = req.miajs.route.hostId; var url = req.miajs.route.url; var prefix = req.miajs.route.prefix; var method = req.miajs.route.method; var group = req.miajs.route.group; var version = req.miajs.route.version; var registeredServic...
javascript
function (req, res, next) { var hostId = req.miajs.route.hostId; var url = req.miajs.route.url; var prefix = req.miajs.route.prefix; var method = req.miajs.route.method; var group = req.miajs.route.group; var version = req.miajs.route.version; var registeredServic...
[ "function", "(", "req", ",", "res", ",", "next", ")", "{", "var", "hostId", "=", "req", ".", "miajs", ".", "route", ".", "hostId", ";", "var", "url", "=", "req", ".", "miajs", ".", "route", ".", "url", ";", "var", "prefix", "=", "req", ".", "mi...
Apply all preconditions defined in all controllers of this route. Try to find preconditions in registeredServices matching url, prefix, method, group and version @param req @param res @param next
[ "Apply", "all", "preconditions", "defined", "in", "all", "controllers", "of", "this", "route", ".", "Try", "to", "find", "preconditions", "in", "registeredServices", "matching", "url", "prefix", "method", "group", "and", "version" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/routesHandler/lib/preconditionsCheck.js#L158-L245
train
mia-js/mia-js-core
lib/mia-js.js
function () { Shared.initialize('/config', process.argv[2]); Shared.setAppHttp(appHttp); Shared.setAppHttps(appHttps); Shared.setExpress(express); // Init memcached var memcached = Shared.memcached(); // Init redis cache var redis = Shared.redis(true); ...
javascript
function () { Shared.initialize('/config', process.argv[2]); Shared.setAppHttp(appHttp); Shared.setAppHttps(appHttps); Shared.setExpress(express); // Init memcached var memcached = Shared.memcached(); // Init redis cache var redis = Shared.redis(true); ...
[ "function", "(", ")", "{", "Shared", ".", "initialize", "(", "'/config'", ",", "process", ".", "argv", "[", "2", "]", ")", ";", "Shared", ".", "setAppHttp", "(", "appHttp", ")", ";", "Shared", ".", "setAppHttps", "(", "appHttps", ")", ";", "Shared", ...
Set initialize functions @returns {*} @private
[ "Set", "initialize", "functions" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/mia-js.js#L52-L95
train
mia-js/mia-js-core
lib/mia-js.js
function (initFunction) { if (_.isFunction(initFunction)) { Logger.info("Run init function"); _customInitFuncton = initFunction; return initFunction(appHttp) .then(function () { return initFunction(appHttps); }); } ...
javascript
function (initFunction) { if (_.isFunction(initFunction)) { Logger.info("Run init function"); _customInitFuncton = initFunction; return initFunction(appHttp) .then(function () { return initFunction(appHttps); }); } ...
[ "function", "(", "initFunction", ")", "{", "if", "(", "_", ".", "isFunction", "(", "initFunction", ")", ")", "{", "Logger", ".", "info", "(", "\"Run init function\"", ")", ";", "_customInitFuncton", "=", "initFunction", ";", "return", "initFunction", "(", "a...
Call and set custom init function to global @param initFunction @returns {*} @private
[ "Call", "and", "set", "custom", "init", "function", "to", "global" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/mia-js.js#L110-L120
train
mia-js/mia-js-core
lib/mia-js.js
function () { //set logger if (!module.parent) { appHttp.use(morgan({format: 'dev'})); appHttps.use(morgan({format: 'dev'})); } return Q(); }
javascript
function () { //set logger if (!module.parent) { appHttp.use(morgan({format: 'dev'})); appHttps.use(morgan({format: 'dev'})); } return Q(); }
[ "function", "(", ")", "{", "//set logger", "if", "(", "!", "module", ".", "parent", ")", "{", "appHttp", ".", "use", "(", "morgan", "(", "{", "format", ":", "'dev'", "}", ")", ")", ";", "appHttps", ".", "use", "(", "morgan", "(", "{", "format", "...
Set morgan logger @returns {*} @private
[ "Set", "morgan", "logger" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/mia-js.js#L174-L181
train
mia-js/mia-js-core
lib/mia-js.js
function (host, reInit) { if (_.isEmpty(host.id) || !_.isString(host.id)) { throw new Error("Host configuration is invalid. Host id is missing or not a string"); } if (_.isEmpty(host.host)) { throw new Error("Host configuration is invalid. Host is missing"); } ...
javascript
function (host, reInit) { if (_.isEmpty(host.id) || !_.isString(host.id)) { throw new Error("Host configuration is invalid. Host id is missing or not a string"); } if (_.isEmpty(host.host)) { throw new Error("Host configuration is invalid. Host is missing"); } ...
[ "function", "(", "host", ",", "reInit", ")", "{", "if", "(", "_", ".", "isEmpty", "(", "host", ".", "id", ")", "||", "!", "_", ".", "isString", "(", "host", ".", "id", ")", ")", "{", "throw", "new", "Error", "(", "\"Host configuration is invalid. Hos...
Parse virtual host definition from mia.js global environment configuration @param {Object} host @param {Boolean} reInit @private
[ "Parse", "virtual", "host", "definition", "from", "mia", ".", "js", "global", "environment", "configuration" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/mia-js.js#L189-L227
train
mia-js/mia-js-core
lib/mia-js.js
function (reInit = false) { //load routes var environment = Shared.config("environment"); var hosts = environment.hosts; if (hosts) { if (!_.isArray(hosts)) { hosts = [hosts]; } for (var host in hosts) { _parseHosts(host...
javascript
function (reInit = false) { //load routes var environment = Shared.config("environment"); var hosts = environment.hosts; if (hosts) { if (!_.isArray(hosts)) { hosts = [hosts]; } for (var host in hosts) { _parseHosts(host...
[ "function", "(", "reInit", "=", "false", ")", "{", "//load routes", "var", "environment", "=", "Shared", ".", "config", "(", "\"environment\"", ")", ";", "var", "hosts", "=", "environment", ".", "hosts", ";", "if", "(", "hosts", ")", "{", "if", "(", "!...
Register all routes defined in routes definition of projects and apply to virtual hosts @param {Boolean} reInit @returns {*} @private
[ "Register", "all", "routes", "defined", "in", "routes", "definition", "of", "projects", "and", "apply", "to", "virtual", "hosts" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/mia-js.js#L245-L266
train
mia-js/mia-js-core
lib/mia-js.js
function () { const cronJobsToStart = _getNamesOfCronJobsToStart(); if (!cronJobsToStart && _shouldStartCrons() && Shared.isDbConnectionAvailable() === true) { return CronJobManagerJob.startListening().then(function () { Logger.tag('Cron').info('Cron Job Manager is started. S...
javascript
function () { const cronJobsToStart = _getNamesOfCronJobsToStart(); if (!cronJobsToStart && _shouldStartCrons() && Shared.isDbConnectionAvailable() === true) { return CronJobManagerJob.startListening().then(function () { Logger.tag('Cron').info('Cron Job Manager is started. S...
[ "function", "(", ")", "{", "const", "cronJobsToStart", "=", "_getNamesOfCronJobsToStart", "(", ")", ";", "if", "(", "!", "cronJobsToStart", "&&", "_shouldStartCrons", "(", ")", "&&", "Shared", ".", "isDbConnectionAvailable", "(", ")", "===", "true", ")", "{", ...
Start cron manager @returns {*} @private
[ "Start", "cron", "manager" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/mia-js.js#L284-L316
train
mia-js/mia-js-core
lib/mia-js.js
function () { const crons = _.get(Shared, 'runtimeArgs.cron') || _.get(Shared, 'runtimeArgs.crons'); if (crons) { const cronTasks = crons.replace(/\s/g, '').split(','); return cronTasks.length > 0 ? cronTasks : undefined; } return undefined; }
javascript
function () { const crons = _.get(Shared, 'runtimeArgs.cron') || _.get(Shared, 'runtimeArgs.crons'); if (crons) { const cronTasks = crons.replace(/\s/g, '').split(','); return cronTasks.length > 0 ? cronTasks : undefined; } return undefined; }
[ "function", "(", ")", "{", "const", "crons", "=", "_", ".", "get", "(", "Shared", ",", "'runtimeArgs.cron'", ")", "||", "_", ".", "get", "(", "Shared", ",", "'runtimeArgs.crons'", ")", ";", "if", "(", "crons", ")", "{", "const", "cronTasks", "=", "cr...
Checks process arguments if specific cron jobs should be started immediately. That's the case if there is a third argument like "cron=NameOfCronjobToStart,NameOfAnotherCronjobToStart" @returns {Array} Names of cron jobs to start @private
[ "Checks", "process", "arguments", "if", "specific", "cron", "jobs", "should", "be", "started", "immediately", ".", "That", "s", "the", "case", "if", "there", "is", "a", "third", "argument", "like", "cron", "=", "NameOfCronjobToStart", "NameOfAnotherCronjobToStart"...
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/mia-js.js#L324-L331
train
rapid7/rism
lib/rism.js
setResponsive
function setResponsive(name) { if (name) { setResponsiveComponents.call(this, name); } else { _utils2["default"].forEach(Object.keys(this._component), (function (name) { setResponsiveComponents.call(this, name); }).bind(this)); } if (_utils2["default"].isUndefined(na...
javascript
function setResponsive(name) { if (name) { setResponsiveComponents.call(this, name); } else { _utils2["default"].forEach(Object.keys(this._component), (function (name) { setResponsiveComponents.call(this, name); }).bind(this)); } if (_utils2["default"].isUndefined(na...
[ "function", "setResponsive", "(", "name", ")", "{", "if", "(", "name", ")", "{", "setResponsiveComponents", ".", "call", "(", "this", ",", "name", ")", ";", "}", "else", "{", "_utils2", "[", "\"default\"", "]", ".", "forEach", "(", "Object", ".", "keys...
set responsive values
[ "set", "responsive", "values" ]
cc1b8dd05175b0df375c0892edc4b1fefdf72b0f
https://github.com/rapid7/rism/blob/cc1b8dd05175b0df375c0892edc4b1fefdf72b0f/lib/rism.js#L154-L176
train
playmedia/http-cli
lib/config.js
loadDefault
function loadDefault() { return { port: 8000, host: '127.0.0.1', root: './', logFormat: 'combined', middlewares: [ { name: 'cors', cfg: { origin: true } }, { name: 'morgan', cfg: {} }, { name: 'serveStatic', ...
javascript
function loadDefault() { return { port: 8000, host: '127.0.0.1', root: './', logFormat: 'combined', middlewares: [ { name: 'cors', cfg: { origin: true } }, { name: 'morgan', cfg: {} }, { name: 'serveStatic', ...
[ "function", "loadDefault", "(", ")", "{", "return", "{", "port", ":", "8000", ",", "host", ":", "'127.0.0.1'", ",", "root", ":", "'./'", ",", "logFormat", ":", "'combined'", ",", "middlewares", ":", "[", "{", "name", ":", "'cors'", ",", "cfg", ":", "...
Get default HTTP server configuration. @return {Object} The HTTP server configuration.
[ "Get", "default", "HTTP", "server", "configuration", "." ]
81862084ef50cf9db6530b0da48cbe721355378f
https://github.com/playmedia/http-cli/blob/81862084ef50cf9db6530b0da48cbe721355378f/lib/config.js#L8-L37
train
playmedia/http-cli
lib/config.js
loadFromFile
function loadFromFile(filename) { var cfg = {} Object.assign( cfg, loadDefault(), JSON.parse(fs.readFileSync(filename)) ) return cfg }
javascript
function loadFromFile(filename) { var cfg = {} Object.assign( cfg, loadDefault(), JSON.parse(fs.readFileSync(filename)) ) return cfg }
[ "function", "loadFromFile", "(", "filename", ")", "{", "var", "cfg", "=", "{", "}", "Object", ".", "assign", "(", "cfg", ",", "loadDefault", "(", ")", ",", "JSON", ".", "parse", "(", "fs", ".", "readFileSync", "(", "filename", ")", ")", ")", "return"...
Get HTTP server configuration from JSON file. @param {string} filename - The JSON filename. @throws Will throw an error if invalid filename or JSON. @return {Object} The HTTP server configuration.
[ "Get", "HTTP", "server", "configuration", "from", "JSON", "file", "." ]
81862084ef50cf9db6530b0da48cbe721355378f
https://github.com/playmedia/http-cli/blob/81862084ef50cf9db6530b0da48cbe721355378f/lib/config.js#L45-L54
train
playmedia/http-cli
lib/config.js
saveToFile
function saveToFile(filename, cfg) { // Use 'wx' flag to fails if filename exists fs.writeFileSync(filename, JSON.stringify(cfg, null, 2), {flag: 'wx'}) }
javascript
function saveToFile(filename, cfg) { // Use 'wx' flag to fails if filename exists fs.writeFileSync(filename, JSON.stringify(cfg, null, 2), {flag: 'wx'}) }
[ "function", "saveToFile", "(", "filename", ",", "cfg", ")", "{", "// Use 'wx' flag to fails if filename exists", "fs", ".", "writeFileSync", "(", "filename", ",", "JSON", ".", "stringify", "(", "cfg", ",", "null", ",", "2", ")", ",", "{", "flag", ":", "'wx'"...
Save HTTP server configuration to JSON file. @param {string} filename - The JSON filename. @param {Object} cfg - The HTTP server configuration. @throws Will throw an error if filename exists.
[ "Save", "HTTP", "server", "configuration", "to", "JSON", "file", "." ]
81862084ef50cf9db6530b0da48cbe721355378f
https://github.com/playmedia/http-cli/blob/81862084ef50cf9db6530b0da48cbe721355378f/lib/config.js#L62-L65
train
playmedia/http-cli
lib/config.js
loadFromOptions
function loadFromOptions(opts) { var defCfg = loadDefault() var cfg = opts.config ? loadFromFile(opts.config) : loadDefault() // Command line config override file loaded config for (var k in opts) { defCfg.hasOwnProperty(k) && (defCfg[k] !== opts[k] && (cfg[k] = opts[k])) } return cfg }
javascript
function loadFromOptions(opts) { var defCfg = loadDefault() var cfg = opts.config ? loadFromFile(opts.config) : loadDefault() // Command line config override file loaded config for (var k in opts) { defCfg.hasOwnProperty(k) && (defCfg[k] !== opts[k] && (cfg[k] = opts[k])) } return cfg }
[ "function", "loadFromOptions", "(", "opts", ")", "{", "var", "defCfg", "=", "loadDefault", "(", ")", "var", "cfg", "=", "opts", ".", "config", "?", "loadFromFile", "(", "opts", ".", "config", ")", ":", "loadDefault", "(", ")", "// Command line config overrid...
Get HTTP server configuration from command line options. @param {Object} opts - The command line options. @return {Object} The HTTP server configuration.
[ "Get", "HTTP", "server", "configuration", "from", "command", "line", "options", "." ]
81862084ef50cf9db6530b0da48cbe721355378f
https://github.com/playmedia/http-cli/blob/81862084ef50cf9db6530b0da48cbe721355378f/lib/config.js#L72-L82
train
mia-js/mia-js-core
lib/moduleLoader/lib/requireAll.js
function (options, iterationInfo) { var files; var modules = {}; var result = {}; // remember the starting directory try { files = fs.readdirSync(iterationInfo.dirName); } catch (e) { if (options.optional) return {}; el...
javascript
function (options, iterationInfo) { var files; var modules = {}; var result = {}; // remember the starting directory try { files = fs.readdirSync(iterationInfo.dirName); } catch (e) { if (options.optional) return {}; el...
[ "function", "(", "options", ",", "iterationInfo", ")", "{", "var", "files", ";", "var", "modules", "=", "{", "}", ";", "var", "result", "=", "{", "}", ";", "// remember the starting directory", "try", "{", "files", "=", "fs", ".", "readdirSync", "(", "it...
Parses a directory and searches for options.module subdir. If found subdir is searched for required files @param options @param iterationInfo @returns {{}}
[ "Parses", "a", "directory", "and", "searches", "for", "options", ".", "module", "subdir", ".", "If", "found", "subdir", "is", "searched", "for", "required", "files" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/moduleLoader/lib/requireAll.js#L100-L123
train
mia-js/mia-js-core
lib/moduleLoader/lib/requireAll.js
function (options, iterationInfo, modules) { // filename filter if (options.fileNameFilter) { var match = iterationInfo.fileName.match(options.fileNameFilter); if (!match) { return; } } // Filter spec.js files var match = itera...
javascript
function (options, iterationInfo, modules) { // filename filter if (options.fileNameFilter) { var match = iterationInfo.fileName.match(options.fileNameFilter); if (!match) { return; } } // Filter spec.js files var match = itera...
[ "function", "(", "options", ",", "iterationInfo", ",", "modules", ")", "{", "// filename filter", "if", "(", "options", ".", "fileNameFilter", ")", "{", "var", "match", "=", "iterationInfo", ".", "fileName", ".", "match", "(", "options", ".", "fileNameFilter",...
Process single file to module dictionary @param options @param fileName @param modules
[ "Process", "single", "file", "to", "module", "dictionary" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/moduleLoader/lib/requireAll.js#L181-L205
train
mia-js/mia-js-core
lib/moduleLoader/lib/requireAll.js
function (modules, options, iterationInfo) { // load module into memory (unless `dontLoad` is true) var module = true; //default is options.dontLoad === false if (options.dontLoad !== true) { //if module is to be loaded module = require(iterationInfo.absoluteFul...
javascript
function (modules, options, iterationInfo) { // load module into memory (unless `dontLoad` is true) var module = true; //default is options.dontLoad === false if (options.dontLoad !== true) { //if module is to be loaded module = require(iterationInfo.absoluteFul...
[ "function", "(", "modules", ",", "options", ",", "iterationInfo", ")", "{", "// load module into memory (unless `dontLoad` is true)", "var", "module", "=", "true", ";", "//default is options.dontLoad === false", "if", "(", "options", ".", "dontLoad", "!==", "true", ")",...
Load single module @param modules @param options @param iterationInfo
[ "Load", "single", "module" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/moduleLoader/lib/requireAll.js#L213-L285
train
mia-js/mia-js-core
lib/moduleLoader/lib/requireAll.js
function (options, iterationInfo) { // Use the identity for the key name var identity; if (options.mode === 'list') { identity = iterationInfo.relativeFullPath; //identity = identity.toLowerCase(); //find and replace all containments of '/', ':' and '\' within...
javascript
function (options, iterationInfo) { // Use the identity for the key name var identity; if (options.mode === 'list') { identity = iterationInfo.relativeFullPath; //identity = identity.toLowerCase(); //find and replace all containments of '/', ':' and '\' within...
[ "function", "(", "options", ",", "iterationInfo", ")", "{", "// Use the identity for the key name", "var", "identity", ";", "if", "(", "options", ".", "mode", "===", "'list'", ")", "{", "identity", "=", "iterationInfo", ".", "relativeFullPath", ";", "//identity = ...
Generates identity for a module @param options @param iterationInfo @returns {string}
[ "Generates", "identity", "for", "a", "module" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/moduleLoader/lib/requireAll.js#L293-L313
train
mia-js/mia-js-core
lib/moduleLoader/lib/requireAll.js
function (options, iterationInfo, modules) { // Ignore explicitly excluded directories if (options.excludeDirs) { var match = iterationInfo.fileName.match(options.excludeDirs); if (match) return; } // Recursively call requireAll on each child dir...
javascript
function (options, iterationInfo, modules) { // Ignore explicitly excluded directories if (options.excludeDirs) { var match = iterationInfo.fileName.match(options.excludeDirs); if (match) return; } // Recursively call requireAll on each child dir...
[ "function", "(", "options", ",", "iterationInfo", ",", "modules", ")", "{", "// Ignore explicitly excluded directories", "if", "(", "options", ".", "excludeDirs", ")", "{", "var", "match", "=", "iterationInfo", ".", "fileName", ".", "match", "(", "options", ".",...
Processes one directory level @param options :: general options @param iterationInfo :: iteration options @param modules :: object in which output will be loaded
[ "Processes", "one", "directory", "level" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/moduleLoader/lib/requireAll.js#L321-L371
train
mia-js/mia-js-core
lib/logger/lib/logger.js
function (level, message, tag, data) { var env = Shared.config('environment'); var levels = ['fatal', 'error', 'warn', 'info', 'debug', 'trace']; var logLevelConfig = env.logLevel || "info"; if (logLevelConfig == "none") { return; } var logLevel = levels.in...
javascript
function (level, message, tag, data) { var env = Shared.config('environment'); var levels = ['fatal', 'error', 'warn', 'info', 'debug', 'trace']; var logLevelConfig = env.logLevel || "info"; if (logLevelConfig == "none") { return; } var logLevel = levels.in...
[ "function", "(", "level", ",", "message", ",", "tag", ",", "data", ")", "{", "var", "env", "=", "Shared", ".", "config", "(", "'environment'", ")", ";", "var", "levels", "=", "[", "'fatal'", ",", "'error'", ",", "'warn'", ",", "'info'", ",", "'debug'...
Write logging information @param level => 'none', 'fatal', 'error', 'warn', 'info', 'debug', 'trace' @param message = >Error message @param tag => Tags of log info i.e. database, request. Default is 'default' or empty @param data => Any data object @private
[ "Write", "logging", "information" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/logger/lib/logger.js#L23-L82
train
mia-js/mia-js-core
lib/logger/lib/logger.js
function (obj, tag) { tag = _.isArray(tag) ? tag.join(',') : tag; tag = !_.isEmpty(tag) ? tag.toLowerCase() : 'default'; obj.trace = function (message, data) { _logEvent("trace", message, tag, data); }; obj.debug = function (message, data) { _logEvent("d...
javascript
function (obj, tag) { tag = _.isArray(tag) ? tag.join(',') : tag; tag = !_.isEmpty(tag) ? tag.toLowerCase() : 'default'; obj.trace = function (message, data) { _logEvent("trace", message, tag, data); }; obj.debug = function (message, data) { _logEvent("d...
[ "function", "(", "obj", ",", "tag", ")", "{", "tag", "=", "_", ".", "isArray", "(", "tag", ")", "?", "tag", ".", "join", "(", "','", ")", ":", "tag", ";", "tag", "=", "!", "_", ".", "isEmpty", "(", "tag", ")", "?", "tag", ".", "toLowerCase", ...
Provide log methods @param obj @param tag @returns {*}
[ "Provide", "log", "methods" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/logger/lib/logger.js#L100-L129
train
AndreasPizsa/grunt-update-json
tasks/lib/update_json.js
expandField
function expandField(input, grunt){ var get = pointer(input); return function(memo, fin, fout){ if(_.isString(fin)){ var match = fin.match(re.PATH_POINT); // matched ...with a `$.` ...but not with a `\` if(match && match[3] === '$.' && !match[1]){ // field name, starts with an ...
javascript
function expandField(input, grunt){ var get = pointer(input); return function(memo, fin, fout){ if(_.isString(fin)){ var match = fin.match(re.PATH_POINT); // matched ...with a `$.` ...but not with a `\` if(match && match[3] === '$.' && !match[1]){ // field name, starts with an ...
[ "function", "expandField", "(", "input", ",", "grunt", ")", "{", "var", "get", "=", "pointer", "(", "input", ")", ";", "return", "function", "(", "memo", ",", "fin", ",", "fout", ")", "{", "if", "(", "_", ".", "isString", "(", "fin", ")", ")", "{...
factory for a reduce function, bound to the input, that can get the value out of the input
[ "factory", "for", "a", "reduce", "function", "bound", "to", "the", "input", "that", "can", "get", "the", "value", "out", "of", "the", "input" ]
c85f6575a039c665371ce411f0d47e2a264bb3b6
https://github.com/AndreasPizsa/grunt-update-json/blob/c85f6575a039c665371ce411f0d47e2a264bb3b6/tasks/lib/update_json.js#L46-L82
train
voxgig/seneca-hapi
hapi.js
action_handler
async function action_handler(req, h) { const data = req.payload const json = 'string' === typeof data ? tu.parseJSON(data) : data if (json instanceof Error) { throw json } const seneca = prepare_seneca(req, json) const msg = tu.internalize_msg(seneca, json) return await new Promise(...
javascript
async function action_handler(req, h) { const data = req.payload const json = 'string' === typeof data ? tu.parseJSON(data) : data if (json instanceof Error) { throw json } const seneca = prepare_seneca(req, json) const msg = tu.internalize_msg(seneca, json) return await new Promise(...
[ "async", "function", "action_handler", "(", "req", ",", "h", ")", "{", "const", "data", "=", "req", ".", "payload", "const", "json", "=", "'string'", "===", "typeof", "data", "?", "tu", ".", "parseJSON", "(", "data", ")", ":", "data", "if", "(", "jso...
Convenience handler to call a seneca action directly from inbound POST JSON.
[ "Convenience", "handler", "to", "call", "a", "seneca", "action", "directly", "from", "inbound", "POST", "JSON", "." ]
377c0e8c38bc2703686fcffa85a5999c93f9ef1c
https://github.com/voxgig/seneca-hapi/blob/377c0e8c38bc2703686fcffa85a5999c93f9ef1c/hapi.js#L64-L91
train
mia-js/mia-js-core
lib/cronJobs/lib/jobManagementDbConnector.js
function () { return ServerHeartbeatModel.find({ status: _statusActive }).then(function (cursor) { return Q.ninvoke(cursor, 'toArray').then(function (servers) { var serverIds = []; servers.map(function (value) { serverIds.push(v...
javascript
function () { return ServerHeartbeatModel.find({ status: _statusActive }).then(function (cursor) { return Q.ninvoke(cursor, 'toArray').then(function (servers) { var serverIds = []; servers.map(function (value) { serverIds.push(v...
[ "function", "(", ")", "{", "return", "ServerHeartbeatModel", ".", "find", "(", "{", "status", ":", "_statusActive", "}", ")", ".", "then", "(", "function", "(", "cursor", ")", "{", "return", "Q", ".", "ninvoke", "(", "cursor", ",", "'toArray'", ")", "....
Remove unknown serverIds from jobslist, can happen while server restart
[ "Remove", "unknown", "serverIds", "from", "jobslist", "can", "happen", "while", "server", "restart" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/cronJobs/lib/jobManagementDbConnector.js#L301-L313
train
jbaicoianu/elation
components/utils/scripts/dust.js
function( input, chunk, context ){ // return given input if there is no dust reference to resolve var output = input; // dust compiles a string to function, if there are references if( typeof input === "function"){ if( ( typeof input.isReference !== "undefined" ) && ( input.isReference === true ) ...
javascript
function( input, chunk, context ){ // return given input if there is no dust reference to resolve var output = input; // dust compiles a string to function, if there are references if( typeof input === "function"){ if( ( typeof input.isReference !== "undefined" ) && ( input.isReference === true ) ...
[ "function", "(", "input", ",", "chunk", ",", "context", ")", "{", "// return given input if there is no dust reference to resolve", "var", "output", "=", "input", ";", "// dust compiles a string to function, if there are references", "if", "(", "typeof", "input", "===", "\"...
Utility helping to resolve dust references in the given chunk
[ "Utility", "helping", "to", "resolve", "dust", "references", "in", "the", "given", "chunk" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/scripts/dust.js#L655-L674
train
jbaicoianu/elation
components/utils/scripts/dust.js
compactBuffers
function compactBuffers(context, node) { var out = [node[0]], memo; for (var i=1, len=node.length; i<len; i++) { var res = dust.filterNode(context, node[i]); if (res) { if (res[0] === 'buffer') { if (memo) { memo[1] += res[1]; } else { memo = res; out.push...
javascript
function compactBuffers(context, node) { var out = [node[0]], memo; for (var i=1, len=node.length; i<len; i++) { var res = dust.filterNode(context, node[i]); if (res) { if (res[0] === 'buffer') { if (memo) { memo[1] += res[1]; } else { memo = res; out.push...
[ "function", "compactBuffers", "(", "context", ",", "node", ")", "{", "var", "out", "=", "[", "node", "[", "0", "]", "]", ",", "memo", ";", "for", "(", "var", "i", "=", "1", ",", "len", "=", "node", ".", "length", ";", "i", "<", "len", ";", "i...
Compacts consecutive buffer nodes into a single node
[ "Compacts", "consecutive", "buffer", "nodes", "into", "a", "single", "node" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/scripts/dust.js#L838-L857
train
mia-js/mia-js-core
lib/utils/lib/ipAddressHelper.js
thisModule
function thisModule() { var self = this; /** * Generate random hash value * @returns {*} */ self.getClientIP = function (req) { req = req || {}; req.connection = req.connection || {}; req.socket = req.socket || {}; req.client = req.client || {}; var ip...
javascript
function thisModule() { var self = this; /** * Generate random hash value * @returns {*} */ self.getClientIP = function (req) { req = req || {}; req.connection = req.connection || {}; req.socket = req.socket || {}; req.client = req.client || {}; var ip...
[ "function", "thisModule", "(", ")", "{", "var", "self", "=", "this", ";", "/**\n * Generate random hash value\n * @returns {*}\n */", "self", ".", "getClientIP", "=", "function", "(", "req", ")", "{", "req", "=", "req", "||", "{", "}", ";", "req", ...
Determine Clients IP Address @param err @returns {*}
[ "Determine", "Clients", "IP", "Address" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/utils/lib/ipAddressHelper.js#L7-L31
train
AmpersandJS/ampersand-dom
ampersand-dom.js
function (el, cls) { cls = getString(cls); if (!cls) return; if (Array.isArray(cls)) { cls.forEach(function(c) { dom.addClass(el, c); }); } else if (el.classList) { el.classList.add(cls); } else { if (!hasClass(el, c...
javascript
function (el, cls) { cls = getString(cls); if (!cls) return; if (Array.isArray(cls)) { cls.forEach(function(c) { dom.addClass(el, c); }); } else if (el.classList) { el.classList.add(cls); } else { if (!hasClass(el, c...
[ "function", "(", "el", ",", "cls", ")", "{", "cls", "=", "getString", "(", "cls", ")", ";", "if", "(", "!", "cls", ")", "return", ";", "if", "(", "Array", ".", "isArray", "(", "cls", ")", ")", "{", "cls", ".", "forEach", "(", "function", "(", ...
optimize if we have classList
[ "optimize", "if", "we", "have", "classList" ]
7a79f8a2a6c0bba16eb6d9f5e81295c0286aafa9
https://github.com/AmpersandJS/ampersand-dom/blob/7a79f8a2a6c0bba16eb6d9f5e81295c0286aafa9/ampersand-dom.js#L7-L25
train
jbaicoianu/elation
components/utils/scripts/elation.js
function(name, container, args, events) { /* handling for any default values if args are not specified */ var mergeDefaults = function(args, defaults) { var args = args || {}; if (typeof defaults == 'object') { for (var key in defaults) { if (elation.utils.isNull(args[...
javascript
function(name, container, args, events) { /* handling for any default values if args are not specified */ var mergeDefaults = function(args, defaults) { var args = args || {}; if (typeof defaults == 'object') { for (var key in defaults) { if (elation.utils.isNull(args[...
[ "function", "(", "name", ",", "container", ",", "args", ",", "events", ")", "{", "/* handling for any default values if args are not specified */", "var", "mergeDefaults", "=", "function", "(", "args", ",", "defaults", ")", "{", "var", "args", "=", "args", "||", ...
At the top level, a component is just a function which checks to see if an instance with the given name exists already. If it doesn't we create it, and then we return a reference to the specified instance.
[ "At", "the", "top", "level", "a", "component", "is", "just", "a", "function", "which", "checks", "to", "see", "if", "an", "instance", "with", "the", "given", "name", "exists", "already", ".", "If", "it", "doesn", "t", "we", "create", "it", "and", "then...
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/scripts/elation.js#L238-L322
train
healthsparq/ember-fountainhead
lib/parse-markdown.js
function(description) { // Look for triple backtick code blocks flagged as `glimmer`; // define end of block as triple backticks followed by a newline let matches = description.match(/(```glimmer)(.|\n)*?```/gi); if (matches && matches.length) { matches.map(codeBlock => { let blockEnd = codeBlock.len...
javascript
function(description) { // Look for triple backtick code blocks flagged as `glimmer`; // define end of block as triple backticks followed by a newline let matches = description.match(/(```glimmer)(.|\n)*?```/gi); if (matches && matches.length) { matches.map(codeBlock => { let blockEnd = codeBlock.len...
[ "function", "(", "description", ")", "{", "// Look for triple backtick code blocks flagged as `glimmer`;", "// define end of block as triple backticks followed by a newline", "let", "matches", "=", "description", ".", "match", "(", "/", "(```glimmer)(.|\\n)*?```", "/", "gi", ")",...
Scans the description text for instances of markdown code blocks flagged as `"glimmer"` syntax. If any such instances are found, they are copied, stripped of their triple backticks and re-inserted into the `templateString` immediately after the original declaration. This allows for functional copies of your code exampl...
[ "Scans", "the", "description", "text", "for", "instances", "of", "markdown", "code", "blocks", "flagged", "as", "glimmer", "syntax", ".", "If", "any", "such", "instances", "are", "found", "they", "are", "copied", "stripped", "of", "their", "triple", "backticks...
3577546719b251385ca1093f812889590459205a
https://github.com/healthsparq/ember-fountainhead/blob/3577546719b251385ca1093f812889590459205a/lib/parse-markdown.js#L101-L115
train
jbaicoianu/elation
components/utils/htdocs/scripts/jsmart.js
obMerge
function obMerge(prefix, ob1, ob2 /*, ...*/) { for (var i=2; i<arguments.length; ++i) { for (var nm in arguments[i]) { if (arguments[i].hasOwnProperty(nm) || typeof arguments[i][nm] == 'function') { if (typeof(arguments[i][...
javascript
function obMerge(prefix, ob1, ob2 /*, ...*/) { for (var i=2; i<arguments.length; ++i) { for (var nm in arguments[i]) { if (arguments[i].hasOwnProperty(nm) || typeof arguments[i][nm] == 'function') { if (typeof(arguments[i][...
[ "function", "obMerge", "(", "prefix", ",", "ob1", ",", "ob2", "/*, ...*/", ")", "{", "for", "(", "var", "i", "=", "2", ";", "i", "<", "arguments", ".", "length", ";", "++", "i", ")", "{", "for", "(", "var", "nm", "in", "arguments", "[", "i", "]...
merges two or more objects into one and add prefix at the beginning of every property name at the top level objects type is lost, only own properties copied
[ "merges", "two", "or", "more", "objects", "into", "one", "and", "add", "prefix", "at", "the", "beginning", "of", "every", "property", "name", "at", "the", "top", "level", "objects", "type", "is", "lost", "only", "own", "properties", "copied" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/htdocs/scripts/jsmart.js#L17-L38
train
jbaicoianu/elation
components/utils/htdocs/scripts/jsmart.js
function(e, s) { var parens = []; e.tree.push(parens); parens.parent = e.tree; e.tree = parens; }
javascript
function(e, s) { var parens = []; e.tree.push(parens); parens.parent = e.tree; e.tree = parens; }
[ "function", "(", "e", ",", "s", ")", "{", "var", "parens", "=", "[", "]", ";", "e", ".", "tree", ".", "push", "(", "parens", ")", ";", "parens", ".", "parent", "=", "e", ".", "tree", ";", "e", ".", "tree", "=", "parens", ";", "}" ]
expression in parentheses
[ "expression", "in", "parentheses" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/htdocs/scripts/jsmart.js#L1093-L1099
train
mongodb-js/storage-mixin
lib/backends/errback.js
function(done) { return { success: function(res) { done(null, res); }, error: function(res, err) { done(err); } }; }
javascript
function(done) { return { success: function(res) { done(null, res); }, error: function(res, err) { done(err); } }; }
[ "function", "(", "done", ")", "{", "return", "{", "success", ":", "function", "(", "res", ")", "{", "done", "(", "null", ",", "res", ")", ";", "}", ",", "error", ":", "function", "(", "res", ",", "err", ")", "{", "done", "(", "err", ")", ";", ...
The opposite of wrapOptions, this helper wraps an errback and returns an options object that calls the errback appropriately. @param {Function} done @return {Object}
[ "The", "opposite", "of", "wrapOptions", "this", "helper", "wraps", "an", "errback", "and", "returns", "an", "options", "object", "that", "calls", "the", "errback", "appropriately", "." ]
1f8c26e6db4738f6f502a9a3286d114364fe9ed8
https://github.com/mongodb-js/storage-mixin/blob/1f8c26e6db4738f6f502a9a3286d114364fe9ed8/lib/backends/errback.js#L34-L43
train
knownasilya/interval
lib/interval.js
add
function add(base, addend) { if (util.isDate(base)) { return new Date(base.getTime() + interval(addend)); } return interval(base) + interval(addend); }
javascript
function add(base, addend) { if (util.isDate(base)) { return new Date(base.getTime() + interval(addend)); } return interval(base) + interval(addend); }
[ "function", "add", "(", "base", ",", "addend", ")", "{", "if", "(", "util", ".", "isDate", "(", "base", ")", ")", "{", "return", "new", "Date", "(", "base", ".", "getTime", "(", ")", "+", "interval", "(", "addend", ")", ")", ";", "}", "return", ...
first parmater can be a date or an interval, second parameter has to be an interval returns the same type as the first parameter
[ "first", "parmater", "can", "be", "a", "date", "or", "an", "interval", "second", "parameter", "has", "to", "be", "an", "interval", "returns", "the", "same", "type", "as", "the", "first", "parameter" ]
d8dd395944dc202f79031adeb3defe9296c5a7f8
https://github.com/knownasilya/interval/blob/d8dd395944dc202f79031adeb3defe9296c5a7f8/lib/interval.js#L95-L100
train
faucet-pipeline/faucet-pipeline-sass
lib/make-sass-renderer.js
renderSass
function renderSass(options) { return new Promise((resolve, reject) => { try { // using synchronous rendering because it is faster let result = sass.renderSync(options); result.css = fixEOF(result.css); resolve(result); } catch(err) { reject(err); } }); }
javascript
function renderSass(options) { return new Promise((resolve, reject) => { try { // using synchronous rendering because it is faster let result = sass.renderSync(options); result.css = fixEOF(result.css); resolve(result); } catch(err) { reject(err); } }); }
[ "function", "renderSass", "(", "options", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "try", "{", "// using synchronous rendering because it is faster", "let", "result", "=", "sass", ".", "renderSync", "(", "options"...
promisified version of sass.render
[ "promisified", "version", "of", "sass", ".", "render" ]
a9c1e40671237abdef4939dfb07e8717bb187622
https://github.com/faucet-pipeline/faucet-pipeline-sass/blob/a9c1e40671237abdef4939dfb07e8717bb187622/lib/make-sass-renderer.js#L29-L40
train
jbaicoianu/elation
components/utils/scripts/sylvester.js
function(obj) { if (obj.anchor) { // obj is a plane or line var P = this.elements.slice(); var C = obj.pointClosestTo(P).elements; return Vector.create([C[0] + (C[0] - P[0]), C[1] + (C[1] - P[1]), C[2] + (C[2] - (P[2] || 0))]); } else { // obj is a point var Q = obj.e...
javascript
function(obj) { if (obj.anchor) { // obj is a plane or line var P = this.elements.slice(); var C = obj.pointClosestTo(P).elements; return Vector.create([C[0] + (C[0] - P[0]), C[1] + (C[1] - P[1]), C[2] + (C[2] - (P[2] || 0))]); } else { // obj is a point var Q = obj.e...
[ "function", "(", "obj", ")", "{", "if", "(", "obj", ".", "anchor", ")", "{", "// obj is a plane or line\r", "var", "P", "=", "this", ".", "elements", ".", "slice", "(", ")", ";", "var", "C", "=", "obj", ".", "pointClosestTo", "(", "P", ")", ".", "e...
Returns the result of reflecting the point in the given point, line or plane
[ "Returns", "the", "result", "of", "reflecting", "the", "point", "in", "the", "given", "point", "line", "or", "plane" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/scripts/sylvester.js#L264-L276
train
jbaicoianu/elation
components/utils/scripts/sylvester.js
function(obj) { if (obj.normal) { // obj is a plane var A = this.anchor.elements, D = this.direction.elements; var A1 = A[0], A2 = A[1], A3 = A[2], D1 = D[0], D2 = D[1], D3 = D[2]; var newA = this.anchor.reflectionIn(obj).elements; // Add the line's direction vector to its anchor...
javascript
function(obj) { if (obj.normal) { // obj is a plane var A = this.anchor.elements, D = this.direction.elements; var A1 = A[0], A2 = A[1], A3 = A[2], D1 = D[0], D2 = D[1], D3 = D[2]; var newA = this.anchor.reflectionIn(obj).elements; // Add the line's direction vector to its anchor...
[ "function", "(", "obj", ")", "{", "if", "(", "obj", ".", "normal", ")", "{", "// obj is a plane\r", "var", "A", "=", "this", ".", "anchor", ".", "elements", ",", "D", "=", "this", ".", "direction", ".", "elements", ";", "var", "A1", "=", "A", "[", ...
Returns the line's reflection in the given point or line
[ "Returns", "the", "line", "s", "reflection", "in", "the", "given", "point", "or", "line" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/scripts/sylvester.js#L973-L992
train
ericmatthys/grunt-changelog
tasks/changelog.js
getChanges
function getChanges(log, regex) { var changes = []; var match; while ((match = regex.exec(log))) { var change = ''; for (var i = 1, len = match.length; i < len; i++) { change += match[i]; } changes.push(change.trim()); } return changes; }
javascript
function getChanges(log, regex) { var changes = []; var match; while ((match = regex.exec(log))) { var change = ''; for (var i = 1, len = match.length; i < len; i++) { change += match[i]; } changes.push(change.trim()); } return changes; }
[ "function", "getChanges", "(", "log", ",", "regex", ")", "{", "var", "changes", "=", "[", "]", ";", "var", "match", ";", "while", "(", "(", "match", "=", "regex", ".", "exec", "(", "log", ")", ")", ")", "{", "var", "change", "=", "''", ";", "fo...
Loop through each match and build the array of changes that will be passed to the template.
[ "Loop", "through", "each", "match", "and", "build", "the", "array", "of", "changes", "that", "will", "be", "passed", "to", "the", "template", "." ]
24bc2a0a5ba0bdfb3d46d4fbb10763181eab25e6
https://github.com/ericmatthys/grunt-changelog/blob/24bc2a0a5ba0bdfb3d46d4fbb10763181eab25e6/tasks/changelog.js#L76-L91
train
ericmatthys/grunt-changelog
tasks/changelog.js
getChangelog
function getChangelog(log) { var data = { date: moment().format('YYYY-MM-DD'), features: getChanges(log, options.featureRegex), fixes: getChanges(log, options.fixRegex) }; return template(data); }
javascript
function getChangelog(log) { var data = { date: moment().format('YYYY-MM-DD'), features: getChanges(log, options.featureRegex), fixes: getChanges(log, options.fixRegex) }; return template(data); }
[ "function", "getChangelog", "(", "log", ")", "{", "var", "data", "=", "{", "date", ":", "moment", "(", ")", ".", "format", "(", "'YYYY-MM-DD'", ")", ",", "features", ":", "getChanges", "(", "log", ",", "options", ".", "featureRegex", ")", ",", "fixes",...
Generate the changelog using the templates defined in options.
[ "Generate", "the", "changelog", "using", "the", "templates", "defined", "in", "options", "." ]
24bc2a0a5ba0bdfb3d46d4fbb10763181eab25e6
https://github.com/ericmatthys/grunt-changelog/blob/24bc2a0a5ba0bdfb3d46d4fbb10763181eab25e6/tasks/changelog.js#L94-L102
train
ericmatthys/grunt-changelog
tasks/changelog.js
writeChangelog
function writeChangelog(changelog) { var fileContents = null; var firstLineFile = null; var firstLineFileHeader = null; var regex = null; if (options.insertType && grunt.file.exists(options.dest)) { fileContents = grunt.file.read(options.dest); firstLineFile = fileContents...
javascript
function writeChangelog(changelog) { var fileContents = null; var firstLineFile = null; var firstLineFileHeader = null; var regex = null; if (options.insertType && grunt.file.exists(options.dest)) { fileContents = grunt.file.read(options.dest); firstLineFile = fileContents...
[ "function", "writeChangelog", "(", "changelog", ")", "{", "var", "fileContents", "=", "null", ";", "var", "firstLineFile", "=", "null", ";", "var", "firstLineFileHeader", "=", "null", ";", "var", "regex", "=", "null", ";", "if", "(", "options", ".", "inser...
Write the changelog to the destination file.
[ "Write", "the", "changelog", "to", "the", "destination", "file", "." ]
24bc2a0a5ba0bdfb3d46d4fbb10763181eab25e6
https://github.com/ericmatthys/grunt-changelog/blob/24bc2a0a5ba0bdfb3d46d4fbb10763181eab25e6/tasks/changelog.js#L105-L157
train
mia-js/mia-js-core
lib/routesHandler/lib/initializeRoutes.js
function (preconditions) { var errorCodesList = { "500": ["InternalServerError"], "400": [ "UnexpectedDefaultValue", "UnexpectedType", "MinLengthUnderachieved", "MaxLengthExceeded", "MinValueUnderachived", ...
javascript
function (preconditions) { var errorCodesList = { "500": ["InternalServerError"], "400": [ "UnexpectedDefaultValue", "UnexpectedType", "MinLengthUnderachieved", "MaxLengthExceeded", "MinValueUnderachived", ...
[ "function", "(", "preconditions", ")", "{", "var", "errorCodesList", "=", "{", "\"500\"", ":", "[", "\"InternalServerError\"", "]", ",", "\"400\"", ":", "[", "\"UnexpectedDefaultValue\"", ",", "\"UnexpectedType\"", ",", "\"MinLengthUnderachieved\"", ",", "\"MaxLengthE...
Returns a list of http codes defined in preconditions section in controller
[ "Returns", "a", "list", "of", "http", "codes", "defined", "in", "preconditions", "section", "in", "controller" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/routesHandler/lib/initializeRoutes.js#L88-L132
train
mia-js/mia-js-core
lib/routesHandler/lib/initializeRoutes.js
function (attr, attrName) { if (_.isObject(attr) && !_.isDate(attr) && !_.isBoolean(attr) && !_.isString(attr) && !_.isNumber(attr) && !_.isFunction(attr) && !_.isRegExp(attr) && !_.isArray(attr)) { //attr = _removeAttributes(); for (var aIndex in attr) { ...
javascript
function (attr, attrName) { if (_.isObject(attr) && !_.isDate(attr) && !_.isBoolean(attr) && !_.isString(attr) && !_.isNumber(attr) && !_.isFunction(attr) && !_.isRegExp(attr) && !_.isArray(attr)) { //attr = _removeAttributes(); for (var aIndex in attr) { ...
[ "function", "(", "attr", ",", "attrName", ")", "{", "if", "(", "_", ".", "isObject", "(", "attr", ")", "&&", "!", "_", ".", "isDate", "(", "attr", ")", "&&", "!", "_", ".", "isBoolean", "(", "attr", ")", "&&", "!", "_", ".", "isString", "(", ...
Remove attributes recursively
[ "Remove", "attributes", "recursively" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/routesHandler/lib/initializeRoutes.js#L148-L168
train
mia-js/mia-js-core
lib/routesHandler/lib/initializeRoutes.js
function (parametersList, parameters, section) { if (parameters[section]) { for (var name in parameters[section]) { var addCondition = parameters[section][name]; if (parametersList[section] && parametersList[section][name]) { /...
javascript
function (parametersList, parameters, section) { if (parameters[section]) { for (var name in parameters[section]) { var addCondition = parameters[section][name]; if (parametersList[section] && parametersList[section][name]) { /...
[ "function", "(", "parametersList", ",", "parameters", ",", "section", ")", "{", "if", "(", "parameters", "[", "section", "]", ")", "{", "for", "(", "var", "name", "in", "parameters", "[", "section", "]", ")", "{", "var", "addCondition", "=", "parameters"...
Parse preconditions parameters in section header, query, body
[ "Parse", "preconditions", "parameters", "in", "section", "header", "query", "body" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/routesHandler/lib/initializeRoutes.js#L171-L215
train
mia-js/mia-js-core
lib/routesHandler/lib/initializeRoutes.js
function (req, res, next) { if (!req.miajs.controllerDebugInfo) { req.miajs.controllerDebugInfo = {}; } if (controller.name && controller.version) { req.miajs.controllerDebugInfo[controller.name + '_' + controller.version] = {'runtime': Date.now() - re...
javascript
function (req, res, next) { if (!req.miajs.controllerDebugInfo) { req.miajs.controllerDebugInfo = {}; } if (controller.name && controller.version) { req.miajs.controllerDebugInfo[controller.name + '_' + controller.version] = {'runtime': Date.now() - re...
[ "function", "(", "req", ",", "res", ",", "next", ")", "{", "if", "(", "!", "req", ".", "miajs", ".", "controllerDebugInfo", ")", "{", "req", ".", "miajs", ".", "controllerDebugInfo", "=", "{", "}", ";", "}", "if", "(", "controller", ".", "name", "&...
Measure runtime of controller
[ "Measure", "runtime", "of", "controller" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/routesHandler/lib/initializeRoutes.js#L381-L389
train
mia-js/mia-js-core
lib/routesHandler/lib/initializeRoutes.js
function (routeConfig, methodValue) { var rateLimits = []; var environment = Shared.config("environment"); var globalRateLimit = environment.rateLimit; if (globalRateLimit) { if (globalRateLimit.interval && _.isNumber(globalRateLimit.interval) && parseInt(globalRateLimit.inte...
javascript
function (routeConfig, methodValue) { var rateLimits = []; var environment = Shared.config("environment"); var globalRateLimit = environment.rateLimit; if (globalRateLimit) { if (globalRateLimit.interval && _.isNumber(globalRateLimit.interval) && parseInt(globalRateLimit.inte...
[ "function", "(", "routeConfig", ",", "methodValue", ")", "{", "var", "rateLimits", "=", "[", "]", ";", "var", "environment", "=", "Shared", ".", "config", "(", "\"environment\"", ")", ";", "var", "globalRateLimit", "=", "environment", ".", "rateLimit", ";", ...
Validate rate limits settings
[ "Validate", "rate", "limits", "settings" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/routesHandler/lib/initializeRoutes.js#L459-L493
train
mia-js/mia-js-core
lib/routesHandler/lib/initializeRoutes.js
function (req, res, next) { var ip = IPAddressHelper.getClientIP(req) , route = req.miajs.route , key = ip + route.path + route.method; if (_.isEmpty(route.rateLimits)) { next(); return; } RateLimiter.checkRateLimitsByKey(key, route.rateL...
javascript
function (req, res, next) { var ip = IPAddressHelper.getClientIP(req) , route = req.miajs.route , key = ip + route.path + route.method; if (_.isEmpty(route.rateLimits)) { next(); return; } RateLimiter.checkRateLimitsByKey(key, route.rateL...
[ "function", "(", "req", ",", "res", ",", "next", ")", "{", "var", "ip", "=", "IPAddressHelper", ".", "getClientIP", "(", "req", ")", ",", "route", "=", "req", ".", "miajs", ".", "route", ",", "key", "=", "ip", "+", "route", ".", "path", "+", "rou...
Route for rate limits check
[ "Route", "for", "rate", "limits", "check" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/routesHandler/lib/initializeRoutes.js#L497-L530
train
mia-js/mia-js-core
lib/rateLimiter/lib/rateLimiter.js
function (range) { var coeff = 1000 * 60 * range; return new Date(Math.ceil(new Date(Date.now()).getTime() / coeff) * coeff).getTime() / 1000; }
javascript
function (range) { var coeff = 1000 * 60 * range; return new Date(Math.ceil(new Date(Date.now()).getTime() / coeff) * coeff).getTime() / 1000; }
[ "function", "(", "range", ")", "{", "var", "coeff", "=", "1000", "*", "60", "*", "range", ";", "return", "new", "Date", "(", "Math", ".", "ceil", "(", "new", "Date", "(", "Date", ".", "now", "(", ")", ")", ".", "getTime", "(", ")", "/", "coeff"...
Calculate current time interval slot
[ "Calculate", "current", "time", "interval", "slot" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/rateLimiter/lib/rateLimiter.js#L21-L24
train
mia-js/mia-js-core
lib/rateLimiter/lib/rateLimiter.js
function (key, timeInterval, limit) { //Validate rate limiter settings if (!_.isNumber(timeInterval) || parseInt(timeInterval) <= 0 || !_.isNumber(limit) || parseInt(limit) <= 0) { return Q.reject(); } var cacheKey = Encryption.md5("MiaJSRateLimit" + key + _calculateCurrentTi...
javascript
function (key, timeInterval, limit) { //Validate rate limiter settings if (!_.isNumber(timeInterval) || parseInt(timeInterval) <= 0 || !_.isNumber(limit) || parseInt(limit) <= 0) { return Q.reject(); } var cacheKey = Encryption.md5("MiaJSRateLimit" + key + _calculateCurrentTi...
[ "function", "(", "key", ",", "timeInterval", ",", "limit", ")", "{", "//Validate rate limiter settings", "if", "(", "!", "_", ".", "isNumber", "(", "timeInterval", ")", "||", "parseInt", "(", "timeInterval", ")", "<=", "0", "||", "!", "_", ".", "isNumber",...
Check global rate limits per ip
[ "Check", "global", "rate", "limits", "per", "ip" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/rateLimiter/lib/rateLimiter.js#L27-L41
train
mia-js/mia-js-core
lib/rateLimiter/lib/rateLimiter.js
function (key, intervalSize, limit) { var deferred = Q.defer() , memcached = Shared.memcached(); if (!memcached) { deferred.reject(); } else { //Get current rate for ip memcached.get(key, function (err, value) { if (err) { ...
javascript
function (key, intervalSize, limit) { var deferred = Q.defer() , memcached = Shared.memcached(); if (!memcached) { deferred.reject(); } else { //Get current rate for ip memcached.get(key, function (err, value) { if (err) { ...
[ "function", "(", "key", ",", "intervalSize", ",", "limit", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ",", "memcached", "=", "Shared", ".", "memcached", "(", ")", ";", "if", "(", "!", "memcached", ")", "{", "deferred", ".", "rej...
Validate and increase current rate limit in memcache
[ "Validate", "and", "increase", "current", "rate", "limit", "in", "memcache" ]
77c976a72382fd0edef1144f9bea47d8c175c26b
https://github.com/mia-js/mia-js-core/blob/77c976a72382fd0edef1144f9bea47d8c175c26b/lib/rateLimiter/lib/rateLimiter.js#L44-L81
train
jbaicoianu/elation
components/utils/scripts/jit.js
function(e, win) { var event = $.event.get(e, win); var wheel = $.event.getWheel(event); that.handleEvent('MouseWheel', e, win, wheel); }
javascript
function(e, win) { var event = $.event.get(e, win); var wheel = $.event.getWheel(event); that.handleEvent('MouseWheel', e, win, wheel); }
[ "function", "(", "e", ",", "win", ")", "{", "var", "event", "=", "$", ".", "event", ".", "get", "(", "e", ",", "win", ")", ";", "var", "wheel", "=", "$", ".", "event", ".", "getWheel", "(", "event", ")", ";", "that", ".", "handleEvent", "(", ...
attach mousewheel event
[ "attach", "mousewheel", "event" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/scripts/jit.js#L2037-L2041
train
jbaicoianu/elation
components/utils/scripts/jit.js
$E
function $E(tag, props) { var elem = document.createElement(tag); for(var p in props) { if(typeof props[p] == "object") { $.extend(elem[p], props[p]); } else { elem[p] = props[p]; } } if (tag == "canvas" && !supportsCanvas && G_vmlCanvasManager) { elem = G_vmlCanv...
javascript
function $E(tag, props) { var elem = document.createElement(tag); for(var p in props) { if(typeof props[p] == "object") { $.extend(elem[p], props[p]); } else { elem[p] = props[p]; } } if (tag == "canvas" && !supportsCanvas && G_vmlCanvasManager) { elem = G_vmlCanv...
[ "function", "$E", "(", "tag", ",", "props", ")", "{", "var", "elem", "=", "document", ".", "createElement", "(", "tag", ")", ";", "for", "(", "var", "p", "in", "props", ")", "{", "if", "(", "typeof", "props", "[", "p", "]", "==", "\"object\"", ")...
create element function
[ "create", "element", "function" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/scripts/jit.js#L2719-L2732
train
jbaicoianu/elation
components/utils/scripts/jit.js
getNodesToHide
function getNodesToHide(node) { node = node || this.clickedNode; if(!this.config.constrained) { return []; } var Geom = this.geom; var graph = this.graph; var canvas = this.canvas; var level = node._depth, nodeArray = []; graph.eachNode(function(n) { if(n...
javascript
function getNodesToHide(node) { node = node || this.clickedNode; if(!this.config.constrained) { return []; } var Geom = this.geom; var graph = this.graph; var canvas = this.canvas; var level = node._depth, nodeArray = []; graph.eachNode(function(n) { if(n...
[ "function", "getNodesToHide", "(", "node", ")", "{", "node", "=", "node", "||", "this", ".", "clickedNode", ";", "if", "(", "!", "this", ".", "config", ".", "constrained", ")", "{", "return", "[", "]", ";", "}", "var", "Geom", "=", "this", ".", "ge...
Nodes to contract
[ "Nodes", "to", "contract" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/scripts/jit.js#L8113-L8143
train
jbaicoianu/elation
components/utils/scripts/jit.js
getNodesToShow
function getNodesToShow(node) { var nodeArray = [], config = this.config; node = node || this.clickedNode; this.clickedNode.eachLevel(0, config.levelsToShow, function(n) { if(config.multitree && !('$orn' in n.data) && n.anySubnode(function(ch){ return ch.exist && !ch.d...
javascript
function getNodesToShow(node) { var nodeArray = [], config = this.config; node = node || this.clickedNode; this.clickedNode.eachLevel(0, config.levelsToShow, function(n) { if(config.multitree && !('$orn' in n.data) && n.anySubnode(function(ch){ return ch.exist && !ch.d...
[ "function", "getNodesToShow", "(", "node", ")", "{", "var", "nodeArray", "=", "[", "]", ",", "config", "=", "this", ".", "config", ";", "node", "=", "node", "||", "this", ".", "clickedNode", ";", "this", ".", "clickedNode", ".", "eachLevel", "(", "0", ...
Nodes to expand
[ "Nodes", "to", "expand" ]
5fb8824d8b7150c463daf2fe99c31716c6e8812f
https://github.com/jbaicoianu/elation/blob/5fb8824d8b7150c463daf2fe99c31716c6e8812f/components/utils/scripts/jit.js#L8145-L8157
train
primus/substream
substream.js
SubStream
function SubStream(stream, name, options) { if (!(this instanceof SubStream)) return new SubStream(stream, name, options); options = options || {}; this.readyState = stream.readyState; // Copy the current readyState. this.stream = stream; // The underlaying stream. this.name = nam...
javascript
function SubStream(stream, name, options) { if (!(this instanceof SubStream)) return new SubStream(stream, name, options); options = options || {}; this.readyState = stream.readyState; // Copy the current readyState. this.stream = stream; // The underlaying stream. this.name = nam...
[ "function", "SubStream", "(", "stream", ",", "name", ",", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "SubStream", ")", ")", "return", "new", "SubStream", "(", "stream", ",", "name", ",", "options", ")", ";", "options", "=", "option...
Streams provides a streaming, namespaced interface on top of a regular stream. Options: - proxy: Array of addition events that need to be re-emitted. @constructor @param {Stream} stream The stream that needs we're streaming over. @param {String} name The name of our stream. @param {object} options SubStream configur...
[ "Streams", "provides", "a", "streaming", "namespaced", "interface", "on", "top", "of", "a", "regular", "stream", "." ]
626792b746e1dc90b67a81045f442ee1f584c0ec
https://github.com/primus/substream/blob/626792b746e1dc90b67a81045f442ee1f584c0ec/substream.js#L25-L53
train
mozilla-jetpack/node-fx-runner
lib/utils.js
fallBack
function fallBack () { var programFilesVar = "ProgramFiles"; if (arch === "(64)") { console.warn("You are using 32-bit version of Firefox on 64-bit versions of the Windows.\nSome features may not work correctly in this version. You should upgrade Firefox to the latest 64-bit version now!") p...
javascript
function fallBack () { var programFilesVar = "ProgramFiles"; if (arch === "(64)") { console.warn("You are using 32-bit version of Firefox on 64-bit versions of the Windows.\nSome features may not work correctly in this version. You should upgrade Firefox to the latest 64-bit version now!") p...
[ "function", "fallBack", "(", ")", "{", "var", "programFilesVar", "=", "\"ProgramFiles\"", ";", "if", "(", "arch", "===", "\"(64)\"", ")", "{", "console", ".", "warn", "(", "\"You are using 32-bit version of Firefox on 64-bit versions of the Windows.\\nSome features may not ...
this is used when reading the registry goes wrong.
[ "this", "is", "used", "when", "reading", "the", "registry", "goes", "wrong", "." ]
71e3848b6adac1054829391c826fd88cfb28f621
https://github.com/mozilla-jetpack/node-fx-runner/blob/71e3848b6adac1054829391c826fd88cfb28f621/lib/utils.js#L74-L81
train
primus/substream
index.js
listen
function listen(event, spark) { if ('end' === event) return function end() { if (!spark.streams) return; for (var stream in spark.streams) { stream = spark.streams[stream]; if (stream.end) stream.end(); } }; if ('readyStateChange' === event) return function change(reason)...
javascript
function listen(event, spark) { if ('end' === event) return function end() { if (!spark.streams) return; for (var stream in spark.streams) { stream = spark.streams[stream]; if (stream.end) stream.end(); } }; if ('readyStateChange' === event) return function change(reason)...
[ "function", "listen", "(", "event", ",", "spark", ")", "{", "if", "(", "'end'", "===", "event", ")", "return", "function", "end", "(", ")", "{", "if", "(", "!", "spark", ".", "streams", ")", "return", ";", "for", "(", "var", "stream", "in", "spark"...
Return a preconfigured listener. @param {String} event Name of the event. @returns {Function} listener @api private
[ "Return", "a", "preconfigured", "listener", "." ]
626792b746e1dc90b67a81045f442ee1f584c0ec
https://github.com/primus/substream/blob/626792b746e1dc90b67a81045f442ee1f584c0ec/index.js#L25-L54
train
globality-corp/nodule-logging
src/logger.js
createLoggerStream
function createLoggerStream(name, level, logglyConfig) { const streams = [process.stdout]; if (logglyConfig.enabled) { const logglyStream = new LogglyStream({ token: logglyConfig.token, subdomain: logglyConfig.subdomain, name, environment: logglyConfig.env...
javascript
function createLoggerStream(name, level, logglyConfig) { const streams = [process.stdout]; if (logglyConfig.enabled) { const logglyStream = new LogglyStream({ token: logglyConfig.token, subdomain: logglyConfig.subdomain, name, environment: logglyConfig.env...
[ "function", "createLoggerStream", "(", "name", ",", "level", ",", "logglyConfig", ")", "{", "const", "streams", "=", "[", "process", ".", "stdout", "]", ";", "if", "(", "logglyConfig", ".", "enabled", ")", "{", "const", "logglyStream", "=", "new", "LogglyS...
singleton to create a logging instance based on config
[ "singleton", "to", "create", "a", "logging", "instance", "based", "on", "config" ]
5283de6c8bf8a2866f377aa82eca80bc3b30a5c3
https://github.com/globality-corp/nodule-logging/blob/5283de6c8bf8a2866f377aa82eca80bc3b30a5c3/src/logger.js#L16-L28
train
wikimedia/restbase-mod-table-cassandra
lib/schemaMigration.js
confChanged
function confChanged(current, proposed) { if (stringify(current.conf) !== stringify(proposed.conf)) { if (current.version >= proposed.version) { const e = new Error('Schema change, but no version increment.'); e.current = current; e.proposed = proposed; throw ...
javascript
function confChanged(current, proposed) { if (stringify(current.conf) !== stringify(proposed.conf)) { if (current.version >= proposed.version) { const e = new Error('Schema change, but no version increment.'); e.current = current; e.proposed = proposed; throw ...
[ "function", "confChanged", "(", "current", ",", "proposed", ")", "{", "if", "(", "stringify", "(", "current", ".", "conf", ")", "!==", "stringify", "(", "proposed", ".", "conf", ")", ")", "{", "if", "(", "current", ".", "version", ">=", "proposed", "."...
Check if a schema part differs, and if it does, if the version was incremented. @param {Object} current { conf: {object}, version: {number} } @param {Object} proposed { conf: {object}, version: {number} } @return {boolean} Whether the attribute has changed. @throws {Error} If the schema fragment changed, but the versio...
[ "Check", "if", "a", "schema", "part", "differs", "and", "if", "it", "does", "if", "the", "version", "was", "incremented", "." ]
f226a4bd1c75a31243a895d1106bf8ccd643113a
https://github.com/wikimedia/restbase-mod-table-cassandra/blob/f226a4bd1c75a31243a895d1106bf8ccd643113a/lib/schemaMigration.js#L16-L28
train
globality-corp/nodule-logging
src/logFormatting.js
validatePropertyType
function validatePropertyType(property, type, recursive) { return type && ( (recursive && typeof property === 'object') || (type === 'string' && typeof property === 'string') || (type === 'number' && typeof property === 'number') || (type === 'uuid' && isUuid(property)) || (t...
javascript
function validatePropertyType(property, type, recursive) { return type && ( (recursive && typeof property === 'object') || (type === 'string' && typeof property === 'string') || (type === 'number' && typeof property === 'number') || (type === 'uuid' && isUuid(property)) || (t...
[ "function", "validatePropertyType", "(", "property", ",", "type", ",", "recursive", ")", "{", "return", "type", "&&", "(", "(", "recursive", "&&", "typeof", "property", "===", "'object'", ")", "||", "(", "type", "===", "'string'", "&&", "typeof", "property",...
Helper function to parseObject
[ "Helper", "function", "to", "parseObject" ]
5283de6c8bf8a2866f377aa82eca80bc3b30a5c3
https://github.com/globality-corp/nodule-logging/blob/5283de6c8bf8a2866f377aa82eca80bc3b30a5c3/src/logFormatting.js#L44-L52
train
globality-corp/nodule-logging
src/logFormatting.js
parseObject
function parseObject(obj, { name, path, subPaths, type, recursive = true, ...args }) { let property = get(obj, path); if (property === null || !validatePropertyType(property, type, recursive)) { return []; } if (type === 'uuidList' && isUuidList(property)) { return [{ [name]: property.sp...
javascript
function parseObject(obj, { name, path, subPaths, type, recursive = true, ...args }) { let property = get(obj, path); if (property === null || !validatePropertyType(property, type, recursive)) { return []; } if (type === 'uuidList' && isUuidList(property)) { return [{ [name]: property.sp...
[ "function", "parseObject", "(", "obj", ",", "{", "name", ",", "path", ",", "subPaths", ",", "type", ",", "recursive", "=", "true", ",", "...", "args", "}", ")", "{", "let", "property", "=", "get", "(", "obj", ",", "path", ")", ";", "if", "(", "pr...
Helper function to extractLoggingProperties Parse rules and return an array of properties to log
[ "Helper", "function", "to", "extractLoggingProperties", "Parse", "rules", "and", "return", "an", "array", "of", "properties", "to", "log" ]
5283de6c8bf8a2866f377aa82eca80bc3b30a5c3
https://github.com/globality-corp/nodule-logging/blob/5283de6c8bf8a2866f377aa82eca80bc3b30a5c3/src/logFormatting.js#L57-L87
train
maurelian/eth-registrar-ens
src/index.js
Entry
function Entry(name, hash, status, mode, deed, registrationDate, value, highestBid) { // TODO: improve Entry constructor so that unknown names can be handled via getEntry this.name = name; this.hash = hash; this.status = status; this.mode = mode; this.deed = deed; this.registrationDate = registrationDate;...
javascript
function Entry(name, hash, status, mode, deed, registrationDate, value, highestBid) { // TODO: improve Entry constructor so that unknown names can be handled via getEntry this.name = name; this.hash = hash; this.status = status; this.mode = mode; this.deed = deed; this.registrationDate = registrationDate;...
[ "function", "Entry", "(", "name", ",", "hash", ",", "status", ",", "mode", ",", "deed", ",", "registrationDate", ",", "value", ",", "highestBid", ")", "{", "// TODO: improve Entry constructor so that unknown names can be handled via getEntry", "this", ".", "name", "="...
Constructs a new Entry object corresponding to a name. @ignore @param {string} name The unhashed name @param {string} hash @param {number} status @param {address} deed @param {number} registrationDate @param {number} value @param {number} highestBid
[ "Constructs", "a", "new", "Entry", "object", "corresponding", "to", "a", "name", "." ]
a70baba4de1bcbdb8479f84e1ac694bd670349d5
https://github.com/maurelian/eth-registrar-ens/blob/a70baba4de1bcbdb8479f84e1ac694bd670349d5/src/index.js#L131-L141
train
globality-corp/nodule-logging
src/middleware.js
skip
function skip(ignoreRouteUrls) { return function ignoreUrl(req) { const url = req.originalUrl || req.url; return ignoreRouteUrls.includes(url); }; }
javascript
function skip(ignoreRouteUrls) { return function ignoreUrl(req) { const url = req.originalUrl || req.url; return ignoreRouteUrls.includes(url); }; }
[ "function", "skip", "(", "ignoreRouteUrls", ")", "{", "return", "function", "ignoreUrl", "(", "req", ")", "{", "const", "url", "=", "req", ".", "originalUrl", "||", "req", ".", "url", ";", "return", "ignoreRouteUrls", ".", "includes", "(", "url", ")", ";...
exclude any health or other ignorable urls
[ "exclude", "any", "health", "or", "other", "ignorable", "urls" ]
5283de6c8bf8a2866f377aa82eca80bc3b30a5c3
https://github.com/globality-corp/nodule-logging/blob/5283de6c8bf8a2866f377aa82eca80bc3b30a5c3/src/middleware.js#L9-L14
train
globality-corp/nodule-logging
src/middleware.js
omit
function omit(req, blacklist) { return omitBy(req, (value, key) => blacklist.includes(key)); }
javascript
function omit(req, blacklist) { return omitBy(req, (value, key) => blacklist.includes(key)); }
[ "function", "omit", "(", "req", ",", "blacklist", ")", "{", "return", "omitBy", "(", "req", ",", "(", "value", ",", "key", ")", "=>", "blacklist", ".", "includes", "(", "key", ")", ")", ";", "}" ]
filter out named properties from req object
[ "filter", "out", "named", "properties", "from", "req", "object" ]
5283de6c8bf8a2866f377aa82eca80bc3b30a5c3
https://github.com/globality-corp/nodule-logging/blob/5283de6c8bf8a2866f377aa82eca80bc3b30a5c3/src/middleware.js#L28-L30
train
globality-corp/nodule-logging
src/middleware.js
morganMiddleware
function morganMiddleware(req, res, next) { const { ignoreRouteUrls, includeReqHeaders, omitReqProperties } = getConfig('logger'); const { format } = getConfig('logger.morgan'); // define custom tokens morgan.token('operation-hash', request => get(request, 'body.extensions.persistentQuery.sha256Hash'));...
javascript
function morganMiddleware(req, res, next) { const { ignoreRouteUrls, includeReqHeaders, omitReqProperties } = getConfig('logger'); const { format } = getConfig('logger.morgan'); // define custom tokens morgan.token('operation-hash', request => get(request, 'body.extensions.persistentQuery.sha256Hash'));...
[ "function", "morganMiddleware", "(", "req", ",", "res", ",", "next", ")", "{", "const", "{", "ignoreRouteUrls", ",", "includeReqHeaders", ",", "omitReqProperties", "}", "=", "getConfig", "(", "'logger'", ")", ";", "const", "{", "format", "}", "=", "getConfig...
Use morgan library to log every HTTP response Also set req._startAt - that is used by the logger
[ "Use", "morgan", "library", "to", "log", "every", "HTTP", "response", "Also", "set", "req", ".", "_startAt", "-", "that", "is", "used", "by", "the", "logger" ]
5283de6c8bf8a2866f377aa82eca80bc3b30a5c3
https://github.com/globality-corp/nodule-logging/blob/5283de6c8bf8a2866f377aa82eca80bc3b30a5c3/src/middleware.js#L40-L63
train
wikimedia/restbase-mod-table-cassandra
maintenance/lib/index.js
getConfig
function getConfig(config) { // Read a RESTBase configuration from a (optional) path argument, an (optional) CONFIG // env var, or from /etc/restbase/config.yaml var conf; if (config) { conf = config; } else if (process.env.CONFIG) { conf = process.env.CONFIG; } else { c...
javascript
function getConfig(config) { // Read a RESTBase configuration from a (optional) path argument, an (optional) CONFIG // env var, or from /etc/restbase/config.yaml var conf; if (config) { conf = config; } else if (process.env.CONFIG) { conf = process.env.CONFIG; } else { c...
[ "function", "getConfig", "(", "config", ")", "{", "// Read a RESTBase configuration from a (optional) path argument, an (optional) CONFIG", "// env var, or from /etc/restbase/config.yaml", "var", "conf", ";", "if", "(", "config", ")", "{", "conf", "=", "config", ";", "}", "...
Return the table section of a RESTBase config. @param {string} config - Path to a RESTBase YAML configuration file. @return {Object} table section of configuration.
[ "Return", "the", "table", "section", "of", "a", "RESTBase", "config", "." ]
f226a4bd1c75a31243a895d1106bf8ccd643113a
https://github.com/wikimedia/restbase-mod-table-cassandra/blob/f226a4bd1c75a31243a895d1106bf8ccd643113a/maintenance/lib/index.js#L12-L27
train
jsrmath/sharp11
lib/note.js
function (name) { var octave = null; name = prepareNoteName(name); // Extract octave number if given if (/\d$/.test(name)) { octave = parseInt(name.slice(-1)); name = name.slice(0, -1); } // Throw an error for an invalid note name if (!(/^[A-Ga-g](bb|##|[b#n])?$/).test(name)) { throw new E...
javascript
function (name) { var octave = null; name = prepareNoteName(name); // Extract octave number if given if (/\d$/.test(name)) { octave = parseInt(name.slice(-1)); name = name.slice(0, -1); } // Throw an error for an invalid note name if (!(/^[A-Ga-g](bb|##|[b#n])?$/).test(name)) { throw new E...
[ "function", "(", "name", ")", "{", "var", "octave", "=", "null", ";", "name", "=", "prepareNoteName", "(", "name", ")", ";", "// Extract octave number if given", "if", "(", "/", "\\d$", "/", ".", "test", "(", "name", ")", ")", "{", "octave", "=", "pars...
Parse a note name and return object with letter, accidental
[ "Parse", "a", "note", "name", "and", "return", "object", "with", "letter", "accidental" ]
4f5857c40535b1bccc102ffdcc42a086e213016a
https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/note.js#L37-L58
train
jsrmath/sharp11
lib/note.js
function (note, number) { var letter = note.letter; var index = scale.indexOf(note.letter); var newIndex = mod(index + number - 1, scale.length); assert(index > -1); assert(newIndex > -1 && newIndex < scale.length); return scale[newIndex]; }
javascript
function (note, number) { var letter = note.letter; var index = scale.indexOf(note.letter); var newIndex = mod(index + number - 1, scale.length); assert(index > -1); assert(newIndex > -1 && newIndex < scale.length); return scale[newIndex]; }
[ "function", "(", "note", ",", "number", ")", "{", "var", "letter", "=", "note", ".", "letter", ";", "var", "index", "=", "scale", ".", "indexOf", "(", "note", ".", "letter", ")", ";", "var", "newIndex", "=", "mod", "(", "index", "+", "number", "-",...
Increase the letter of a note by a given interval
[ "Increase", "the", "letter", "of", "a", "note", "by", "a", "given", "interval" ]
4f5857c40535b1bccc102ffdcc42a086e213016a
https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/note.js#L61-L70
train
jsrmath/sharp11
lib/note.js
function (letter1, letter2) { var index1 = scale.indexOf(letter1); var index2 = scale.indexOf(letter2); var distance = mod(index2 - index1, scale.length) + 1; assert(index1 > -1); assert(index2 > -1); assert(distance > 0 && distance <= scale.length); return distance; }
javascript
function (letter1, letter2) { var index1 = scale.indexOf(letter1); var index2 = scale.indexOf(letter2); var distance = mod(index2 - index1, scale.length) + 1; assert(index1 > -1); assert(index2 > -1); assert(distance > 0 && distance <= scale.length); return distance; }
[ "function", "(", "letter1", ",", "letter2", ")", "{", "var", "index1", "=", "scale", ".", "indexOf", "(", "letter1", ")", ";", "var", "index2", "=", "scale", ".", "indexOf", "(", "letter2", ")", ";", "var", "distance", "=", "mod", "(", "index2", "-",...
Find the interval number between two notes given their letters
[ "Find", "the", "interval", "number", "between", "two", "notes", "given", "their", "letters" ]
4f5857c40535b1bccc102ffdcc42a086e213016a
https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/note.js#L73-L83
train
jsrmath/sharp11
lib/note.js
function (int) { var map = interval.isPerfect(int.number) ? perfectOffsets : majorOffsets; var key = _.invert(map)[int.quality]; return parseInt(key, 10); }
javascript
function (int) { var map = interval.isPerfect(int.number) ? perfectOffsets : majorOffsets; var key = _.invert(map)[int.quality]; return parseInt(key, 10); }
[ "function", "(", "int", ")", "{", "var", "map", "=", "interval", ".", "isPerfect", "(", "int", ".", "number", ")", "?", "perfectOffsets", ":", "majorOffsets", ";", "var", "key", "=", "_", ".", "invert", "(", "map", ")", "[", "int", ".", "quality", ...
Find the number of half steps between interval and corresponding diatonic interval
[ "Find", "the", "number", "of", "half", "steps", "between", "interval", "and", "corresponding", "diatonic", "interval" ]
4f5857c40535b1bccc102ffdcc42a086e213016a
https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/note.js#L97-L102
train
jsrmath/sharp11
lib/note.js
function (number, halfSteps) { var diatonicHalfSteps = getDiatonicHalfSteps(number); var halfStepOffset = halfSteps - diatonicHalfSteps; // Handle various abnormalities if (halfStepOffset === 11) halfStepOffset = -1; if (halfStepOffset === -11) halfStepOffset = 1; return halfStepOffset; }
javascript
function (number, halfSteps) { var diatonicHalfSteps = getDiatonicHalfSteps(number); var halfStepOffset = halfSteps - diatonicHalfSteps; // Handle various abnormalities if (halfStepOffset === 11) halfStepOffset = -1; if (halfStepOffset === -11) halfStepOffset = 1; return halfStepOffset; }
[ "function", "(", "number", ",", "halfSteps", ")", "{", "var", "diatonicHalfSteps", "=", "getDiatonicHalfSteps", "(", "number", ")", ";", "var", "halfStepOffset", "=", "halfSteps", "-", "diatonicHalfSteps", ";", "// Handle various abnormalities", "if", "(", "halfStep...
Find the offset between
[ "Find", "the", "offset", "between" ]
4f5857c40535b1bccc102ffdcc42a086e213016a
https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/note.js#L105-L114
train