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
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
edertone/TurboCommons
TurboCommons-Java/.turboBuilder/Utils.js
echoWarningsAndErrors
function echoWarningsAndErrors(antWarnings, antErrors){ //Define the echo task to use for warnings and errors var echo = project.createTask("echo"); var error = new org.apache.tools.ant.taskdefs.Echo.EchoLevel(); error.setValue("error"); echo.setLevel(error); //Display all the detected warnings for(var i = 0; i < antWarnings.length; i++){ echo.setMessage("WARNING: " + antWarnings[i]); echo.perform(); } //Display all the detected errors for(i = 0; i < antErrors.length; i++){ echo.setMessage("ERROR: " + antErrors[i]); echo.perform(); } //Set a failure to the ant build if errors are present if(antErrors.length > 0){ project.setProperty("javascript.fail.message", "Source analisis detected errors."); } }
javascript
function echoWarningsAndErrors(antWarnings, antErrors){ //Define the echo task to use for warnings and errors var echo = project.createTask("echo"); var error = new org.apache.tools.ant.taskdefs.Echo.EchoLevel(); error.setValue("error"); echo.setLevel(error); //Display all the detected warnings for(var i = 0; i < antWarnings.length; i++){ echo.setMessage("WARNING: " + antWarnings[i]); echo.perform(); } //Display all the detected errors for(i = 0; i < antErrors.length; i++){ echo.setMessage("ERROR: " + antErrors[i]); echo.perform(); } //Set a failure to the ant build if errors are present if(antErrors.length > 0){ project.setProperty("javascript.fail.message", "Source analisis detected errors."); } }
[ "function", "echoWarningsAndErrors", "(", "antWarnings", ",", "antErrors", ")", "{", "var", "echo", "=", "project", ".", "createTask", "(", "\"echo\"", ")", ";", "var", "error", "=", "new", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "Echo", ".", "EchoLevel", "(", ")", ";", "error", ".", "setValue", "(", "\"error\"", ")", ";", "echo", ".", "setLevel", "(", "error", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "antWarnings", ".", "length", ";", "i", "++", ")", "{", "echo", ".", "setMessage", "(", "\"WARNING: \"", "+", "antWarnings", "[", "i", "]", ")", ";", "echo", ".", "perform", "(", ")", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "antErrors", ".", "length", ";", "i", "++", ")", "{", "echo", ".", "setMessage", "(", "\"ERROR: \"", "+", "antErrors", "[", "i", "]", ")", ";", "echo", ".", "perform", "(", ")", ";", "}", "if", "(", "antErrors", ".", "length", ">", "0", ")", "{", "project", ".", "setProperty", "(", "\"javascript.fail.message\"", ",", "\"Source analisis detected errors.\"", ")", ";", "}", "}" ]
Output to ant console the warnings and errors if exist
[ "Output", "to", "ant", "console", "the", "warnings", "and", "errors", "if", "exist" ]
275d4971ec19d8632b92ac466d9ce5b7db50acfa
https://github.com/edertone/TurboCommons/blob/275d4971ec19d8632b92ac466d9ce5b7db50acfa/TurboCommons-Java/.turboBuilder/Utils.js#L83-L110
train
jslicense/spdx-satisfies.js
index.js
flatten
function flatten (expression) { const expanded = Array.from(expandInner(expression)) const flattened = expanded.reduce(function (result, clause) { return Object.assign(result, clause) }, {}) return sort([flattened])[0] }
javascript
function flatten (expression) { const expanded = Array.from(expandInner(expression)) const flattened = expanded.reduce(function (result, clause) { return Object.assign(result, clause) }, {}) return sort([flattened])[0] }
[ "function", "flatten", "(", "expression", ")", "{", "const", "expanded", "=", "Array", ".", "from", "(", "expandInner", "(", "expression", ")", ")", "const", "flattened", "=", "expanded", ".", "reduce", "(", "function", "(", "result", ",", "clause", ")", "{", "return", "Object", ".", "assign", "(", "result", ",", "clause", ")", "}", ",", "{", "}", ")", "return", "sort", "(", "[", "flattened", "]", ")", "[", "0", "]", "}" ]
Flatten the given expression into an array of all licenses mentioned in the expression.
[ "Flatten", "the", "given", "expression", "into", "an", "array", "of", "all", "licenses", "mentioned", "in", "the", "expression", "." ]
a4d27d9711a333fecda4c9b83f0d549eb06d5dfc
https://github.com/jslicense/spdx-satisfies.js/blob/a4d27d9711a333fecda4c9b83f0d549eb06d5dfc/index.js#L96-L102
train
ArnaudBuchholz/gpf-js
src/factory.js
_gpfNewApply
function _gpfNewApply (Constructor, parameters) { if (parameters.length > _gpfGenericFactory.length) { _gpfGenericFactory = _gpfGenerateGenericFactory(parameters.length); } return _gpfGenericFactory.apply(Constructor, parameters); }
javascript
function _gpfNewApply (Constructor, parameters) { if (parameters.length > _gpfGenericFactory.length) { _gpfGenericFactory = _gpfGenerateGenericFactory(parameters.length); } return _gpfGenericFactory.apply(Constructor, parameters); }
[ "function", "_gpfNewApply", "(", "Constructor", ",", "parameters", ")", "{", "if", "(", "parameters", ".", "length", ">", "_gpfGenericFactory", ".", "length", ")", "{", "_gpfGenericFactory", "=", "_gpfGenerateGenericFactory", "(", "parameters", ".", "length", ")", ";", "}", "return", "_gpfGenericFactory", ".", "apply", "(", "Constructor", ",", "parameters", ")", ";", "}" ]
Call a constructor with an array of parameters. It is impossible to mix [new](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new) and [apply](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply) in the same call. This helper workarounds this problem. @param {Function} Constructor Class constructor @param {Array} parameters Parameters to pass to the constructor @return {Object} New object @since 0.1.5
[ "Call", "a", "constructor", "with", "an", "array", "of", "parameters", "." ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/factory.js#L70-L75
train
ArnaudBuchholz/gpf-js
src/error.js
function (context) { var replacements; if (context) { replacements = {}; _gpfObjectForEach(context, function (value, key) { replacements["{" + key + "}"] = value.toString(); }); this.message = _gpfStringReplaceEx(this.message, replacements); } }
javascript
function (context) { var replacements; if (context) { replacements = {}; _gpfObjectForEach(context, function (value, key) { replacements["{" + key + "}"] = value.toString(); }); this.message = _gpfStringReplaceEx(this.message, replacements); } }
[ "function", "(", "context", ")", "{", "var", "replacements", ";", "if", "(", "context", ")", "{", "replacements", "=", "{", "}", ";", "_gpfObjectForEach", "(", "context", ",", "function", "(", "value", ",", "key", ")", "{", "replacements", "[", "\"{\"", "+", "key", "+", "\"}\"", "]", "=", "value", ".", "toString", "(", ")", ";", "}", ")", ";", "this", ".", "message", "=", "_gpfStringReplaceEx", "(", "this", ".", "message", ",", "replacements", ")", ";", "}", "}" ]
Build message by substituting context variables @param {Object} context Dictionary of named keys @since 0.1.5
[ "Build", "message", "by", "substituting", "context", "variables" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/error.js#L59-L68
train
ArnaudBuchholz/gpf-js
src/error.js
_gpfGenenerateErrorFunction
function _gpfGenenerateErrorFunction (code, name, message) { var result = _gpfErrorFactory(code, name, message); result.CODE = code; result.NAME = name; result.MESSAGE = message; return result; }
javascript
function _gpfGenenerateErrorFunction (code, name, message) { var result = _gpfErrorFactory(code, name, message); result.CODE = code; result.NAME = name; result.MESSAGE = message; return result; }
[ "function", "_gpfGenenerateErrorFunction", "(", "code", ",", "name", ",", "message", ")", "{", "var", "result", "=", "_gpfErrorFactory", "(", "code", ",", "name", ",", "message", ")", ";", "result", ".", "CODE", "=", "code", ";", "result", ".", "NAME", "=", "name", ";", "result", ".", "MESSAGE", "=", "message", ";", "return", "result", ";", "}" ]
Generates an error class @param {Number} code Error code @param {String} name Error name @param {String} message Error message @return {Function} New error class @gpf:closure @since 0.1.5
[ "Generates", "an", "error", "class" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/error.js#L103-L109
train
ArnaudBuchholz/gpf-js
src/error.js
_gpfErrorDeclare
function _gpfErrorDeclare (source, dictionary) { _gpfIgnore(source); _gpfObjectForEach(dictionary, function (message, name) { var code = ++_gpfLastErrorCode; gpf.Error["CODE_" + name.toUpperCase()] = code; gpf.Error[name] = _gpfGenenerateErrorFunction(code, name, message); }); }
javascript
function _gpfErrorDeclare (source, dictionary) { _gpfIgnore(source); _gpfObjectForEach(dictionary, function (message, name) { var code = ++_gpfLastErrorCode; gpf.Error["CODE_" + name.toUpperCase()] = code; gpf.Error[name] = _gpfGenenerateErrorFunction(code, name, message); }); }
[ "function", "_gpfErrorDeclare", "(", "source", ",", "dictionary", ")", "{", "_gpfIgnore", "(", "source", ")", ";", "_gpfObjectForEach", "(", "dictionary", ",", "function", "(", "message", ",", "name", ")", "{", "var", "code", "=", "++", "_gpfLastErrorCode", ";", "gpf", ".", "Error", "[", "\"CODE_\"", "+", "name", ".", "toUpperCase", "(", ")", "]", "=", "code", ";", "gpf", ".", "Error", "[", "name", "]", "=", "_gpfGenenerateErrorFunction", "(", "code", ",", "name", ",", "message", ")", ";", "}", ")", ";", "}" ]
Declare error messages. Each source declares its own errors. @param {String} source Source name @param {Object} dictionary Dictionary of error name to message @since 0.1.5
[ "Declare", "error", "messages", ".", "Each", "source", "declares", "its", "own", "errors", "." ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/error.js#L122-L129
train
Esri/terraformer-geostore
src/helpers/browser/eventemitter.js
EventEmitter
function EventEmitter() { this._events = { }; this._once = { }; // default to 10 max liseners this._maxListeners = 10; this._add = function (event, listener, once) { var entry = { listener: listener }; if (once) { entry.once = true; } if (this._events[event]) { this._events[event].push(entry); } else { this._events[event] = [ entry ]; } if (this._maxListeners && this._events[event].count > this._maxListeners && console && console.warn) { console.warn("EventEmitter Error: Maximum number of listeners"); } return this; }; this.on = function (event, listener) { return this._add(event, listener); }; this.addListener = this.on; this.once = function (event, listener) { return this._add(event, listener, true); }; this.removeListener = function (event, listener) { if (!this._events[event]) { return this; } for(var i = this._events.length-1; i--;) { if (this._events[i].listener === callback) { this._events.splice(i, 1); } } return this; }; this.removeAllListeners = function (event) { this._events[event] = undefined; return this; }; this.setMaxListeners = function (count) { this._maxListeners = count; return this; }; this.emit = function () { var args = Array.prototype.slice.apply(arguments); var remove = [ ], i; if (args.length) { var event = args.shift(); if (this._events[event]) { for (i = this._events[event].length; i--;) { this._events[event][i].listener.apply(null, args); if (this._events[event][i].once) { remove.push(listener); } } } for (i = remove.length; i--;) { this.removeListener(event, remove[i]); } } return this; }; }
javascript
function EventEmitter() { this._events = { }; this._once = { }; // default to 10 max liseners this._maxListeners = 10; this._add = function (event, listener, once) { var entry = { listener: listener }; if (once) { entry.once = true; } if (this._events[event]) { this._events[event].push(entry); } else { this._events[event] = [ entry ]; } if (this._maxListeners && this._events[event].count > this._maxListeners && console && console.warn) { console.warn("EventEmitter Error: Maximum number of listeners"); } return this; }; this.on = function (event, listener) { return this._add(event, listener); }; this.addListener = this.on; this.once = function (event, listener) { return this._add(event, listener, true); }; this.removeListener = function (event, listener) { if (!this._events[event]) { return this; } for(var i = this._events.length-1; i--;) { if (this._events[i].listener === callback) { this._events.splice(i, 1); } } return this; }; this.removeAllListeners = function (event) { this._events[event] = undefined; return this; }; this.setMaxListeners = function (count) { this._maxListeners = count; return this; }; this.emit = function () { var args = Array.prototype.slice.apply(arguments); var remove = [ ], i; if (args.length) { var event = args.shift(); if (this._events[event]) { for (i = this._events[event].length; i--;) { this._events[event][i].listener.apply(null, args); if (this._events[event][i].once) { remove.push(listener); } } } for (i = remove.length; i--;) { this.removeListener(event, remove[i]); } } return this; }; }
[ "function", "EventEmitter", "(", ")", "{", "this", ".", "_events", "=", "{", "}", ";", "this", ".", "_once", "=", "{", "}", ";", "this", ".", "_maxListeners", "=", "10", ";", "this", ".", "_add", "=", "function", "(", "event", ",", "listener", ",", "once", ")", "{", "var", "entry", "=", "{", "listener", ":", "listener", "}", ";", "if", "(", "once", ")", "{", "entry", ".", "once", "=", "true", ";", "}", "if", "(", "this", ".", "_events", "[", "event", "]", ")", "{", "this", ".", "_events", "[", "event", "]", ".", "push", "(", "entry", ")", ";", "}", "else", "{", "this", ".", "_events", "[", "event", "]", "=", "[", "entry", "]", ";", "}", "if", "(", "this", ".", "_maxListeners", "&&", "this", ".", "_events", "[", "event", "]", ".", "count", ">", "this", ".", "_maxListeners", "&&", "console", "&&", "console", ".", "warn", ")", "{", "console", ".", "warn", "(", "\"EventEmitter Error: Maximum number of listeners\"", ")", ";", "}", "return", "this", ";", "}", ";", "this", ".", "on", "=", "function", "(", "event", ",", "listener", ")", "{", "return", "this", ".", "_add", "(", "event", ",", "listener", ")", ";", "}", ";", "this", ".", "addListener", "=", "this", ".", "on", ";", "this", ".", "once", "=", "function", "(", "event", ",", "listener", ")", "{", "return", "this", ".", "_add", "(", "event", ",", "listener", ",", "true", ")", ";", "}", ";", "this", ".", "removeListener", "=", "function", "(", "event", ",", "listener", ")", "{", "if", "(", "!", "this", ".", "_events", "[", "event", "]", ")", "{", "return", "this", ";", "}", "for", "(", "var", "i", "=", "this", ".", "_events", ".", "length", "-", "1", ";", "i", "--", ";", ")", "{", "if", "(", "this", ".", "_events", "[", "i", "]", ".", "listener", "===", "callback", ")", "{", "this", ".", "_events", ".", "splice", "(", "i", ",", "1", ")", ";", "}", "}", "return", "this", ";", "}", ";", "this", ".", "removeAllListeners", "=", "function", "(", "event", ")", "{", "this", ".", "_events", "[", "event", "]", "=", "undefined", ";", "return", "this", ";", "}", ";", "this", ".", "setMaxListeners", "=", "function", "(", "count", ")", "{", "this", ".", "_maxListeners", "=", "count", ";", "return", "this", ";", "}", ";", "this", ".", "emit", "=", "function", "(", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "apply", "(", "arguments", ")", ";", "var", "remove", "=", "[", "]", ",", "i", ";", "if", "(", "args", ".", "length", ")", "{", "var", "event", "=", "args", ".", "shift", "(", ")", ";", "if", "(", "this", ".", "_events", "[", "event", "]", ")", "{", "for", "(", "i", "=", "this", ".", "_events", "[", "event", "]", ".", "length", ";", "i", "--", ";", ")", "{", "this", ".", "_events", "[", "event", "]", "[", "i", "]", ".", "listener", ".", "apply", "(", "null", ",", "args", ")", ";", "if", "(", "this", ".", "_events", "[", "event", "]", "[", "i", "]", ".", "once", ")", "{", "remove", ".", "push", "(", "listener", ")", ";", "}", "}", "}", "for", "(", "i", "=", "remove", ".", "length", ";", "i", "--", ";", ")", "{", "this", ".", "removeListener", "(", "event", ",", "remove", "[", "i", "]", ")", ";", "}", "}", "return", "this", ";", "}", ";", "}" ]
super light weight EventEmitter implementation
[ "super", "light", "weight", "EventEmitter", "implementation" ]
0226a88e570dafcbf185d598eafd9de3f8f27213
https://github.com/Esri/terraformer-geostore/blob/0226a88e570dafcbf185d598eafd9de3f8f27213/src/helpers/browser/eventemitter.js#L3-L87
train
ArnaudBuchholz/gpf-js
src/attributes/check.js
_gpfAttributesCheckAppliedOnBaseClass
function _gpfAttributesCheckAppliedOnBaseClass (classDefinition, ExpectedBaseClass) { var Extend = classDefinition._extend; if (Extend !== ExpectedBaseClass) { _gpfAttributesCheckAppliedOnBaseClassIsInstanceOf(Extend.prototype, ExpectedBaseClass); } }
javascript
function _gpfAttributesCheckAppliedOnBaseClass (classDefinition, ExpectedBaseClass) { var Extend = classDefinition._extend; if (Extend !== ExpectedBaseClass) { _gpfAttributesCheckAppliedOnBaseClassIsInstanceOf(Extend.prototype, ExpectedBaseClass); } }
[ "function", "_gpfAttributesCheckAppliedOnBaseClass", "(", "classDefinition", ",", "ExpectedBaseClass", ")", "{", "var", "Extend", "=", "classDefinition", ".", "_extend", ";", "if", "(", "Extend", "!==", "ExpectedBaseClass", ")", "{", "_gpfAttributesCheckAppliedOnBaseClassIsInstanceOf", "(", "Extend", ".", "prototype", ",", "ExpectedBaseClass", ")", ";", "}", "}" ]
Ensures attribute is applied on a specific base class @param {_GpfClassDefinition} classDefinition Class definition @param {Function} ExpectedBaseClass Expected base class @throws {gpf.Error.RestrictedBaseClassAttribute} @since 0.2.8
[ "Ensures", "attribute", "is", "applied", "on", "a", "specific", "base", "class" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/attributes/check.js#L108-L113
train
ArnaudBuchholz/gpf-js
src/attributes/check.js
_gpfAttributesCheckAppliedOnlyOnce
function _gpfAttributesCheckAppliedOnlyOnce (member, classDefinition, AttributeClass) { var attributes = _gpfAttributesCheckGetMemberAttributes(member, classDefinition, AttributeClass); if (_gpfArrayTail(attributes).length) { gpf.Error.uniqueAttributeUsedTwice(); } }
javascript
function _gpfAttributesCheckAppliedOnlyOnce (member, classDefinition, AttributeClass) { var attributes = _gpfAttributesCheckGetMemberAttributes(member, classDefinition, AttributeClass); if (_gpfArrayTail(attributes).length) { gpf.Error.uniqueAttributeUsedTwice(); } }
[ "function", "_gpfAttributesCheckAppliedOnlyOnce", "(", "member", ",", "classDefinition", ",", "AttributeClass", ")", "{", "var", "attributes", "=", "_gpfAttributesCheckGetMemberAttributes", "(", "member", ",", "classDefinition", ",", "AttributeClass", ")", ";", "if", "(", "_gpfArrayTail", "(", "attributes", ")", ".", "length", ")", "{", "gpf", ".", "Error", ".", "uniqueAttributeUsedTwice", "(", ")", ";", "}", "}" ]
Ensures attribute is used only once @param {String} member Member name or empty if global to the class @param {_GpfClassDefinition} classDefinition Class definition @param {Function} AttributeClass Attribute class @throws {gpf.Error.UniqueAttributeUsedTwice} @since 0.2.8
[ "Ensures", "attribute", "is", "used", "only", "once" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/attributes/check.js#L132-L137
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/definition/member.js
_GpfClassDefMember
function _GpfClassDefMember (name, defaultValue, type) { /*jshint validthis:true*/ // constructor this._name = name; this._setDefaultValue(defaultValue); this._setType(type || "undefined"); }
javascript
function _GpfClassDefMember (name, defaultValue, type) { /*jshint validthis:true*/ // constructor this._name = name; this._setDefaultValue(defaultValue); this._setType(type || "undefined"); }
[ "function", "_GpfClassDefMember", "(", "name", ",", "defaultValue", ",", "type", ")", "{", "this", ".", "_name", "=", "name", ";", "this", ".", "_setDefaultValue", "(", "defaultValue", ")", ";", "this", ".", "_setType", "(", "type", "||", "\"undefined\"", ")", ";", "}" ]
Class member definition - Contains a reference to the class definition where the member is defined - Owns the name, the default value and a reference type @param {String} name Member name @param {*} defaultValue Member default / initial value @param {String} [type=typeof defaultValue] type Member type @class
[ "Class", "member", "definition", "-", "Contains", "a", "reference", "to", "the", "class", "definition", "where", "the", "member", "is", "defined", "-", "Owns", "the", "name", "the", "default", "value", "and", "a", "reference", "type" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/definition/member.js#L25-L30
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/definition/class.js
function (member) { _gpfAsserts({ "Expected a _GpfClassDefMember": member instanceof _GpfClassDefMember, "Member is already assigned to a class": null === member._classDef }); this._checkMemberBeforeAdd(member); this._members[member.getName()] = member; member._classDef = this; return this; }
javascript
function (member) { _gpfAsserts({ "Expected a _GpfClassDefMember": member instanceof _GpfClassDefMember, "Member is already assigned to a class": null === member._classDef }); this._checkMemberBeforeAdd(member); this._members[member.getName()] = member; member._classDef = this; return this; }
[ "function", "(", "member", ")", "{", "_gpfAsserts", "(", "{", "\"Expected a _GpfClassDefMember\"", ":", "member", "instanceof", "_GpfClassDefMember", ",", "\"Member is already assigned to a class\"", ":", "null", "===", "member", ".", "_classDef", "}", ")", ";", "this", ".", "_checkMemberBeforeAdd", "(", "member", ")", ";", "this", ".", "_members", "[", "member", ".", "getName", "(", ")", "]", "=", "member", ";", "member", ".", "_classDef", "=", "this", ";", "return", "this", ";", "}" ]
Add a member @param {_GpfClassDefMember} member Member to add @gpf:chainable
[ "Add", "a", "member" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/definition/class.js#L152-L161
train
SockDrawer/SockBot
lib/utils.js
mergeInner
function mergeInner(base, mixin, mergeArrays) { if (base === null || typeof base !== 'object' || Array.isArray(base)) { throw new Error('base must be object'); } if (mixin === null || typeof mixin !== 'object' || Array.isArray(mixin)) { throw new Error('mixin must be object'); } Object.keys(mixin).forEach((name) => { mergeHelper(base, mixin, name, mergeArrays); }); }
javascript
function mergeInner(base, mixin, mergeArrays) { if (base === null || typeof base !== 'object' || Array.isArray(base)) { throw new Error('base must be object'); } if (mixin === null || typeof mixin !== 'object' || Array.isArray(mixin)) { throw new Error('mixin must be object'); } Object.keys(mixin).forEach((name) => { mergeHelper(base, mixin, name, mergeArrays); }); }
[ "function", "mergeInner", "(", "base", ",", "mixin", ",", "mergeArrays", ")", "{", "if", "(", "base", "===", "null", "||", "typeof", "base", "!==", "'object'", "||", "Array", ".", "isArray", "(", "base", ")", ")", "{", "throw", "new", "Error", "(", "'base must be object'", ")", ";", "}", "if", "(", "mixin", "===", "null", "||", "typeof", "mixin", "!==", "'object'", "||", "Array", ".", "isArray", "(", "mixin", ")", ")", "{", "throw", "new", "Error", "(", "'mixin must be object'", ")", ";", "}", "Object", ".", "keys", "(", "mixin", ")", ".", "forEach", "(", "(", "name", ")", "=>", "{", "mergeHelper", "(", "base", ",", "mixin", ",", "name", ",", "mergeArrays", ")", ";", "}", ")", ";", "}" ]
Recursively merge objects @param {object} base Base object to merge `mixin` into @param {object} mixin Mixin object to merge into `base` @param {boolean} [mergeArrays] Merge arrays instead of concatenating them
[ "Recursively", "merge", "objects" ]
043f7e9aa9ec12250889fd825ddcf86709b095a3
https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/lib/utils.js#L46-L56
train
SockDrawer/SockBot
lib/utils.js
mergeHelper
function mergeHelper(base, mixin, name, mergeArrays) { if (Array.isArray(mixin[name])) { if (!mergeArrays && base[name] && Array.isArray(base[name])) { base[name] = base[name].concat(mixin[name]); } else { base[name] = mixin[name]; } } else if (typeof mixin[name] === 'object' && mixin[name] !== null) { let newBase = base[name] || {}; if (Array.isArray(newBase)) { newBase = {}; } mergeInner(newBase, mixin[name], mergeArrays); base[name] = newBase; } else { base[name] = mixin[name]; } }
javascript
function mergeHelper(base, mixin, name, mergeArrays) { if (Array.isArray(mixin[name])) { if (!mergeArrays && base[name] && Array.isArray(base[name])) { base[name] = base[name].concat(mixin[name]); } else { base[name] = mixin[name]; } } else if (typeof mixin[name] === 'object' && mixin[name] !== null) { let newBase = base[name] || {}; if (Array.isArray(newBase)) { newBase = {}; } mergeInner(newBase, mixin[name], mergeArrays); base[name] = newBase; } else { base[name] = mixin[name]; } }
[ "function", "mergeHelper", "(", "base", ",", "mixin", ",", "name", ",", "mergeArrays", ")", "{", "if", "(", "Array", ".", "isArray", "(", "mixin", "[", "name", "]", ")", ")", "{", "if", "(", "!", "mergeArrays", "&&", "base", "[", "name", "]", "&&", "Array", ".", "isArray", "(", "base", "[", "name", "]", ")", ")", "{", "base", "[", "name", "]", "=", "base", "[", "name", "]", ".", "concat", "(", "mixin", "[", "name", "]", ")", ";", "}", "else", "{", "base", "[", "name", "]", "=", "mixin", "[", "name", "]", ";", "}", "}", "else", "if", "(", "typeof", "mixin", "[", "name", "]", "===", "'object'", "&&", "mixin", "[", "name", "]", "!==", "null", ")", "{", "let", "newBase", "=", "base", "[", "name", "]", "||", "{", "}", ";", "if", "(", "Array", ".", "isArray", "(", "newBase", ")", ")", "{", "newBase", "=", "{", "}", ";", "}", "mergeInner", "(", "newBase", ",", "mixin", "[", "name", "]", ",", "mergeArrays", ")", ";", "base", "[", "name", "]", "=", "newBase", ";", "}", "else", "{", "base", "[", "name", "]", "=", "mixin", "[", "name", "]", ";", "}", "}" ]
Merge helper - FOR INTERNAL USE ONLY @param {object} base Base object to merge `mixin` into @param {object} mixin Mixin object to merge into `base` @param {string} name Name of property to merge @param {boolean} [mergeArrays] Merge arrays instead of concatenating them
[ "Merge", "helper", "-", "FOR", "INTERNAL", "USE", "ONLY" ]
043f7e9aa9ec12250889fd825ddcf86709b095a3
https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/lib/utils.js#L66-L83
train
SockDrawer/SockBot
plugins/summoner.js
handler
function handler(notification) { debug('summoner received a mention notification!'); return notification.getUser() .then((user) => { debug(`summoner responding to summons by ${user.name}`); const index = Math.floor(Math.random() * messages.length); const message = messages[index].replace(/%(\w+)%/g, (_, key) => { let value = user[key]; if (key === 'name' && !value) { value = user.username; } value = value || `%${key}%`; if (typeof value !== 'string') { value = `%${key}%`; } return value; }); debug(`summoner replying with: ${message}`); return forum.Post.reply(notification.topicId, notification.postId, message); }).catch((err) => { forum.emit('error', err); return Promise.reject(err); }); }
javascript
function handler(notification) { debug('summoner received a mention notification!'); return notification.getUser() .then((user) => { debug(`summoner responding to summons by ${user.name}`); const index = Math.floor(Math.random() * messages.length); const message = messages[index].replace(/%(\w+)%/g, (_, key) => { let value = user[key]; if (key === 'name' && !value) { value = user.username; } value = value || `%${key}%`; if (typeof value !== 'string') { value = `%${key}%`; } return value; }); debug(`summoner replying with: ${message}`); return forum.Post.reply(notification.topicId, notification.postId, message); }).catch((err) => { forum.emit('error', err); return Promise.reject(err); }); }
[ "function", "handler", "(", "notification", ")", "{", "debug", "(", "'summoner received a mention notification!'", ")", ";", "return", "notification", ".", "getUser", "(", ")", ".", "then", "(", "(", "user", ")", "=>", "{", "debug", "(", "`", "${", "user", ".", "name", "}", "`", ")", ";", "const", "index", "=", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "messages", ".", "length", ")", ";", "const", "message", "=", "messages", "[", "index", "]", ".", "replace", "(", "/", "%(\\w+)%", "/", "g", ",", "(", "_", ",", "key", ")", "=>", "{", "let", "value", "=", "user", "[", "key", "]", ";", "if", "(", "key", "===", "'name'", "&&", "!", "value", ")", "{", "value", "=", "user", ".", "username", ";", "}", "value", "=", "value", "||", "`", "${", "key", "}", "`", ";", "if", "(", "typeof", "value", "!==", "'string'", ")", "{", "value", "=", "`", "${", "key", "}", "`", ";", "}", "return", "value", ";", "}", ")", ";", "debug", "(", "`", "${", "message", "}", "`", ")", ";", "return", "forum", ".", "Post", ".", "reply", "(", "notification", ".", "topicId", ",", "notification", ".", "postId", ",", "message", ")", ";", "}", ")", ".", "catch", "(", "(", "err", ")", "=>", "{", "forum", ".", "emit", "(", "'error'", ",", "err", ")", ";", "return", "Promise", ".", "reject", "(", "err", ")", ";", "}", ")", ";", "}" ]
Handle a mention notification. Choose a random message and reply with it @param {Notification} notification Notification event to handle @returns {Promise} Resolves when event is processed
[ "Handle", "a", "mention", "notification", "." ]
043f7e9aa9ec12250889fd825ddcf86709b095a3
https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/plugins/summoner.js#L45-L68
train
SockDrawer/SockBot
providers/nodebb/chat.js
sendChat
function sendChat(roomId, content) { return retryAction(() => forum._emit('modules.chats.send', { roomId: roomId, message: content }), 5); }
javascript
function sendChat(roomId, content) { return retryAction(() => forum._emit('modules.chats.send', { roomId: roomId, message: content }), 5); }
[ "function", "sendChat", "(", "roomId", ",", "content", ")", "{", "return", "retryAction", "(", "(", ")", "=>", "forum", ".", "_emit", "(", "'modules.chats.send'", ",", "{", "roomId", ":", "roomId", ",", "message", ":", "content", "}", ")", ",", "5", ")", ";", "}" ]
Send a message to the chatroom @public @param {number} roomId Chatroom to speak to @param {string} content Message to send to the chatroom @returns {Promise} Resolves when message has been sent
[ "Send", "a", "message", "to", "the", "chatroom" ]
043f7e9aa9ec12250889fd825ddcf86709b095a3
https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/providers/nodebb/chat.js#L22-L27
train
SockDrawer/SockBot
providers/nodebb/chat.js
handleChat
function handleChat(payload) { if (!payload.message) { return Promise.reject(new Error('Event payload did not include chat message')); } const message = ChatRoom.Message.parse(payload.message); forum.emit('chatMessage', message); const ids = { post: -1, topic: -1, user: message.from.id, pm: message.room, chat: message.id }; return forum.Commands.get(ids, message.content, (content) => message.reply(content)) .then((command) => command.execute()); }
javascript
function handleChat(payload) { if (!payload.message) { return Promise.reject(new Error('Event payload did not include chat message')); } const message = ChatRoom.Message.parse(payload.message); forum.emit('chatMessage', message); const ids = { post: -1, topic: -1, user: message.from.id, pm: message.room, chat: message.id }; return forum.Commands.get(ids, message.content, (content) => message.reply(content)) .then((command) => command.execute()); }
[ "function", "handleChat", "(", "payload", ")", "{", "if", "(", "!", "payload", ".", "message", ")", "{", "return", "Promise", ".", "reject", "(", "new", "Error", "(", "'Event payload did not include chat message'", ")", ")", ";", "}", "const", "message", "=", "ChatRoom", ".", "Message", ".", "parse", "(", "payload", ".", "message", ")", ";", "forum", ".", "emit", "(", "'chatMessage'", ",", "message", ")", ";", "const", "ids", "=", "{", "post", ":", "-", "1", ",", "topic", ":", "-", "1", ",", "user", ":", "message", ".", "from", ".", "id", ",", "pm", ":", "message", ".", "room", ",", "chat", ":", "message", ".", "id", "}", ";", "return", "forum", ".", "Commands", ".", "get", "(", "ids", ",", "message", ".", "content", ",", "(", "content", ")", "=>", "message", ".", "reply", "(", "content", ")", ")", ".", "then", "(", "(", "command", ")", "=>", "command", ".", "execute", "(", ")", ")", ";", "}" ]
Handle Chat events from websocket @private @param {*} payload websocket event payload @returns {Promise} resolves when processing has been completed for event
[ "Handle", "Chat", "events", "from", "websocket" ]
043f7e9aa9ec12250889fd825ddcf86709b095a3
https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/providers/nodebb/chat.js#L441-L457
train
ArnaudBuchholz/gpf-js
res/sources/source.js
function (dependencies) { this._dependsOn = dependencies[this._name] || []; this._dependencyOf = []; Object.keys(dependencies).forEach(function (name) { var nameDependencies = dependencies[name]; if (nameDependencies.indexOf(this._name) !== NOT_FOUND) { this._dependencyOf.push(name); } }, this); }
javascript
function (dependencies) { this._dependsOn = dependencies[this._name] || []; this._dependencyOf = []; Object.keys(dependencies).forEach(function (name) { var nameDependencies = dependencies[name]; if (nameDependencies.indexOf(this._name) !== NOT_FOUND) { this._dependencyOf.push(name); } }, this); }
[ "function", "(", "dependencies", ")", "{", "this", ".", "_dependsOn", "=", "dependencies", "[", "this", ".", "_name", "]", "||", "[", "]", ";", "this", ".", "_dependencyOf", "=", "[", "]", ";", "Object", ".", "keys", "(", "dependencies", ")", ".", "forEach", "(", "function", "(", "name", ")", "{", "var", "nameDependencies", "=", "dependencies", "[", "name", "]", ";", "if", "(", "nameDependencies", ".", "indexOf", "(", "this", ".", "_name", ")", "!==", "NOT_FOUND", ")", "{", "this", ".", "_dependencyOf", ".", "push", "(", "name", ")", ";", "}", "}", ",", "this", ")", ";", "}" ]
Extract from the dependencies dictionary @param {Object} dependencies dictionary
[ "Extract", "from", "the", "dependencies", "dictionary" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/source.js#L98-L107
train
ArnaudBuchholz/gpf-js
res/sources/source.js
function () { var result = { name: this._name }; if (!this._test) { result.test = false; } if (this._tags.length) { result.tags = this._tags.join(" "); } return result; }
javascript
function () { var result = { name: this._name }; if (!this._test) { result.test = false; } if (this._tags.length) { result.tags = this._tags.join(" "); } return result; }
[ "function", "(", ")", "{", "var", "result", "=", "{", "name", ":", "this", ".", "_name", "}", ";", "if", "(", "!", "this", ".", "_test", ")", "{", "result", ".", "test", "=", "false", ";", "}", "if", "(", "this", ".", "_tags", ".", "length", ")", "{", "result", ".", "tags", "=", "this", ".", "_tags", ".", "join", "(", "\" \"", ")", ";", "}", "return", "result", ";", "}" ]
Create the exported version of the source @return {Object} Object to be converted to JSON and saved
[ "Create", "the", "exported", "version", "of", "the", "source" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/source.js#L128-L139
train
Esri/terraformer-geostore
src/geostore.js
function(primitive){ completed++; if ( primitive ){ var geometry = new Terraformer.Primitive(primitive.geometry); if (shapeGeometryTest(geometry, shape)){ if (self._stream) { if (completed === found.length) { if (operationName == "within") { self._stream.emit("done", primitive); } else { self._stream.emit("data", primitive); } self._stream.emit("end"); } else { self._stream.emit("data", primitive); } } else { results.push(primitive); } } if(completed >= found.length){ if(!errors){ if (self._stream) { self._stream = null; } else if (callback) { callback( null, results ); } } else { if (callback) { callback("Could not get all geometries", null); } } } } }
javascript
function(primitive){ completed++; if ( primitive ){ var geometry = new Terraformer.Primitive(primitive.geometry); if (shapeGeometryTest(geometry, shape)){ if (self._stream) { if (completed === found.length) { if (operationName == "within") { self._stream.emit("done", primitive); } else { self._stream.emit("data", primitive); } self._stream.emit("end"); } else { self._stream.emit("data", primitive); } } else { results.push(primitive); } } if(completed >= found.length){ if(!errors){ if (self._stream) { self._stream = null; } else if (callback) { callback( null, results ); } } else { if (callback) { callback("Could not get all geometries", null); } } } } }
[ "function", "(", "primitive", ")", "{", "completed", "++", ";", "if", "(", "primitive", ")", "{", "var", "geometry", "=", "new", "Terraformer", ".", "Primitive", "(", "primitive", ".", "geometry", ")", ";", "if", "(", "shapeGeometryTest", "(", "geometry", ",", "shape", ")", ")", "{", "if", "(", "self", ".", "_stream", ")", "{", "if", "(", "completed", "===", "found", ".", "length", ")", "{", "if", "(", "operationName", "==", "\"within\"", ")", "{", "self", ".", "_stream", ".", "emit", "(", "\"done\"", ",", "primitive", ")", ";", "}", "else", "{", "self", ".", "_stream", ".", "emit", "(", "\"data\"", ",", "primitive", ")", ";", "}", "self", ".", "_stream", ".", "emit", "(", "\"end\"", ")", ";", "}", "else", "{", "self", ".", "_stream", ".", "emit", "(", "\"data\"", ",", "primitive", ")", ";", "}", "}", "else", "{", "results", ".", "push", "(", "primitive", ")", ";", "}", "}", "if", "(", "completed", ">=", "found", ".", "length", ")", "{", "if", "(", "!", "errors", ")", "{", "if", "(", "self", ".", "_stream", ")", "{", "self", ".", "_stream", "=", "null", ";", "}", "else", "if", "(", "callback", ")", "{", "callback", "(", "null", ",", "results", ")", ";", "}", "}", "else", "{", "if", "(", "callback", ")", "{", "callback", "(", "\"Could not get all geometries\"", ",", "null", ")", ";", "}", "}", "}", "}", "}" ]
the function to evalute results from the index
[ "the", "function", "to", "evalute", "results", "from", "the", "index" ]
0226a88e570dafcbf185d598eafd9de3f8f27213
https://github.com/Esri/terraformer-geostore/blob/0226a88e570dafcbf185d598eafd9de3f8f27213/src/geostore.js#L219-L254
train
ArnaudBuchholz/gpf-js
src/define/check.js
function () { var parts = new RegExp("(.*)\\.([^\\.]+)$").exec(this._name), NAME_PART = 2, NAMESPACE_PART = 1; if (parts) { this._name = parts[NAME_PART]; return parts[NAMESPACE_PART]; } }
javascript
function () { var parts = new RegExp("(.*)\\.([^\\.]+)$").exec(this._name), NAME_PART = 2, NAMESPACE_PART = 1; if (parts) { this._name = parts[NAME_PART]; return parts[NAMESPACE_PART]; } }
[ "function", "(", ")", "{", "var", "parts", "=", "new", "RegExp", "(", "\"(.*)\\\\.([^\\\\.]+)$\"", ")", ".", "\\\\", "\\\\", ",", "exec", ",", "(", "this", ".", "_name", ")", ";", "NAME_PART", "=", "2", "}" ]
If the name is prefixed with a namespace, isolate it and update name property @return {String|undefined} Namespace contained in the name or undefined if none @since 0.1.6
[ "If", "the", "name", "is", "prefixed", "with", "a", "namespace", "isolate", "it", "and", "update", "name", "property" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/define/check.js#L260-L268
train
ArnaudBuchholz/gpf-js
src/define/check.js
function () { var namespaces = [ this._initialDefinition.$namespace, this._extractRelativeNamespaceFromName() ].filter(function (namespacePart) { return namespacePart; }); if (namespaces.length) { this._namespace = namespaces.join("."); } }
javascript
function () { var namespaces = [ this._initialDefinition.$namespace, this._extractRelativeNamespaceFromName() ].filter(function (namespacePart) { return namespacePart; }); if (namespaces.length) { this._namespace = namespaces.join("."); } }
[ "function", "(", ")", "{", "var", "namespaces", "=", "[", "this", ".", "_initialDefinition", ".", "$namespace", ",", "this", ".", "_extractRelativeNamespaceFromName", "(", ")", "]", ".", "filter", "(", "function", "(", "namespacePart", ")", "{", "return", "namespacePart", ";", "}", ")", ";", "if", "(", "namespaces", ".", "length", ")", "{", "this", ".", "_namespace", "=", "namespaces", ".", "join", "(", "\".\"", ")", ";", "}", "}" ]
Compute namespace property @since 0.1.6
[ "Compute", "namespace", "property" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/define/check.js#L274-L284
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/internal.js
_gpfCleanDefinition
function _gpfCleanDefinition (name, shortcut) { /*jshint validthis:true*/ // Bound to the definition below var shortcutValue = this[shortcut]; if (undefined !== shortcutValue) { this[name] = shortcutValue; delete this[shortcut]; } }
javascript
function _gpfCleanDefinition (name, shortcut) { /*jshint validthis:true*/ // Bound to the definition below var shortcutValue = this[shortcut]; if (undefined !== shortcutValue) { this[name] = shortcutValue; delete this[shortcut]; } }
[ "function", "_gpfCleanDefinition", "(", "name", ",", "shortcut", ")", "{", "var", "shortcutValue", "=", "this", "[", "shortcut", "]", ";", "if", "(", "undefined", "!==", "shortcutValue", ")", "{", "this", "[", "name", "]", "=", "shortcutValue", ";", "delete", "this", "[", "shortcut", "]", ";", "}", "}" ]
Replace the shortcut with the correct property name
[ "Replace", "the", "shortcut", "with", "the", "correct", "property", "name" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/internal.js#L18-L25
train
popeindustries/buddy
lib/config/index.js
parsePlugins
function parsePlugins(config) { let plugins = []; function parse(plugins) { return plugins.map(plugin => { if ('string' == typeof plugin) plugin = path.resolve(plugin); return plugin; }); } // Handle plugin paths defined in config file if (config.plugins) { plugins.push(...parse(config.plugins)); delete config.plugins; } // Handle plugin paths/functions defined in runtime options if (config.runtimeOptions.plugins) { plugins.push(...parse(config.runtimeOptions.plugins)); delete config.runtimeOptions.plugins; } return plugins; }
javascript
function parsePlugins(config) { let plugins = []; function parse(plugins) { return plugins.map(plugin => { if ('string' == typeof plugin) plugin = path.resolve(plugin); return plugin; }); } // Handle plugin paths defined in config file if (config.plugins) { plugins.push(...parse(config.plugins)); delete config.plugins; } // Handle plugin paths/functions defined in runtime options if (config.runtimeOptions.plugins) { plugins.push(...parse(config.runtimeOptions.plugins)); delete config.runtimeOptions.plugins; } return plugins; }
[ "function", "parsePlugins", "(", "config", ")", "{", "let", "plugins", "=", "[", "]", ";", "function", "parse", "(", "plugins", ")", "{", "return", "plugins", ".", "map", "(", "plugin", "=>", "{", "if", "(", "'string'", "==", "typeof", "plugin", ")", "plugin", "=", "path", ".", "resolve", "(", "plugin", ")", ";", "return", "plugin", ";", "}", ")", ";", "}", "if", "(", "config", ".", "plugins", ")", "{", "plugins", ".", "push", "(", "...", "parse", "(", "config", ".", "plugins", ")", ")", ";", "delete", "config", ".", "plugins", ";", "}", "if", "(", "config", ".", "runtimeOptions", ".", "plugins", ")", "{", "plugins", ".", "push", "(", "...", "parse", "(", "config", ".", "runtimeOptions", ".", "plugins", ")", ")", ";", "delete", "config", ".", "runtimeOptions", ".", "plugins", ";", "}", "return", "plugins", ";", "}" ]
Parse plugins defined in 'config' @param {Config} config @returns {Array}
[ "Parse", "plugins", "defined", "in", "config" ]
c38afc2e6915743eb6cfcf5aba59a8699142c7a5
https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/config/index.js#L320-L342
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/params.js
_gpfProcessDefineParamCheckIfRelativeName
function _gpfProcessDefineParamCheckIfRelativeName (rootNamespace, params) { var name = params[_GPF_DEFINE_PARAM_NAME]; if (-1 === name.indexOf(".")) { params[_GPF_DEFINE_PARAM_NAME] = rootNamespace + name; } }
javascript
function _gpfProcessDefineParamCheckIfRelativeName (rootNamespace, params) { var name = params[_GPF_DEFINE_PARAM_NAME]; if (-1 === name.indexOf(".")) { params[_GPF_DEFINE_PARAM_NAME] = rootNamespace + name; } }
[ "function", "_gpfProcessDefineParamCheckIfRelativeName", "(", "rootNamespace", ",", "params", ")", "{", "var", "name", "=", "params", "[", "_GPF_DEFINE_PARAM_NAME", "]", ";", "if", "(", "-", "1", "===", "name", ".", "indexOf", "(", "\".\"", ")", ")", "{", "params", "[", "_GPF_DEFINE_PARAM_NAME", "]", "=", "rootNamespace", "+", "name", ";", "}", "}" ]
Check if the name is relative, if so concatenate to the rootNamespace
[ "Check", "if", "the", "name", "is", "relative", "if", "so", "concatenate", "to", "the", "rootNamespace" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/params.js#L26-L31
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/params.js
_gpfProcessDefineParamResolveBase
function _gpfProcessDefineParamResolveBase (params) { var Super = params[_GPF_DEFINE_PARAM_SUPER]; if (!(Super instanceof Function)) { params[_GPF_DEFINE_PARAM_SUPER] = _gpfContext(Super.toString().split(".")); } }
javascript
function _gpfProcessDefineParamResolveBase (params) { var Super = params[_GPF_DEFINE_PARAM_SUPER]; if (!(Super instanceof Function)) { params[_GPF_DEFINE_PARAM_SUPER] = _gpfContext(Super.toString().split(".")); } }
[ "function", "_gpfProcessDefineParamResolveBase", "(", "params", ")", "{", "var", "Super", "=", "params", "[", "_GPF_DEFINE_PARAM_SUPER", "]", ";", "if", "(", "!", "(", "Super", "instanceof", "Function", ")", ")", "{", "params", "[", "_GPF_DEFINE_PARAM_SUPER", "]", "=", "_gpfContext", "(", "Super", ".", "toString", "(", ")", ".", "split", "(", "\".\"", ")", ")", ";", "}", "}" ]
Convert base parameter from string to contextual object
[ "Convert", "base", "parameter", "from", "string", "to", "contextual", "object" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/params.js#L48-L53
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/params.js
_gpfProcessDefineParamsCheck
function _gpfProcessDefineParamsCheck (params) { _gpfAsserts({ "name is required (String)": "string" === typeof params[_GPF_DEFINE_PARAM_NAME], "Super is required and must resolve to a Constructor": params[_GPF_DEFINE_PARAM_SUPER] instanceof Function, "definition is required (Object)": "object" === typeof params[_GPF_DEFINE_PARAM_DEFINITION] }); }
javascript
function _gpfProcessDefineParamsCheck (params) { _gpfAsserts({ "name is required (String)": "string" === typeof params[_GPF_DEFINE_PARAM_NAME], "Super is required and must resolve to a Constructor": params[_GPF_DEFINE_PARAM_SUPER] instanceof Function, "definition is required (Object)": "object" === typeof params[_GPF_DEFINE_PARAM_DEFINITION] }); }
[ "function", "_gpfProcessDefineParamsCheck", "(", "params", ")", "{", "_gpfAsserts", "(", "{", "\"name is required (String)\"", ":", "\"string\"", "===", "typeof", "params", "[", "_GPF_DEFINE_PARAM_NAME", "]", ",", "\"Super is required and must resolve to a Constructor\"", ":", "params", "[", "_GPF_DEFINE_PARAM_SUPER", "]", "instanceof", "Function", ",", "\"definition is required (Object)\"", ":", "\"object\"", "===", "typeof", "params", "[", "_GPF_DEFINE_PARAM_DEFINITION", "]", "}", ")", ";", "}" ]
Check that the parameters are correct
[ "Check", "that", "the", "parameters", "are", "correct" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/params.js#L56-L62
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/params.js
_gpfProcessDefineParams
function _gpfProcessDefineParams (rootNamespace, defaultSuper, params) { _gpfProcessDefineParamNoSuperUsed(defaultSuper, params); _gpfProcessDefineParamCheckIfRelativeName(rootNamespace, params); _gpfProcessDefineParamDefaultSuper(defaultSuper, params); _gpfProcessDefineParamDefaultDefinition(params); _gpfProcessDefineParamResolveBase(params); _gpfProcessDefineParamsCheck(params); }
javascript
function _gpfProcessDefineParams (rootNamespace, defaultSuper, params) { _gpfProcessDefineParamNoSuperUsed(defaultSuper, params); _gpfProcessDefineParamCheckIfRelativeName(rootNamespace, params); _gpfProcessDefineParamDefaultSuper(defaultSuper, params); _gpfProcessDefineParamDefaultDefinition(params); _gpfProcessDefineParamResolveBase(params); _gpfProcessDefineParamsCheck(params); }
[ "function", "_gpfProcessDefineParams", "(", "rootNamespace", ",", "defaultSuper", ",", "params", ")", "{", "_gpfProcessDefineParamNoSuperUsed", "(", "defaultSuper", ",", "params", ")", ";", "_gpfProcessDefineParamCheckIfRelativeName", "(", "rootNamespace", ",", "params", ")", ";", "_gpfProcessDefineParamDefaultSuper", "(", "defaultSuper", ",", "params", ")", ";", "_gpfProcessDefineParamDefaultDefinition", "(", "params", ")", ";", "_gpfProcessDefineParamResolveBase", "(", "params", ")", ";", "_gpfProcessDefineParamsCheck", "(", "params", ")", ";", "}" ]
Process define parameters to inject default values when needed @param {String} rootNamespace @param {Function|undefined|String} defaultSuper @param {Array} params gpf.define parameters: - {String} name New class contextual name - {String} [base=undefined] base Base class contextual name - {Object} [definition=undefined] definition Class definition
[ "Process", "define", "parameters", "to", "inject", "default", "values", "when", "needed" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/params.js#L74-L81
train
popeindustries/buddy
lib/resolver/resolve.js
find
function find(id, type, sourcedir, options) { const { cache, fileExtensions, nativeModules } = options; const pkgDetails = pkg.getDetails(sourcedir, options); let filepath = isRelativeFilepath(id) ? path.join(sourcedir, id) : id; filepath = alias.resolve(filepath, pkgDetails && pkgDetails.aliases); if (filepath === false || nativeModules.includes(filepath)) return false; if (isAbsoluteFilepath(filepath)) { filepath = findFilepath(filepath, type, fileExtensions); filepath = alias.resolve(filepath, pkgDetails && pkgDetails.aliases); // File doesn't exist or is disabled if (filepath === '' || filepath === false) return filepath; // File found if (isAbsoluteFilepath(filepath)) { // Cache cache.setFile( { id: pkg.resolveId(pkgDetails, filepath), path: filepath, version: pkgDetails.version }, versionDelimiter ); return filepath; } } // Update id if it has been resolved as package if (!isFilepath(filepath)) id = filepath; // Search paths for matches pkgDetails.paths.some(sourcepath => { if (id && sourcedir != sourcepath) { let fp = path.join(sourcepath, id); fp = find(fp, type, fp, options); if (fp !== '') { filepath = fp; return true; } filepath = ''; } }); return filepath; }
javascript
function find(id, type, sourcedir, options) { const { cache, fileExtensions, nativeModules } = options; const pkgDetails = pkg.getDetails(sourcedir, options); let filepath = isRelativeFilepath(id) ? path.join(sourcedir, id) : id; filepath = alias.resolve(filepath, pkgDetails && pkgDetails.aliases); if (filepath === false || nativeModules.includes(filepath)) return false; if (isAbsoluteFilepath(filepath)) { filepath = findFilepath(filepath, type, fileExtensions); filepath = alias.resolve(filepath, pkgDetails && pkgDetails.aliases); // File doesn't exist or is disabled if (filepath === '' || filepath === false) return filepath; // File found if (isAbsoluteFilepath(filepath)) { // Cache cache.setFile( { id: pkg.resolveId(pkgDetails, filepath), path: filepath, version: pkgDetails.version }, versionDelimiter ); return filepath; } } // Update id if it has been resolved as package if (!isFilepath(filepath)) id = filepath; // Search paths for matches pkgDetails.paths.some(sourcepath => { if (id && sourcedir != sourcepath) { let fp = path.join(sourcepath, id); fp = find(fp, type, fp, options); if (fp !== '') { filepath = fp; return true; } filepath = ''; } }); return filepath; }
[ "function", "find", "(", "id", ",", "type", ",", "sourcedir", ",", "options", ")", "{", "const", "{", "cache", ",", "fileExtensions", ",", "nativeModules", "}", "=", "options", ";", "const", "pkgDetails", "=", "pkg", ".", "getDetails", "(", "sourcedir", ",", "options", ")", ";", "let", "filepath", "=", "isRelativeFilepath", "(", "id", ")", "?", "path", ".", "join", "(", "sourcedir", ",", "id", ")", ":", "id", ";", "filepath", "=", "alias", ".", "resolve", "(", "filepath", ",", "pkgDetails", "&&", "pkgDetails", ".", "aliases", ")", ";", "if", "(", "filepath", "===", "false", "||", "nativeModules", ".", "includes", "(", "filepath", ")", ")", "return", "false", ";", "if", "(", "isAbsoluteFilepath", "(", "filepath", ")", ")", "{", "filepath", "=", "findFilepath", "(", "filepath", ",", "type", ",", "fileExtensions", ")", ";", "filepath", "=", "alias", ".", "resolve", "(", "filepath", ",", "pkgDetails", "&&", "pkgDetails", ".", "aliases", ")", ";", "if", "(", "filepath", "===", "''", "||", "filepath", "===", "false", ")", "return", "filepath", ";", "if", "(", "isAbsoluteFilepath", "(", "filepath", ")", ")", "{", "cache", ".", "setFile", "(", "{", "id", ":", "pkg", ".", "resolveId", "(", "pkgDetails", ",", "filepath", ")", ",", "path", ":", "filepath", ",", "version", ":", "pkgDetails", ".", "version", "}", ",", "versionDelimiter", ")", ";", "return", "filepath", ";", "}", "}", "if", "(", "!", "isFilepath", "(", "filepath", ")", ")", "id", "=", "filepath", ";", "pkgDetails", ".", "paths", ".", "some", "(", "sourcepath", "=>", "{", "if", "(", "id", "&&", "sourcedir", "!=", "sourcepath", ")", "{", "let", "fp", "=", "path", ".", "join", "(", "sourcepath", ",", "id", ")", ";", "fp", "=", "find", "(", "fp", ",", "type", ",", "fp", ",", "options", ")", ";", "if", "(", "fp", "!==", "''", ")", "{", "filepath", "=", "fp", ";", "return", "true", ";", "}", "filepath", "=", "''", ";", "}", "}", ")", ";", "return", "filepath", ";", "}" ]
Find filepath for 'id' in 'sourcedir' directory @param {String} id @param {String} type @param {String} sourcedir @param {Object} options - {Boolean} browser - {ResolverCache} cache - {Object} fileExtensions - {Array} nativeModules - {Array} sources @returns {String|Boolean}
[ "Find", "filepath", "for", "id", "in", "sourcedir", "directory" ]
c38afc2e6915743eb6cfcf5aba59a8699142c7a5
https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/resolver/resolve.js#L53-L100
train
ArnaudBuchholz/gpf-js
src/web/tag.js
_gpfWebGetNamespace
function _gpfWebGetNamespace (prefix) { var namespace = _gpfWebNamespacePrefix[prefix]; if (undefined === namespace) { gpf.Error.unknownNamespacePrefix(); } return namespace; }
javascript
function _gpfWebGetNamespace (prefix) { var namespace = _gpfWebNamespacePrefix[prefix]; if (undefined === namespace) { gpf.Error.unknownNamespacePrefix(); } return namespace; }
[ "function", "_gpfWebGetNamespace", "(", "prefix", ")", "{", "var", "namespace", "=", "_gpfWebNamespacePrefix", "[", "prefix", "]", ";", "if", "(", "undefined", "===", "namespace", ")", "{", "gpf", ".", "Error", ".", "unknownNamespacePrefix", "(", ")", ";", "}", "return", "namespace", ";", "}" ]
Retrieves namespace associated to the prefix or fail @param {String} prefix Namespace prefix @return {String} Namespace URI @throws {gpf.Error.UnknownNamespacePrefix} @since 0.2.2
[ "Retrieves", "namespace", "associated", "to", "the", "prefix", "or", "fail" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L146-L152
train
ArnaudBuchholz/gpf-js
src/web/tag.js
_gpfWebGetNamespaceAndName
function _gpfWebGetNamespaceAndName (name) { var EXPECTED_PARTS_COUNT = 2, NAMESPACE_PREFIX = 0, NAME = 1, parts = name.split(":"); if (parts.length === EXPECTED_PARTS_COUNT) { return { namespace: _gpfWebGetNamespace(parts[NAMESPACE_PREFIX]), name: parts[NAME] }; } }
javascript
function _gpfWebGetNamespaceAndName (name) { var EXPECTED_PARTS_COUNT = 2, NAMESPACE_PREFIX = 0, NAME = 1, parts = name.split(":"); if (parts.length === EXPECTED_PARTS_COUNT) { return { namespace: _gpfWebGetNamespace(parts[NAMESPACE_PREFIX]), name: parts[NAME] }; } }
[ "function", "_gpfWebGetNamespaceAndName", "(", "name", ")", "{", "var", "EXPECTED_PARTS_COUNT", "=", "2", ",", "NAMESPACE_PREFIX", "=", "0", ",", "NAME", "=", "1", ",", "parts", "=", "name", ".", "split", "(", "\":\"", ")", ";", "if", "(", "parts", ".", "length", "===", "EXPECTED_PARTS_COUNT", ")", "{", "return", "{", "namespace", ":", "_gpfWebGetNamespace", "(", "parts", "[", "NAMESPACE_PREFIX", "]", ")", ",", "name", ":", "parts", "[", "NAME", "]", "}", ";", "}", "}" ]
Resolves prefixed name to namespace and name @param {String} name Attribute or node name @return {{namespace, name}|undefined} Namespace and name in a structure if prefixed, undefined otherwise @since 0.2.2
[ "Resolves", "prefixed", "name", "to", "namespace", "and", "name" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L161-L172
train
ArnaudBuchholz/gpf-js
src/web/tag.js
_gpfWebTagFlattenChildren
function _gpfWebTagFlattenChildren (array, callback) { array.forEach(function (item) { if (_gpfIsArray(item)) { _gpfWebTagFlattenChildren(item, callback); } else { callback(item); } }); }
javascript
function _gpfWebTagFlattenChildren (array, callback) { array.forEach(function (item) { if (_gpfIsArray(item)) { _gpfWebTagFlattenChildren(item, callback); } else { callback(item); } }); }
[ "function", "_gpfWebTagFlattenChildren", "(", "array", ",", "callback", ")", "{", "array", ".", "forEach", "(", "function", "(", "item", ")", "{", "if", "(", "_gpfIsArray", "(", "item", ")", ")", "{", "_gpfWebTagFlattenChildren", "(", "item", ",", "callback", ")", ";", "}", "else", "{", "callback", "(", "item", ")", ";", "}", "}", ")", ";", "}" ]
Apply the callback to each array item, process recursively if the array item is an array @param {Array} array array of items @param {Function} callback Function to apply on each array item @since 0.2.1
[ "Apply", "the", "callback", "to", "each", "array", "item", "process", "recursively", "if", "the", "array", "item", "is", "an", "array" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L206-L214
train
ArnaudBuchholz/gpf-js
src/web/tag.js
function () { return Object.keys(this._attributes).map(function (name) { _gpfWebCheckNamespaceSafe(name); return " " + _gpfWebTagAttributeAlias(name) + "=\"" + _gpfStringEscapeForHtml(this._attributes[name]) + "\""; }, this).join(""); }
javascript
function () { return Object.keys(this._attributes).map(function (name) { _gpfWebCheckNamespaceSafe(name); return " " + _gpfWebTagAttributeAlias(name) + "=\"" + _gpfStringEscapeForHtml(this._attributes[name]) + "\""; }, this).join(""); }
[ "function", "(", ")", "{", "return", "Object", ".", "keys", "(", "this", ".", "_attributes", ")", ".", "map", "(", "function", "(", "name", ")", "{", "_gpfWebCheckNamespaceSafe", "(", "name", ")", ";", "return", "\" \"", "+", "_gpfWebTagAttributeAlias", "(", "name", ")", "+", "\"=\\\"\"", "+", "\\\"", "+", "_gpfStringEscapeForHtml", "(", "this", ".", "_attributes", "[", "name", "]", ")", ";", "}", ",", "this", ")", ".", "\"\\\"\"", "\\\"", ";", "}" ]
region toString implementation
[ "region", "toString", "implementation" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L256-L262
train
ArnaudBuchholz/gpf-js
src/web/tag.js
function (node) { var ownerDocument = node.ownerDocument, qualified = _gpfWebGetNamespaceAndName(this._nodeName); if (qualified) { return ownerDocument.createElementNS(qualified.namespace, qualified.name); } return ownerDocument.createElement(this._nodeName); }
javascript
function (node) { var ownerDocument = node.ownerDocument, qualified = _gpfWebGetNamespaceAndName(this._nodeName); if (qualified) { return ownerDocument.createElementNS(qualified.namespace, qualified.name); } return ownerDocument.createElement(this._nodeName); }
[ "function", "(", "node", ")", "{", "var", "ownerDocument", "=", "node", ".", "ownerDocument", ",", "qualified", "=", "_gpfWebGetNamespaceAndName", "(", "this", ".", "_nodeName", ")", ";", "if", "(", "qualified", ")", "{", "return", "ownerDocument", ".", "createElementNS", "(", "qualified", ".", "namespace", ",", "qualified", ".", "name", ")", ";", "}", "return", "ownerDocument", ".", "createElement", "(", "this", ".", "_nodeName", ")", ";", "}" ]
endregion region appendTo implementation
[ "endregion", "region", "appendTo", "implementation" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L294-L301
train
ArnaudBuchholz/gpf-js
src/web/tag.js
function (node) { var element = this._createElement(node); this._setAttributesTo(element); this._appendChildrenTo(element); return node.appendChild(element); }
javascript
function (node) { var element = this._createElement(node); this._setAttributesTo(element); this._appendChildrenTo(element); return node.appendChild(element); }
[ "function", "(", "node", ")", "{", "var", "element", "=", "this", ".", "_createElement", "(", "node", ")", ";", "this", ".", "_setAttributesTo", "(", "element", ")", ";", "this", ".", "_appendChildrenTo", "(", "element", ")", ";", "return", "node", ".", "appendChild", "(", "element", ")", ";", "}" ]
Appends the tag to the provided node @param {Object} node Expected to be a DOM node @return {Object} Created node @since 0.2.1
[ "Appends", "the", "tag", "to", "the", "provided", "node" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L332-L337
train
ArnaudBuchholz/gpf-js
src/web/tag.js
_gpfWebTagCreateFunction
function _gpfWebTagCreateFunction (nodeName) { if (!nodeName) { gpf.Error.missingNodeName(); } return function (firstParam) { var sliceFrom = 0, attributes; if (_gpfIsLiteralObject(firstParam)) { attributes = firstParam; ++sliceFrom; } return new _GpfWebTag(nodeName, attributes, _gpfArraySlice(arguments, sliceFrom)); }; }
javascript
function _gpfWebTagCreateFunction (nodeName) { if (!nodeName) { gpf.Error.missingNodeName(); } return function (firstParam) { var sliceFrom = 0, attributes; if (_gpfIsLiteralObject(firstParam)) { attributes = firstParam; ++sliceFrom; } return new _GpfWebTag(nodeName, attributes, _gpfArraySlice(arguments, sliceFrom)); }; }
[ "function", "_gpfWebTagCreateFunction", "(", "nodeName", ")", "{", "if", "(", "!", "nodeName", ")", "{", "gpf", ".", "Error", ".", "missingNodeName", "(", ")", ";", "}", "return", "function", "(", "firstParam", ")", "{", "var", "sliceFrom", "=", "0", ",", "attributes", ";", "if", "(", "_gpfIsLiteralObject", "(", "firstParam", ")", ")", "{", "attributes", "=", "firstParam", ";", "++", "sliceFrom", ";", "}", "return", "new", "_GpfWebTag", "(", "nodeName", ",", "attributes", ",", "_gpfArraySlice", "(", "arguments", ",", "sliceFrom", ")", ")", ";", "}", ";", "}" ]
Create a tag generation function @param {String} nodeName tag name. May include the namespace prefix svg for [SVG elements](https://developer.mozilla.org/en-US/docs/Web/SVG) @return {gpf.typedef.tagFunc} The tag generation function @gpf:closure @since 0.2.1
[ "Create", "a", "tag", "generation", "function" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/web/tag.js#L352-L365
train
ArnaudBuchholz/gpf-js
lost+found/src/like.js
function (a, b) { var done = this._done, indexOfA, comparedWith; indexOfA = done.indexOf(a); while (-1 < indexOfA) { comparedWith = this._getPair(done, indexOfA); if (comparedWith === b) { return false; // Already compared } indexOfA = done.indexOf(a, indexOfA + 1); } return true; }
javascript
function (a, b) { var done = this._done, indexOfA, comparedWith; indexOfA = done.indexOf(a); while (-1 < indexOfA) { comparedWith = this._getPair(done, indexOfA); if (comparedWith === b) { return false; // Already compared } indexOfA = done.indexOf(a, indexOfA + 1); } return true; }
[ "function", "(", "a", ",", "b", ")", "{", "var", "done", "=", "this", ".", "_done", ",", "indexOfA", ",", "comparedWith", ";", "indexOfA", "=", "done", ".", "indexOf", "(", "a", ")", ";", "while", "(", "-", "1", "<", "indexOfA", ")", "{", "comparedWith", "=", "this", ".", "_getPair", "(", "done", ",", "indexOfA", ")", ";", "if", "(", "comparedWith", "===", "b", ")", "{", "return", "false", ";", "}", "indexOfA", "=", "done", ".", "indexOf", "(", "a", ",", "indexOfA", "+", "1", ")", ";", "}", "return", "true", ";", "}" ]
Check in the stack of done if parameters were never compared @param {Object} a @param {Object} b @return {Boolean}
[ "Check", "in", "the", "stack", "of", "done", "if", "parameters", "were", "never", "compared" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L54-L67
train
ArnaudBuchholz/gpf-js
lost+found/src/like.js
function (a, b) { var pending; if (this._neverCompared(a, b)) { pending = this._pending; pending.push(a); pending.push(b); } }
javascript
function (a, b) { var pending; if (this._neverCompared(a, b)) { pending = this._pending; pending.push(a); pending.push(b); } }
[ "function", "(", "a", ",", "b", ")", "{", "var", "pending", ";", "if", "(", "this", ".", "_neverCompared", "(", "a", ",", "b", ")", ")", "{", "pending", "=", "this", ".", "_pending", ";", "pending", ".", "push", "(", "a", ")", ";", "pending", ".", "push", "(", "b", ")", ";", "}", "}" ]
If a was never compared with b, adds the pair to the pending list. @param {Object} a @param {Object} b
[ "If", "a", "was", "never", "compared", "with", "b", "adds", "the", "pair", "to", "the", "pending", "list", "." ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L75-L82
train
ArnaudBuchholz/gpf-js
lost+found/src/like.js
function () { var pending = this._pending, done = this._done, a, b; while (0 !== pending.length) { b = pending.pop(); a = pending.pop(); done.push(a, b); if (this._areDifferent(a, b)) { return false; } } return true; }
javascript
function () { var pending = this._pending, done = this._done, a, b; while (0 !== pending.length) { b = pending.pop(); a = pending.pop(); done.push(a, b); if (this._areDifferent(a, b)) { return false; } } return true; }
[ "function", "(", ")", "{", "var", "pending", "=", "this", ".", "_pending", ",", "done", "=", "this", ".", "_done", ",", "a", ",", "b", ";", "while", "(", "0", "!==", "pending", ".", "length", ")", "{", "b", "=", "pending", ".", "pop", "(", ")", ";", "a", "=", "pending", ".", "pop", "(", ")", ";", "done", ".", "push", "(", "a", ",", "b", ")", ";", "if", "(", "this", ".", "_areDifferent", "(", "a", ",", "b", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Process the pending list @return {Boolean}
[ "Process", "the", "pending", "list" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L105-L119
train
ArnaudBuchholz/gpf-js
lost+found/src/like.js
function (a, b) { var me = this, membersOfA = Object.keys(a); // a members comparison with b if (!membersOfA.every(function (member) { return me.like(a[member], b[member]); })) { return true; } // Difference on members count? return membersOfA.length !== Object.keys(b).length; }
javascript
function (a, b) { var me = this, membersOfA = Object.keys(a); // a members comparison with b if (!membersOfA.every(function (member) { return me.like(a[member], b[member]); })) { return true; } // Difference on members count? return membersOfA.length !== Object.keys(b).length; }
[ "function", "(", "a", ",", "b", ")", "{", "var", "me", "=", "this", ",", "membersOfA", "=", "Object", ".", "keys", "(", "a", ")", ";", "if", "(", "!", "membersOfA", ".", "every", "(", "function", "(", "member", ")", "{", "return", "me", ".", "like", "(", "a", "[", "member", "]", ",", "b", "[", "member", "]", ")", ";", "}", ")", ")", "{", "return", "true", ";", "}", "return", "membersOfA", ".", "length", "!==", "Object", ".", "keys", "(", "b", ")", ".", "length", ";", "}" ]
Check if members are different @param {*} a @param {*} b @returns {Number}
[ "Check", "if", "members", "are", "different" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L128-L139
train
ArnaudBuchholz/gpf-js
lost+found/src/like.js
function (a, b) { if (null === a || null === b || "object" !== typeof a) { return false; // Because we know that a !== b } this._stack(a, b); return true; }
javascript
function (a, b) { if (null === a || null === b || "object" !== typeof a) { return false; // Because we know that a !== b } this._stack(a, b); return true; }
[ "function", "(", "a", ",", "b", ")", "{", "if", "(", "null", "===", "a", "||", "null", "===", "b", "||", "\"object\"", "!==", "typeof", "a", ")", "{", "return", "false", ";", "}", "this", ".", "_stack", "(", "a", ",", "b", ")", ";", "return", "true", ";", "}" ]
Check if objects are the same @param {Object} a @param {Object} b @returns {boolean}
[ "Check", "if", "objects", "are", "the", "same" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L176-L182
train
ArnaudBuchholz/gpf-js
lost+found/src/like.js
function (a, b) { if (a === b) { return true; } if (typeof a !== typeof b) { return this._alike(a, b); } return this._objectLike(a, b); }
javascript
function (a, b) { if (a === b) { return true; } if (typeof a !== typeof b) { return this._alike(a, b); } return this._objectLike(a, b); }
[ "function", "(", "a", ",", "b", ")", "{", "if", "(", "a", "===", "b", ")", "{", "return", "true", ";", "}", "if", "(", "typeof", "a", "!==", "typeof", "b", ")", "{", "return", "this", ".", "_alike", "(", "a", ",", "b", ")", ";", "}", "return", "this", ".", "_objectLike", "(", "a", ",", "b", ")", ";", "}" ]
Internal version of gpf.like @param {*} a @param {*} b @return {Boolean}
[ "Internal", "version", "of", "gpf", ".", "like" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/like.js#L191-L199
train
ArnaudBuchholz/gpf-js
src/abstract.js
_gpfCreateAbstractFunction
function _gpfCreateAbstractFunction (numberOfParameters) { return _gpfFunctionBuild({ parameters: _gpfBuildFunctionParameterList(numberOfParameters), body: "_throw_();" }, { _throw_: gpf.Error.abstractMethod }); }
javascript
function _gpfCreateAbstractFunction (numberOfParameters) { return _gpfFunctionBuild({ parameters: _gpfBuildFunctionParameterList(numberOfParameters), body: "_throw_();" }, { _throw_: gpf.Error.abstractMethod }); }
[ "function", "_gpfCreateAbstractFunction", "(", "numberOfParameters", ")", "{", "return", "_gpfFunctionBuild", "(", "{", "parameters", ":", "_gpfBuildFunctionParameterList", "(", "numberOfParameters", ")", ",", "body", ":", "\"_throw_();\"", "}", ",", "{", "_throw_", ":", "gpf", ".", "Error", ".", "abstractMethod", "}", ")", ";", "}" ]
Build a function that throws the abstractMethod exception @param {Number} numberOfParameters Defines the signature of the resulting function @return {Function} Function that throws the abstractMethod exception @since 0.1.8
[ "Build", "a", "function", "that", "throws", "the", "abstractMethod", "exception" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/abstract.js#L36-L43
train
ArnaudBuchholz/gpf-js
lost+found/src/dispatch.js
_gpfAddEventListener
function _gpfAddEventListener (event, eventsHandler) { /*jshint validthis:true*/ // will be invoked as an object method var listeners = _gpfAllocateEventDispatcherListeners(this); if (undefined === listeners[event]) { listeners[event] = []; } listeners[event].push(eventsHandler); return this; }
javascript
function _gpfAddEventListener (event, eventsHandler) { /*jshint validthis:true*/ // will be invoked as an object method var listeners = _gpfAllocateEventDispatcherListeners(this); if (undefined === listeners[event]) { listeners[event] = []; } listeners[event].push(eventsHandler); return this; }
[ "function", "_gpfAddEventListener", "(", "event", ",", "eventsHandler", ")", "{", "var", "listeners", "=", "_gpfAllocateEventDispatcherListeners", "(", "this", ")", ";", "if", "(", "undefined", "===", "listeners", "[", "event", "]", ")", "{", "listeners", "[", "event", "]", "=", "[", "]", ";", "}", "listeners", "[", "event", "]", ".", "push", "(", "eventsHandler", ")", ";", "return", "this", ";", "}" ]
Add an event listener to the dispatcher @param {String} event name @param {gpf.events.Handler} eventsHandler @gpf:chainable
[ "Add", "an", "event", "listener", "to", "the", "dispatcher" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/dispatch.js#L26-L34
train
ArnaudBuchholz/gpf-js
lost+found/src/dispatch.js
_gpfRemoveEventListener
function _gpfRemoveEventListener (event, eventsHandler) { /*jshint validthis:true*/ // will be invoked as an object method var listeners = this._eventDispatcherListeners, eventListeners, index; if (listeners) { eventListeners = listeners[event]; if (undefined !== eventListeners) { index = eventListeners.indexOf(eventsHandler); if (-1 !== index) { eventListeners.splice(index, 1); } } } return this; }
javascript
function _gpfRemoveEventListener (event, eventsHandler) { /*jshint validthis:true*/ // will be invoked as an object method var listeners = this._eventDispatcherListeners, eventListeners, index; if (listeners) { eventListeners = listeners[event]; if (undefined !== eventListeners) { index = eventListeners.indexOf(eventsHandler); if (-1 !== index) { eventListeners.splice(index, 1); } } } return this; }
[ "function", "_gpfRemoveEventListener", "(", "event", ",", "eventsHandler", ")", "{", "var", "listeners", "=", "this", ".", "_eventDispatcherListeners", ",", "eventListeners", ",", "index", ";", "if", "(", "listeners", ")", "{", "eventListeners", "=", "listeners", "[", "event", "]", ";", "if", "(", "undefined", "!==", "eventListeners", ")", "{", "index", "=", "eventListeners", ".", "indexOf", "(", "eventsHandler", ")", ";", "if", "(", "-", "1", "!==", "index", ")", "{", "eventListeners", ".", "splice", "(", "index", ",", "1", ")", ";", "}", "}", "}", "return", "this", ";", "}" ]
Remove an event listener from the dispatcher @param {String} event name @param {gpf.events.Handler} eventsHandler @gpf:chainable
[ "Remove", "an", "event", "listener", "from", "the", "dispatcher" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/dispatch.js#L43-L58
train
ArnaudBuchholz/gpf-js
lost+found/src/dispatch.js
_gpfTriggerListeners
function _gpfTriggerListeners (eventObj, eventListeners) { var index, length = eventListeners.length; for (index = 0; index < length; ++index) { _gpfEventsFire.call(eventObj.scope, eventObj, {}, eventListeners[index]); } }
javascript
function _gpfTriggerListeners (eventObj, eventListeners) { var index, length = eventListeners.length; for (index = 0; index < length; ++index) { _gpfEventsFire.call(eventObj.scope, eventObj, {}, eventListeners[index]); } }
[ "function", "_gpfTriggerListeners", "(", "eventObj", ",", "eventListeners", ")", "{", "var", "index", ",", "length", "=", "eventListeners", ".", "length", ";", "for", "(", "index", "=", "0", ";", "index", "<", "length", ";", "++", "index", ")", "{", "_gpfEventsFire", ".", "call", "(", "eventObj", ".", "scope", ",", "eventObj", ",", "{", "}", ",", "eventListeners", "[", "index", "]", ")", ";", "}", "}" ]
Execute the listeners @param {gpf.events.Event} eventObj @param {gpf.events.Handler[]} eventListeners
[ "Execute", "the", "listeners" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/dispatch.js#L66-L72
train
ArnaudBuchholz/gpf-js
lost+found/src/dispatch.js
_gpfDispatchEvent
function _gpfDispatchEvent (event, params) { /*jshint validthis:true*/ // will be invoked as an object method var listeners = this._eventDispatcherListeners, eventObj, type, eventListeners; if (!listeners) { return this; // No listeners at all } if (event instanceof _GpfEvent) { eventObj = event; type = event.type; } else { type = event; } eventListeners = this._eventDispatcherListeners[type]; if (undefined === eventListeners) { return this; // Nothing listeners for this event } if (!eventObj) { eventObj = new _GpfEvent(type, params, this); } _gpfTriggerListeners(eventObj, eventListeners); return eventObj; }
javascript
function _gpfDispatchEvent (event, params) { /*jshint validthis:true*/ // will be invoked as an object method var listeners = this._eventDispatcherListeners, eventObj, type, eventListeners; if (!listeners) { return this; // No listeners at all } if (event instanceof _GpfEvent) { eventObj = event; type = event.type; } else { type = event; } eventListeners = this._eventDispatcherListeners[type]; if (undefined === eventListeners) { return this; // Nothing listeners for this event } if (!eventObj) { eventObj = new _GpfEvent(type, params, this); } _gpfTriggerListeners(eventObj, eventListeners); return eventObj; }
[ "function", "_gpfDispatchEvent", "(", "event", ",", "params", ")", "{", "var", "listeners", "=", "this", ".", "_eventDispatcherListeners", ",", "eventObj", ",", "type", ",", "eventListeners", ";", "if", "(", "!", "listeners", ")", "{", "return", "this", ";", "}", "if", "(", "event", "instanceof", "_GpfEvent", ")", "{", "eventObj", "=", "event", ";", "type", "=", "event", ".", "type", ";", "}", "else", "{", "type", "=", "event", ";", "}", "eventListeners", "=", "this", ".", "_eventDispatcherListeners", "[", "type", "]", ";", "if", "(", "undefined", "===", "eventListeners", ")", "{", "return", "this", ";", "}", "if", "(", "!", "eventObj", ")", "{", "eventObj", "=", "new", "_GpfEvent", "(", "type", ",", "params", ",", "this", ")", ";", "}", "_gpfTriggerListeners", "(", "eventObj", ",", "eventListeners", ")", ";", "return", "eventObj", ";", "}" ]
Broadcast the event @param {String|gpf.events.Event} event name or object @param {Object} [params={}] event parameters @return {gpf.events.Event}
[ "Broadcast", "the", "event" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/dispatch.js#L81-L105
train
ArnaudBuchholz/gpf-js
make/ast.js
function (src) { // https://github.com/Constellation/escodegen/issues/85 let ast = esprima.parse(src, { range: true, tokens: true, comment: true }); ast = escodegen.attachComments(ast, ast.comments, ast.tokens); delete ast.tokens; delete ast.comments; return ast; }
javascript
function (src) { // https://github.com/Constellation/escodegen/issues/85 let ast = esprima.parse(src, { range: true, tokens: true, comment: true }); ast = escodegen.attachComments(ast, ast.comments, ast.tokens); delete ast.tokens; delete ast.comments; return ast; }
[ "function", "(", "src", ")", "{", "let", "ast", "=", "esprima", ".", "parse", "(", "src", ",", "{", "range", ":", "true", ",", "tokens", ":", "true", ",", "comment", ":", "true", "}", ")", ";", "ast", "=", "escodegen", ".", "attachComments", "(", "ast", ",", "ast", ".", "comments", ",", "ast", ".", "tokens", ")", ";", "delete", "ast", ".", "tokens", ";", "delete", "ast", ".", "comments", ";", "return", "ast", ";", "}" ]
Transform the source into an AST representation
[ "Transform", "the", "source", "into", "an", "AST", "representation" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/make/ast.js#L284-L295
train
ArnaudBuchholz/gpf-js
make/ast.js
function (ast, setting, debug) { let optimizer = new Optimizer(ast, setting, debug); optimizer.analyze(); optimizer.optimize(); return ast; }
javascript
function (ast, setting, debug) { let optimizer = new Optimizer(ast, setting, debug); optimizer.analyze(); optimizer.optimize(); return ast; }
[ "function", "(", "ast", ",", "setting", ",", "debug", ")", "{", "let", "optimizer", "=", "new", "Optimizer", "(", "ast", ",", "setting", ",", "debug", ")", ";", "optimizer", ".", "analyze", "(", ")", ";", "optimizer", ".", "optimize", "(", ")", ";", "return", "ast", ";", "}" ]
Detect & apply optimization patterns
[ "Detect", "&", "apply", "optimization", "patterns" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/make/ast.js#L298-L303
train
makeup-js/makeup-expander
index.js
_onKeyDown
function _onKeyDown(e) { var keyCode = e.keyCode; if (keyCode === 13 || keyCode === 32) { this.keyDownFlag = true; // if host element does not naturally trigger a click event on spacebar, we can force one to trigger here. // careful! if host already triggers click events naturally, we end up with a "double-click". if (keyCode === 32 && this.options.simulateSpacebarClick === true) { this.hostEl.click(); } } }
javascript
function _onKeyDown(e) { var keyCode = e.keyCode; if (keyCode === 13 || keyCode === 32) { this.keyDownFlag = true; // if host element does not naturally trigger a click event on spacebar, we can force one to trigger here. // careful! if host already triggers click events naturally, we end up with a "double-click". if (keyCode === 32 && this.options.simulateSpacebarClick === true) { this.hostEl.click(); } } }
[ "function", "_onKeyDown", "(", "e", ")", "{", "var", "keyCode", "=", "e", ".", "keyCode", ";", "if", "(", "keyCode", "===", "13", "||", "keyCode", "===", "32", ")", "{", "this", ".", "keyDownFlag", "=", "true", ";", "if", "(", "keyCode", "===", "32", "&&", "this", ".", "options", ".", "simulateSpacebarClick", "===", "true", ")", "{", "this", ".", "hostEl", ".", "click", "(", ")", ";", "}", "}", "}" ]
when options.expandOnClick is true, we set a flag if spacebar or enter are pressed the idea being that this flag is set BEFORE the click event
[ "when", "options", ".", "expandOnClick", "is", "true", "we", "set", "a", "flag", "if", "spacebar", "or", "enter", "are", "pressed", "the", "idea", "being", "that", "this", "flag", "is", "set", "BEFORE", "the", "click", "event" ]
9274abb14e4fd051ddcc609dbc9fe9ac6605631c
https://github.com/makeup-js/makeup-expander/blob/9274abb14e4fd051ddcc609dbc9fe9ac6605631c/index.js#L35-L46
train
popeindustries/buddy
lib/utils/string.js
commentStrip
function commentStrip(string) { // Remove commented lines string = string.replace(RE_COMMENT_SINGLE_LINE, ''); string = string.replace(RE_COMMENT_MULTI_LINES, ''); return string; }
javascript
function commentStrip(string) { // Remove commented lines string = string.replace(RE_COMMENT_SINGLE_LINE, ''); string = string.replace(RE_COMMENT_MULTI_LINES, ''); return string; }
[ "function", "commentStrip", "(", "string", ")", "{", "string", "=", "string", ".", "replace", "(", "RE_COMMENT_SINGLE_LINE", ",", "''", ")", ";", "string", "=", "string", ".", "replace", "(", "RE_COMMENT_MULTI_LINES", ",", "''", ")", ";", "return", "string", ";", "}" ]
Strip comments from 'string' @param {String} string @returns {String}
[ "Strip", "comments", "from", "string" ]
c38afc2e6915743eb6cfcf5aba59a8699142c7a5
https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/string.js#L31-L36
train
popeindustries/buddy
lib/utils/string.js
commentWrap
function commentWrap(string, type) { let open, close; if (type == 'html') { open = '<!-- '; close = ' -->'; } else { open = '/* '; close = ' */'; } return open + string + close; }
javascript
function commentWrap(string, type) { let open, close; if (type == 'html') { open = '<!-- '; close = ' -->'; } else { open = '/* '; close = ' */'; } return open + string + close; }
[ "function", "commentWrap", "(", "string", ",", "type", ")", "{", "let", "open", ",", "close", ";", "if", "(", "type", "==", "'html'", ")", "{", "open", "=", "'<!-- '", ";", "close", "=", "' ", ";", "}", "else", "{", "open", "=", "'/* '", ";", "close", "=", "' */'", ";", "}", "return", "open", "+", "string", "+", "close", ";", "}" ]
Wrap 'string' in comment based on 'type' @param {String} string @param {String} type @returns {String}
[ "Wrap", "string", "in", "comment", "based", "on", "type" ]
c38afc2e6915743eb6cfcf5aba59a8699142c7a5
https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/string.js#L53-L65
train
popeindustries/buddy
lib/utils/string.js
indent
function indent(string, column) { const spaces = new Array(++column).join(COLUMN); return string.replace(RE_LINE_BEGIN, spaces); }
javascript
function indent(string, column) { const spaces = new Array(++column).join(COLUMN); return string.replace(RE_LINE_BEGIN, spaces); }
[ "function", "indent", "(", "string", ",", "column", ")", "{", "const", "spaces", "=", "new", "Array", "(", "++", "column", ")", ".", "join", "(", "COLUMN", ")", ";", "return", "string", ".", "replace", "(", "RE_LINE_BEGIN", ",", "spaces", ")", ";", "}" ]
Indent the given 'string' a specific number of columns @param {String} string @param {Int} column @returns {String}
[ "Indent", "the", "given", "string", "a", "specific", "number", "of", "columns" ]
c38afc2e6915743eb6cfcf5aba59a8699142c7a5
https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/string.js#L73-L77
train
popeindustries/buddy
lib/utils/string.js
uniqueMatch
function uniqueMatch(string, regexp) { const results = []; let match; while ((match = regexp.exec(string))) { results.push({ context: match[0], match: match[1] || '' }); } // Filter duplicates return unique(results, isEqual); }
javascript
function uniqueMatch(string, regexp) { const results = []; let match; while ((match = regexp.exec(string))) { results.push({ context: match[0], match: match[1] || '' }); } // Filter duplicates return unique(results, isEqual); }
[ "function", "uniqueMatch", "(", "string", ",", "regexp", ")", "{", "const", "results", "=", "[", "]", ";", "let", "match", ";", "while", "(", "(", "match", "=", "regexp", ".", "exec", "(", "string", ")", ")", ")", "{", "results", ".", "push", "(", "{", "context", ":", "match", "[", "0", "]", ",", "match", ":", "match", "[", "1", "]", "||", "''", "}", ")", ";", "}", "return", "unique", "(", "results", ",", "isEqual", ")", ";", "}" ]
Match unique occurrences in 'string' @param {String} string @param {RegExp} regexp @returns {Array}
[ "Match", "unique", "occurrences", "in", "string" ]
c38afc2e6915743eb6cfcf5aba59a8699142c7a5
https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/string.js#L85-L98
train
ArnaudBuchholz/gpf-js
src/host/java.js
_gpfHostJava
function _gpfHostJava () { _gpfDosPath = String(java.lang.System.getProperty("file.separator")) === "\\"; // Define console APIs _gpfMainContext.console = _gpfConsoleGenerate(print); /* istanbul ignore next */ // exit.1 _gpfExit = function (code) { java.lang.System.exit(code); }; }
javascript
function _gpfHostJava () { _gpfDosPath = String(java.lang.System.getProperty("file.separator")) === "\\"; // Define console APIs _gpfMainContext.console = _gpfConsoleGenerate(print); /* istanbul ignore next */ // exit.1 _gpfExit = function (code) { java.lang.System.exit(code); }; }
[ "function", "_gpfHostJava", "(", ")", "{", "_gpfDosPath", "=", "String", "(", "java", ".", "lang", ".", "System", ".", "getProperty", "(", "\"file.separator\"", ")", ")", "===", "\"\\\\\"", ";", "\\\\", "_gpfMainContext", ".", "console", "=", "_gpfConsoleGenerate", "(", "print", ")", ";", "}" ]
Common implementation for Java hosts @since 0.2.4
[ "Common", "implementation", "for", "Java", "hosts" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/host/java.js#L28-L40
train
ArnaudBuchholz/gpf-js
lost+found/src/xnode.js
function (name) { var result, member, mappedName; if (null === this._attributes) { this._members(); } if (undefined === name) { result = {}; for (member in this._attributes) { if (this._attributes.hasOwnProperty(member)) { mappedName = this._attributes[member]; result[mappedName] = this._obj[member]; } } return result; } for (member in this._attributes) { if (this._attributes.hasOwnProperty(member)) { if (name === this._attributes[member]) { return this._obj[member]; } } } return undefined; }
javascript
function (name) { var result, member, mappedName; if (null === this._attributes) { this._members(); } if (undefined === name) { result = {}; for (member in this._attributes) { if (this._attributes.hasOwnProperty(member)) { mappedName = this._attributes[member]; result[mappedName] = this._obj[member]; } } return result; } for (member in this._attributes) { if (this._attributes.hasOwnProperty(member)) { if (name === this._attributes[member]) { return this._obj[member]; } } } return undefined; }
[ "function", "(", "name", ")", "{", "var", "result", ",", "member", ",", "mappedName", ";", "if", "(", "null", "===", "this", ".", "_attributes", ")", "{", "this", ".", "_members", "(", ")", ";", "}", "if", "(", "undefined", "===", "name", ")", "{", "result", "=", "{", "}", ";", "for", "(", "member", "in", "this", ".", "_attributes", ")", "{", "if", "(", "this", ".", "_attributes", ".", "hasOwnProperty", "(", "member", ")", ")", "{", "mappedName", "=", "this", ".", "_attributes", "[", "member", "]", ";", "result", "[", "mappedName", "]", "=", "this", ".", "_obj", "[", "member", "]", ";", "}", "}", "return", "result", ";", "}", "for", "(", "member", "in", "this", ".", "_attributes", ")", "{", "if", "(", "this", ".", "_attributes", ".", "hasOwnProperty", "(", "member", ")", ")", "{", "if", "(", "name", "===", "this", ".", "_attributes", "[", "member", "]", ")", "{", "return", "this", ".", "_obj", "[", "member", "]", ";", "}", "}", "}", "return", "undefined", ";", "}" ]
region gpf.interfaces.IXmlConstNode @implements gpf.interfaces.IXmlConstNode:attributes
[ "region", "gpf", ".", "interfaces", ".", "IXmlConstNode" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/xnode.js#L232-L255
train
ArnaudBuchholz/gpf-js
lost+found/src/xnode.js
_nodeToXml
function _nodeToXml (node, wrapped) { var name = node.localName(), attributes = node.attributes(), children = node.children(), text = node.textContent(), idx; wrapped.startElement({ uri: "", localName: name, qName: name }, attributes); // Today the XmlConstNode may not have both children and textual content if (text) { wrapped.characters(text); } else { for (idx = 0; idx < children.length; ++idx) { _nodeToXml(children[idx], wrapped); } } wrapped.endElement(); }
javascript
function _nodeToXml (node, wrapped) { var name = node.localName(), attributes = node.attributes(), children = node.children(), text = node.textContent(), idx; wrapped.startElement({ uri: "", localName: name, qName: name }, attributes); // Today the XmlConstNode may not have both children and textual content if (text) { wrapped.characters(text); } else { for (idx = 0; idx < children.length; ++idx) { _nodeToXml(children[idx], wrapped); } } wrapped.endElement(); }
[ "function", "_nodeToXml", "(", "node", ",", "wrapped", ")", "{", "var", "name", "=", "node", ".", "localName", "(", ")", ",", "attributes", "=", "node", ".", "attributes", "(", ")", ",", "children", "=", "node", ".", "children", "(", ")", ",", "text", "=", "node", ".", "textContent", "(", ")", ",", "idx", ";", "wrapped", ".", "startElement", "(", "{", "uri", ":", "\"\"", ",", "localName", ":", "name", ",", "qName", ":", "name", "}", ",", "attributes", ")", ";", "if", "(", "text", ")", "{", "wrapped", ".", "characters", "(", "text", ")", ";", "}", "else", "{", "for", "(", "idx", "=", "0", ";", "idx", "<", "children", ".", "length", ";", "++", "idx", ")", "{", "_nodeToXml", "(", "children", "[", "idx", "]", ",", "wrapped", ")", ";", "}", "}", "wrapped", ".", "endElement", "(", ")", ";", "}" ]
Serialize the node into an gpf.interfaces.IXmlContentHandler @param {gpf.interfaces.IXmlConstNode} node Node to serialize @param {gpf.interfaces.wrap(IXmlContentHandler)} wrapped XML Content
[ "Serialize", "the", "node", "into", "an", "gpf", ".", "interfaces", ".", "IXmlContentHandler" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/xnode.js#L405-L426
train
ArnaudBuchholz/gpf-js
src/define/detect.js
_gpfDefineBuildTypedEntity
function _gpfDefineBuildTypedEntity (definition) { var EntityBuilder = _gpfDefineRead$TypedProperties(definition), entityDefinition; if (!EntityBuilder) { EntityBuilder = _gpfDefineCheck$TypeProperty(definition); } entityDefinition = new EntityBuilder(definition); entityDefinition.check(); return entityDefinition; }
javascript
function _gpfDefineBuildTypedEntity (definition) { var EntityBuilder = _gpfDefineRead$TypedProperties(definition), entityDefinition; if (!EntityBuilder) { EntityBuilder = _gpfDefineCheck$TypeProperty(definition); } entityDefinition = new EntityBuilder(definition); entityDefinition.check(); return entityDefinition; }
[ "function", "_gpfDefineBuildTypedEntity", "(", "definition", ")", "{", "var", "EntityBuilder", "=", "_gpfDefineRead$TypedProperties", "(", "definition", ")", ",", "entityDefinition", ";", "if", "(", "!", "EntityBuilder", ")", "{", "EntityBuilder", "=", "_gpfDefineCheck$TypeProperty", "(", "definition", ")", ";", "}", "entityDefinition", "=", "new", "EntityBuilder", "(", "definition", ")", ";", "entityDefinition", ".", "check", "(", ")", ";", "return", "entityDefinition", ";", "}" ]
Factory to create the correct entity type @param {Object} definition Entity definition literal object @return {_GpfEntityDefinition} Entity definition instance @throws {gpf.Error.InvalidEntityType} @since 0.1.6
[ "Factory", "to", "create", "the", "correct", "entity", "type" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/define/detect.js#L78-L87
train
ArnaudBuchholz/gpf-js
res/sources/array.js
function (callback, thisArg) { var me = this; this._sources.forEach(function (source, index) { callback(me._update(source), index); }, thisArg); }
javascript
function (callback, thisArg) { var me = this; this._sources.forEach(function (source, index) { callback(me._update(source), index); }, thisArg); }
[ "function", "(", "callback", ",", "thisArg", ")", "{", "var", "me", "=", "this", ";", "this", ".", "_sources", ".", "forEach", "(", "function", "(", "source", ",", "index", ")", "{", "callback", "(", "me", ".", "_update", "(", "source", ")", ",", "index", ")", ";", "}", ",", "thisArg", ")", ";", "}" ]
Enumerate all sources @param {Function} callback Called on each source @param {*} thisArg This context
[ "Enumerate", "all", "sources" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/array.js#L56-L61
train
ArnaudBuchholz/gpf-js
res/sources/array.js
function (name) { var result; this._sources.every(function (source) { if (source.getName() === name) { result = this._update(source); return false; } return true; }, this); return result; }
javascript
function (name) { var result; this._sources.every(function (source) { if (source.getName() === name) { result = this._update(source); return false; } return true; }, this); return result; }
[ "function", "(", "name", ")", "{", "var", "result", ";", "this", ".", "_sources", ".", "every", "(", "function", "(", "source", ")", "{", "if", "(", "source", ".", "getName", "(", ")", "===", "name", ")", "{", "result", "=", "this", ".", "_update", "(", "source", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", ",", "this", ")", ";", "return", "result", ";", "}" ]
Get the source by name @param {String} name Name of the source name to retreive @return {Source|undefined} Source which name matches the parameter
[ "Get", "the", "source", "by", "name" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/array.js#L69-L79
train
ArnaudBuchholz/gpf-js
res/sources/array.js
function (name) { var dependencies = this.byName(name).getDependencies(), names = this.getNames(), minIndex = 1; // 0 being boot dependencies.forEach(function (dependencyName) { var index = names.indexOf(dependencyName); ++index; if (index > minIndex) { minIndex = index; } }); return minIndex; }
javascript
function (name) { var dependencies = this.byName(name).getDependencies(), names = this.getNames(), minIndex = 1; // 0 being boot dependencies.forEach(function (dependencyName) { var index = names.indexOf(dependencyName); ++index; if (index > minIndex) { minIndex = index; } }); return minIndex; }
[ "function", "(", "name", ")", "{", "var", "dependencies", "=", "this", ".", "byName", "(", "name", ")", ".", "getDependencies", "(", ")", ",", "names", "=", "this", ".", "getNames", "(", ")", ",", "minIndex", "=", "1", ";", "dependencies", ".", "forEach", "(", "function", "(", "dependencyName", ")", "{", "var", "index", "=", "names", ".", "indexOf", "(", "dependencyName", ")", ";", "++", "index", ";", "if", "(", "index", ">", "minIndex", ")", "{", "minIndex", "=", "index", ";", "}", "}", ")", ";", "return", "minIndex", ";", "}" ]
Based on its dependencies, compute the minimum index of the module. @param {String} name Source Name @return {Number} Source index before which the source can't be moved
[ "Based", "on", "its", "dependencies", "compute", "the", "minimum", "index", "of", "the", "module", "." ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/array.js#L108-L120
train
ArnaudBuchholz/gpf-js
res/sources/array.js
function (sourceName, referenceSourceName) { var sourceToMove, sourcePos, referenceSourcePos; if (!this._sources.every(function (source, index) { var name = source.getName(); if (name === sourceName) { sourceToMove = source; sourcePos = index; } else if (name === referenceSourceName) { referenceSourcePos = index; } return sourcePos === undefined || referenceSourcePos === undefined; })) { var KEEP_ITEM = 0, REMOVE_ITEM = 1; this._sources.splice(sourcePos, REMOVE_ITEM); if (sourcePos > referenceSourcePos) { ++referenceSourcePos; } this._sources.splice(referenceSourcePos, KEEP_ITEM, sourceToMove); this._rebuildSourcesIndex(); } }
javascript
function (sourceName, referenceSourceName) { var sourceToMove, sourcePos, referenceSourcePos; if (!this._sources.every(function (source, index) { var name = source.getName(); if (name === sourceName) { sourceToMove = source; sourcePos = index; } else if (name === referenceSourceName) { referenceSourcePos = index; } return sourcePos === undefined || referenceSourcePos === undefined; })) { var KEEP_ITEM = 0, REMOVE_ITEM = 1; this._sources.splice(sourcePos, REMOVE_ITEM); if (sourcePos > referenceSourcePos) { ++referenceSourcePos; } this._sources.splice(referenceSourcePos, KEEP_ITEM, sourceToMove); this._rebuildSourcesIndex(); } }
[ "function", "(", "sourceName", ",", "referenceSourceName", ")", "{", "var", "sourceToMove", ",", "sourcePos", ",", "referenceSourcePos", ";", "if", "(", "!", "this", ".", "_sources", ".", "every", "(", "function", "(", "source", ",", "index", ")", "{", "var", "name", "=", "source", ".", "getName", "(", ")", ";", "if", "(", "name", "===", "sourceName", ")", "{", "sourceToMove", "=", "source", ";", "sourcePos", "=", "index", ";", "}", "else", "if", "(", "name", "===", "referenceSourceName", ")", "{", "referenceSourcePos", "=", "index", ";", "}", "return", "sourcePos", "===", "undefined", "||", "referenceSourcePos", "===", "undefined", ";", "}", ")", ")", "{", "var", "KEEP_ITEM", "=", "0", ",", "REMOVE_ITEM", "=", "1", ";", "this", ".", "_sources", ".", "splice", "(", "sourcePos", ",", "REMOVE_ITEM", ")", ";", "if", "(", "sourcePos", ">", "referenceSourcePos", ")", "{", "++", "referenceSourcePos", ";", "}", "this", ".", "_sources", ".", "splice", "(", "referenceSourcePos", ",", "KEEP_ITEM", ",", "sourceToMove", ")", ";", "this", ".", "_rebuildSourcesIndex", "(", ")", ";", "}", "}" ]
Moves source after the referenced one @param {String} sourceName Name of the source to move @param {String} referenceSourceName Name of the source to be used as a position reference
[ "Moves", "source", "after", "the", "referenced", "one" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/array.js#L150-L173
train
ArnaudBuchholz/gpf-js
res/sources/array.js
function (checkDictionary) { this._checkDictionary = checkDictionary; var newSources = Object.keys(checkDictionary) .filter(function (name) { return checkDictionary[name] === "new"; }) .map(function (name) { return new Source(this, { name: name, load: false }, null); }, this); // Add missing sources after the last loaded one if (newSources.length) { this.sources = this.sources.concat(newSources); } }
javascript
function (checkDictionary) { this._checkDictionary = checkDictionary; var newSources = Object.keys(checkDictionary) .filter(function (name) { return checkDictionary[name] === "new"; }) .map(function (name) { return new Source(this, { name: name, load: false }, null); }, this); // Add missing sources after the last loaded one if (newSources.length) { this.sources = this.sources.concat(newSources); } }
[ "function", "(", "checkDictionary", ")", "{", "this", ".", "_checkDictionary", "=", "checkDictionary", ";", "var", "newSources", "=", "Object", ".", "keys", "(", "checkDictionary", ")", ".", "filter", "(", "function", "(", "name", ")", "{", "return", "checkDictionary", "[", "name", "]", "===", "\"new\"", ";", "}", ")", ".", "map", "(", "function", "(", "name", ")", "{", "return", "new", "Source", "(", "this", ",", "{", "name", ":", "name", ",", "load", ":", "false", "}", ",", "null", ")", ";", "}", ",", "this", ")", ";", "if", "(", "newSources", ".", "length", ")", "{", "this", ".", "sources", "=", "this", ".", "sources", ".", "concat", "(", "newSources", ")", ";", "}", "}" ]
Provide information about sources @param {Object} checkDictionary Result of the check mechanism
[ "Provide", "information", "about", "sources" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/res/sources/array.js#L192-L208
train
azerion/log4js-logstash
index.js
logstashLayout
function logstashLayout(logEvt, fields) { var messageData = logEvt.data[0], log = { '@timestamp': (new Date()).toISOString(), '@fields': { category: logEvt.categoryName, level: logEvt.level.levelStr }, '@message' : (toType(messageData) === "string") ? messageData : JSON.stringify(messageData) } for (var key in fields) { if (typeof fields[key] !== 'function') { log['@fields'][key] = fields[key]; } } return JSON.stringify(log) + '\n'; }
javascript
function logstashLayout(logEvt, fields) { var messageData = logEvt.data[0], log = { '@timestamp': (new Date()).toISOString(), '@fields': { category: logEvt.categoryName, level: logEvt.level.levelStr }, '@message' : (toType(messageData) === "string") ? messageData : JSON.stringify(messageData) } for (var key in fields) { if (typeof fields[key] !== 'function') { log['@fields'][key] = fields[key]; } } return JSON.stringify(log) + '\n'; }
[ "function", "logstashLayout", "(", "logEvt", ",", "fields", ")", "{", "var", "messageData", "=", "logEvt", ".", "data", "[", "0", "]", ",", "log", "=", "{", "'@timestamp'", ":", "(", "new", "Date", "(", ")", ")", ".", "toISOString", "(", ")", ",", "'@fields'", ":", "{", "category", ":", "logEvt", ".", "categoryName", ",", "level", ":", "logEvt", ".", "level", ".", "levelStr", "}", ",", "'@message'", ":", "(", "toType", "(", "messageData", ")", "===", "\"string\"", ")", "?", "messageData", ":", "JSON", ".", "stringify", "(", "messageData", ")", "}", "for", "(", "var", "key", "in", "fields", ")", "{", "if", "(", "typeof", "fields", "[", "key", "]", "!==", "'function'", ")", "{", "log", "[", "'@fields'", "]", "[", "key", "]", "=", "fields", "[", "key", "]", ";", "}", "}", "return", "JSON", ".", "stringify", "(", "log", ")", "+", "'\\n'", ";", "}" ]
Simple layout parser for logstash message. If message type is not string, parser will convert message into string using JSON.stringify. @param logEvt, fields @returns {{@timestamp: string, @fields: {category: (categoryName|*), level: (levelStr|*)}}}
[ "Simple", "layout", "parser", "for", "logstash", "message", ".", "If", "message", "type", "is", "not", "string", "parser", "will", "convert", "message", "into", "string", "using", "JSON", ".", "stringify", "." ]
996e098337c334994d23fb62d0f5ef865fb03861
https://github.com/azerion/log4js-logstash/blob/996e098337c334994d23fb62d0f5ef865fb03861/index.js#L17-L35
train
azerion/log4js-logstash
index.js
logStashAppender
function logStashAppender(config, fields, layout) { var time = process.hrtime(), messages = [], timeOutId = 0; layout = layout || logstashLayout; //Setup the connection to logstash function pushToStash(config, msg) { var client = net.connect({host: config.host, port: config.port}, function () { client.write(msg); client.end(); }); //Fail silently client.on('error', function (evt) { if (true === config.debug) { console.log('An error happened in the logstash appender!', evt); } }); } return function (logEvt) { //do stuff with the logging event var data = layout(logEvt, fields); if (config.batch === true) { messages.push(data); clearTimeout(timeOutId); if ((process.hrtime(time)[0] >= config.batchTimeout || messages.length > config.batchSize)) { pushToStash(config, messages.join('')); time = process.hrtime(); messages = []; } else { timeOutId = setTimeout(function () { pushToStash(config, messages.join('')); time = process.hrtime(); messages = []; }, 1000); } } else { pushToStash(config, data); } }; }
javascript
function logStashAppender(config, fields, layout) { var time = process.hrtime(), messages = [], timeOutId = 0; layout = layout || logstashLayout; //Setup the connection to logstash function pushToStash(config, msg) { var client = net.connect({host: config.host, port: config.port}, function () { client.write(msg); client.end(); }); //Fail silently client.on('error', function (evt) { if (true === config.debug) { console.log('An error happened in the logstash appender!', evt); } }); } return function (logEvt) { //do stuff with the logging event var data = layout(logEvt, fields); if (config.batch === true) { messages.push(data); clearTimeout(timeOutId); if ((process.hrtime(time)[0] >= config.batchTimeout || messages.length > config.batchSize)) { pushToStash(config, messages.join('')); time = process.hrtime(); messages = []; } else { timeOutId = setTimeout(function () { pushToStash(config, messages.join('')); time = process.hrtime(); messages = []; }, 1000); } } else { pushToStash(config, data); } }; }
[ "function", "logStashAppender", "(", "config", ",", "fields", ",", "layout", ")", "{", "var", "time", "=", "process", ".", "hrtime", "(", ")", ",", "messages", "=", "[", "]", ",", "timeOutId", "=", "0", ";", "layout", "=", "layout", "||", "logstashLayout", ";", "function", "pushToStash", "(", "config", ",", "msg", ")", "{", "var", "client", "=", "net", ".", "connect", "(", "{", "host", ":", "config", ".", "host", ",", "port", ":", "config", ".", "port", "}", ",", "function", "(", ")", "{", "client", ".", "write", "(", "msg", ")", ";", "client", ".", "end", "(", ")", ";", "}", ")", ";", "client", ".", "on", "(", "'error'", ",", "function", "(", "evt", ")", "{", "if", "(", "true", "===", "config", ".", "debug", ")", "{", "console", ".", "log", "(", "'An error happened in the logstash appender!'", ",", "evt", ")", ";", "}", "}", ")", ";", "}", "return", "function", "(", "logEvt", ")", "{", "var", "data", "=", "layout", "(", "logEvt", ",", "fields", ")", ";", "if", "(", "config", ".", "batch", "===", "true", ")", "{", "messages", ".", "push", "(", "data", ")", ";", "clearTimeout", "(", "timeOutId", ")", ";", "if", "(", "(", "process", ".", "hrtime", "(", "time", ")", "[", "0", "]", ">=", "config", ".", "batchTimeout", "||", "messages", ".", "length", ">", "config", ".", "batchSize", ")", ")", "{", "pushToStash", "(", "config", ",", "messages", ".", "join", "(", "''", ")", ")", ";", "time", "=", "process", ".", "hrtime", "(", ")", ";", "messages", "=", "[", "]", ";", "}", "else", "{", "timeOutId", "=", "setTimeout", "(", "function", "(", ")", "{", "pushToStash", "(", "config", ",", "messages", ".", "join", "(", "''", ")", ")", ";", "time", "=", "process", ".", "hrtime", "(", ")", ";", "messages", "=", "[", "]", ";", "}", ",", "1000", ")", ";", "}", "}", "else", "{", "pushToStash", "(", "config", ",", "data", ")", ";", "}", "}", ";", "}" ]
The appender, Gives us the function used for log4js. It Supports batching of commands, we use the json_lines codec for this library, so the \n are mandatory @param config @param fields @param layout @returns {Function}
[ "The", "appender", "Gives", "us", "the", "function", "used", "for", "log4js", ".", "It", "Supports", "batching", "of", "commands", "we", "use", "the", "json_lines", "codec", "for", "this", "library", "so", "the", "\\", "n", "are", "mandatory" ]
996e098337c334994d23fb62d0f5ef865fb03861
https://github.com/azerion/log4js-logstash/blob/996e098337c334994d23fb62d0f5ef865fb03861/index.js#L47-L90
train
azerion/log4js-logstash
index.js
pushToStash
function pushToStash(config, msg) { var client = net.connect({host: config.host, port: config.port}, function () { client.write(msg); client.end(); }); //Fail silently client.on('error', function (evt) { if (true === config.debug) { console.log('An error happened in the logstash appender!', evt); } }); }
javascript
function pushToStash(config, msg) { var client = net.connect({host: config.host, port: config.port}, function () { client.write(msg); client.end(); }); //Fail silently client.on('error', function (evt) { if (true === config.debug) { console.log('An error happened in the logstash appender!', evt); } }); }
[ "function", "pushToStash", "(", "config", ",", "msg", ")", "{", "var", "client", "=", "net", ".", "connect", "(", "{", "host", ":", "config", ".", "host", ",", "port", ":", "config", ".", "port", "}", ",", "function", "(", ")", "{", "client", ".", "write", "(", "msg", ")", ";", "client", ".", "end", "(", ")", ";", "}", ")", ";", "client", ".", "on", "(", "'error'", ",", "function", "(", "evt", ")", "{", "if", "(", "true", "===", "config", ".", "debug", ")", "{", "console", ".", "log", "(", "'An error happened in the logstash appender!'", ",", "evt", ")", ";", "}", "}", ")", ";", "}" ]
Setup the connection to logstash
[ "Setup", "the", "connection", "to", "logstash" ]
996e098337c334994d23fb62d0f5ef865fb03861
https://github.com/azerion/log4js-logstash/blob/996e098337c334994d23fb62d0f5ef865fb03861/index.js#L55-L66
train
azerion/log4js-logstash
index.js
configure
function configure(config) { var key, layout = null, fields = {}, options = { port: (typeof config.port === "number") ? config.port : 5959, host: (typeof config.host === "string") ? config.host : 'localhost', debug: config.debug || false }; if (config.batch) { options.batch = true; options.batchSize = config.batch.size; options.batchTimeout = config.batch.timeout; } if (config.fields && typeof config.fields === 'object') { for (key in config.fields) { if (typeof config.fields[key] !== 'function') { fields[key] = config.fields[key]; } } } return logStashAppender(options, fields, layout); }
javascript
function configure(config) { var key, layout = null, fields = {}, options = { port: (typeof config.port === "number") ? config.port : 5959, host: (typeof config.host === "string") ? config.host : 'localhost', debug: config.debug || false }; if (config.batch) { options.batch = true; options.batchSize = config.batch.size; options.batchTimeout = config.batch.timeout; } if (config.fields && typeof config.fields === 'object') { for (key in config.fields) { if (typeof config.fields[key] !== 'function') { fields[key] = config.fields[key]; } } } return logStashAppender(options, fields, layout); }
[ "function", "configure", "(", "config", ")", "{", "var", "key", ",", "layout", "=", "null", ",", "fields", "=", "{", "}", ",", "options", "=", "{", "port", ":", "(", "typeof", "config", ".", "port", "===", "\"number\"", ")", "?", "config", ".", "port", ":", "5959", ",", "host", ":", "(", "typeof", "config", ".", "host", "===", "\"string\"", ")", "?", "config", ".", "host", ":", "'localhost'", ",", "debug", ":", "config", ".", "debug", "||", "false", "}", ";", "if", "(", "config", ".", "batch", ")", "{", "options", ".", "batch", "=", "true", ";", "options", ".", "batchSize", "=", "config", ".", "batch", ".", "size", ";", "options", ".", "batchTimeout", "=", "config", ".", "batch", ".", "timeout", ";", "}", "if", "(", "config", ".", "fields", "&&", "typeof", "config", ".", "fields", "===", "'object'", ")", "{", "for", "(", "key", "in", "config", ".", "fields", ")", "{", "if", "(", "typeof", "config", ".", "fields", "[", "key", "]", "!==", "'function'", ")", "{", "fields", "[", "key", "]", "=", "config", ".", "fields", "[", "key", "]", ";", "}", "}", "}", "return", "logStashAppender", "(", "options", ",", "fields", ",", "layout", ")", ";", "}" ]
Config method, calls logStashAppender to return the logging function @param config @returns {Function}
[ "Config", "method", "calls", "logStashAppender", "to", "return", "the", "logging", "function" ]
996e098337c334994d23fb62d0f5ef865fb03861
https://github.com/azerion/log4js-logstash/blob/996e098337c334994d23fb62d0f5ef865fb03861/index.js#L98-L122
train
ArnaudBuchholz/gpf-js
src/http/helpers.js
_gpfHttpParseHeaders
function _gpfHttpParseHeaders (headers) { var result = {}; _gpfArrayForEach(_gpfRegExpForEach(_gpfHttpHeadersParserRE, headers), function (match) { result[match[_GPF_HTTP_HELPERS_HEADER_NAME]] = match[_GPF_HTTP_HELPERS_HEADER_VALUE]; }); return result; }
javascript
function _gpfHttpParseHeaders (headers) { var result = {}; _gpfArrayForEach(_gpfRegExpForEach(_gpfHttpHeadersParserRE, headers), function (match) { result[match[_GPF_HTTP_HELPERS_HEADER_NAME]] = match[_GPF_HTTP_HELPERS_HEADER_VALUE]; }); return result; }
[ "function", "_gpfHttpParseHeaders", "(", "headers", ")", "{", "var", "result", "=", "{", "}", ";", "_gpfArrayForEach", "(", "_gpfRegExpForEach", "(", "_gpfHttpHeadersParserRE", ",", "headers", ")", ",", "function", "(", "match", ")", "{", "result", "[", "match", "[", "_GPF_HTTP_HELPERS_HEADER_NAME", "]", "]", "=", "match", "[", "_GPF_HTTP_HELPERS_HEADER_VALUE", "]", ";", "}", ")", ";", "return", "result", ";", "}" ]
Parse HTTP response headers @param {String} headers Response headers @return {Object} headers dictionary @since 0.2.1
[ "Parse", "HTTP", "response", "headers" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http/helpers.js#L47-L53
train
ArnaudBuchholz/gpf-js
src/http/helpers.js
_gpfHttpGenSetHeaders
function _gpfHttpGenSetHeaders (methodName) { return function (httpObj, headers) { if (headers) { Object.keys(headers).forEach(function (headerName) { httpObj[methodName](headerName, headers[headerName]); }); } }; }
javascript
function _gpfHttpGenSetHeaders (methodName) { return function (httpObj, headers) { if (headers) { Object.keys(headers).forEach(function (headerName) { httpObj[methodName](headerName, headers[headerName]); }); } }; }
[ "function", "_gpfHttpGenSetHeaders", "(", "methodName", ")", "{", "return", "function", "(", "httpObj", ",", "headers", ")", "{", "if", "(", "headers", ")", "{", "Object", ".", "keys", "(", "headers", ")", ".", "forEach", "(", "function", "(", "headerName", ")", "{", "httpObj", "[", "methodName", "]", "(", "headerName", ",", "headers", "[", "headerName", "]", ")", ";", "}", ")", ";", "}", "}", ";", "}" ]
Generates a function that transmit headers to the http object @param {String} methodName Name of the method to call @return {Function} Method to set the headers @gpf:closure @since 0.2.1
[ "Generates", "a", "function", "that", "transmit", "headers", "to", "the", "http", "object" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http/helpers.js#L63-L71
train
ArnaudBuchholz/gpf-js
src/http/helpers.js
_gpfHttpGenSend
function _gpfHttpGenSend (methodName) { return function (httpObj, data) { if (data) { httpObj[methodName](data); } else { httpObj[methodName](); } }; }
javascript
function _gpfHttpGenSend (methodName) { return function (httpObj, data) { if (data) { httpObj[methodName](data); } else { httpObj[methodName](); } }; }
[ "function", "_gpfHttpGenSend", "(", "methodName", ")", "{", "return", "function", "(", "httpObj", ",", "data", ")", "{", "if", "(", "data", ")", "{", "httpObj", "[", "methodName", "]", "(", "data", ")", ";", "}", "else", "{", "httpObj", "[", "methodName", "]", "(", ")", ";", "}", "}", ";", "}" ]
Generates a function that implements the http send logic @param {String} methodName Name of the method to call @return {Function} Method to trigger the send @gpf:closure @since 0.2.1
[ "Generates", "a", "function", "that", "implements", "the", "http", "send", "logic" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http/helpers.js#L81-L89
train
popeindustries/buddy
lib/utils/sourceMap.js
create
function create(content, url) { url = url || '<source>'; const map = new SourceMapGenerator({ file: url }); const lines = content.split('\n'); for (let l = 1, n = lines.length; l <= n; l++) { // Skip empty if (lines[l - 1]) { map.addMapping({ source: url, original: { line: l, column: 0 }, generated: { line: l, column: 0 } }); } } map.setSourceContent(url, content); return map; }
javascript
function create(content, url) { url = url || '<source>'; const map = new SourceMapGenerator({ file: url }); const lines = content.split('\n'); for (let l = 1, n = lines.length; l <= n; l++) { // Skip empty if (lines[l - 1]) { map.addMapping({ source: url, original: { line: l, column: 0 }, generated: { line: l, column: 0 } }); } } map.setSourceContent(url, content); return map; }
[ "function", "create", "(", "content", ",", "url", ")", "{", "url", "=", "url", "||", "'<source>'", ";", "const", "map", "=", "new", "SourceMapGenerator", "(", "{", "file", ":", "url", "}", ")", ";", "const", "lines", "=", "content", ".", "split", "(", "'\\n'", ")", ";", "\\n", "for", "(", "let", "l", "=", "1", ",", "n", "=", "lines", ".", "length", ";", "l", "<=", "n", ";", "l", "++", ")", "{", "if", "(", "lines", "[", "l", "-", "1", "]", ")", "{", "map", ".", "addMapping", "(", "{", "source", ":", "url", ",", "original", ":", "{", "line", ":", "l", ",", "column", ":", "0", "}", ",", "generated", ":", "{", "line", ":", "l", ",", "column", ":", "0", "}", "}", ")", ";", "}", "}", "map", ".", "setSourceContent", "(", "url", ",", "content", ")", ";", "}" ]
Create source map from 'content' @param {String} content @param {String} [url] @returns {SourceMapGenerator}
[ "Create", "source", "map", "from", "content" ]
c38afc2e6915743eb6cfcf5aba59a8699142c7a5
https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/sourceMap.js#L20-L38
train
popeindustries/buddy
lib/utils/sourceMap.js
createFromMap
function createFromMap(mapObject, content, url) { url = url || '<source>'; if ('string' == typeof mapObject) { try { mapObject = JSON.parse(mapObject); } catch (err) { mapObject = { version: 3, names: [], mappings: '', file: '' }; } } if (emptySources(mapObject)) { mapObject.sources = [url]; mapObject.sourcesContent = [content]; } return SourceMapGenerator.fromSourceMap(new SourceMapConsumer(mapObject)); }
javascript
function createFromMap(mapObject, content, url) { url = url || '<source>'; if ('string' == typeof mapObject) { try { mapObject = JSON.parse(mapObject); } catch (err) { mapObject = { version: 3, names: [], mappings: '', file: '' }; } } if (emptySources(mapObject)) { mapObject.sources = [url]; mapObject.sourcesContent = [content]; } return SourceMapGenerator.fromSourceMap(new SourceMapConsumer(mapObject)); }
[ "function", "createFromMap", "(", "mapObject", ",", "content", ",", "url", ")", "{", "url", "=", "url", "||", "'<source>'", ";", "if", "(", "'string'", "==", "typeof", "mapObject", ")", "{", "try", "{", "mapObject", "=", "JSON", ".", "parse", "(", "mapObject", ")", ";", "}", "catch", "(", "err", ")", "{", "mapObject", "=", "{", "version", ":", "3", ",", "names", ":", "[", "]", ",", "mappings", ":", "''", ",", "file", ":", "''", "}", ";", "}", "}", "if", "(", "emptySources", "(", "mapObject", ")", ")", "{", "mapObject", ".", "sources", "=", "[", "url", "]", ";", "mapObject", ".", "sourcesContent", "=", "[", "content", "]", ";", "}", "return", "SourceMapGenerator", ".", "fromSourceMap", "(", "new", "SourceMapConsumer", "(", "mapObject", ")", ")", ";", "}" ]
Create source map from 'mapObject' and 'content' @param {Object} mapObject @param {String} content @param {String} [url] @returns {SourceMapGenerator}
[ "Create", "source", "map", "from", "mapObject", "and", "content" ]
c38afc2e6915743eb6cfcf5aba59a8699142c7a5
https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/sourceMap.js#L47-L67
train
popeindustries/buddy
lib/utils/sourceMap.js
insert
function insert(outMap, inMap, length, index) { // Move existing mappings if (length) { outMap._mappings.unsortedForEach(mapping => { if (mapping.generatedLine > index) mapping.generatedLine += length; }); } // Add new mappings if (inMap) { const inConsumer = new SourceMapConsumer(inMap.toJSON()); inConsumer.eachMapping(mapping => { outMap.addMapping({ source: mapping.source, original: mapping.source == null ? null : { line: mapping.originalLine, column: mapping.originalColumn }, generated: { line: index + mapping.generatedLine - 1, column: mapping.generatedColumn } }); }); inConsumer.sources.forEach((source, idx) => { outMap.setSourceContent(source, inConsumer.sourcesContent[idx]); }); } }
javascript
function insert(outMap, inMap, length, index) { // Move existing mappings if (length) { outMap._mappings.unsortedForEach(mapping => { if (mapping.generatedLine > index) mapping.generatedLine += length; }); } // Add new mappings if (inMap) { const inConsumer = new SourceMapConsumer(inMap.toJSON()); inConsumer.eachMapping(mapping => { outMap.addMapping({ source: mapping.source, original: mapping.source == null ? null : { line: mapping.originalLine, column: mapping.originalColumn }, generated: { line: index + mapping.generatedLine - 1, column: mapping.generatedColumn } }); }); inConsumer.sources.forEach((source, idx) => { outMap.setSourceContent(source, inConsumer.sourcesContent[idx]); }); } }
[ "function", "insert", "(", "outMap", ",", "inMap", ",", "length", ",", "index", ")", "{", "if", "(", "length", ")", "{", "outMap", ".", "_mappings", ".", "unsortedForEach", "(", "mapping", "=>", "{", "if", "(", "mapping", ".", "generatedLine", ">", "index", ")", "mapping", ".", "generatedLine", "+=", "length", ";", "}", ")", ";", "}", "if", "(", "inMap", ")", "{", "const", "inConsumer", "=", "new", "SourceMapConsumer", "(", "inMap", ".", "toJSON", "(", ")", ")", ";", "inConsumer", ".", "eachMapping", "(", "mapping", "=>", "{", "outMap", ".", "addMapping", "(", "{", "source", ":", "mapping", ".", "source", ",", "original", ":", "mapping", ".", "source", "==", "null", "?", "null", ":", "{", "line", ":", "mapping", ".", "originalLine", ",", "column", ":", "mapping", ".", "originalColumn", "}", ",", "generated", ":", "{", "line", ":", "index", "+", "mapping", ".", "generatedLine", "-", "1", ",", "column", ":", "mapping", ".", "generatedColumn", "}", "}", ")", ";", "}", ")", ";", "inConsumer", ".", "sources", ".", "forEach", "(", "(", "source", ",", "idx", ")", "=>", "{", "outMap", ".", "setSourceContent", "(", "source", ",", "inConsumer", ".", "sourcesContent", "[", "idx", "]", ")", ";", "}", ")", ";", "}", "}" ]
Insert line in 'outMap' with 'inMap' at line 'index' @param {SourceMapGenerator} outMap @param {SourceMapGenerator} [inMap] @param {Number} length @param {Number} index
[ "Insert", "line", "in", "outMap", "with", "inMap", "at", "line", "index" ]
c38afc2e6915743eb6cfcf5aba59a8699142c7a5
https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/sourceMap.js#L156-L188
train
popeindustries/buddy
lib/utils/sourceMap.js
emptySources
function emptySources(map) { return !map.sources || !map.sources.length || !map.sourcesContent || !map.sourcesContent.length || map.sources.length != map.sourcesContent.length; }
javascript
function emptySources(map) { return !map.sources || !map.sources.length || !map.sourcesContent || !map.sourcesContent.length || map.sources.length != map.sourcesContent.length; }
[ "function", "emptySources", "(", "map", ")", "{", "return", "!", "map", ".", "sources", "||", "!", "map", ".", "sources", ".", "length", "||", "!", "map", ".", "sourcesContent", "||", "!", "map", ".", "sourcesContent", ".", "length", "||", "map", ".", "sources", ".", "length", "!=", "map", ".", "sourcesContent", ".", "length", ";", "}" ]
Determine if 'map' has empty sources @param {Object} map @returns {Boolean}
[ "Determine", "if", "map", "has", "empty", "sources" ]
c38afc2e6915743eb6cfcf5aba59a8699142c7a5
https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/utils/sourceMap.js#L195-L201
train
SockDrawer/SockBot
providers/nodebb/notification.js
notifyHandler
function notifyHandler(data) { const notification = Notification.parse(data); return evalBlacklist(notification) .then(() => { forum.emit('log', `Notification ${notification.id}: ${notification.label} received`); const ids = { post: notification.postId, topic: notification.topicId, user: notification.userId, pm: -1, chat: -1 }; return notification.getText() .then((postData) => forum.Commands.get(ids, postData, (content) => forum.Post.reply(notification.topicId, notification.postId, content))) .then((commands) => { if (commands.commands.length === 0) { debug(`Emitting events: 'notification' and 'notification:${notification.type}'`); forum.emit(`notification:${notification.type}`, notification); forum.emit('notification', notification); } return commands; }) .then((commands) => commands.execute()); }).catch((err) => { if (err === 'Ignoring notification') { //We do not process the notification, but we can continue with life return Promise.resolve(); } throw err; }); }
javascript
function notifyHandler(data) { const notification = Notification.parse(data); return evalBlacklist(notification) .then(() => { forum.emit('log', `Notification ${notification.id}: ${notification.label} received`); const ids = { post: notification.postId, topic: notification.topicId, user: notification.userId, pm: -1, chat: -1 }; return notification.getText() .then((postData) => forum.Commands.get(ids, postData, (content) => forum.Post.reply(notification.topicId, notification.postId, content))) .then((commands) => { if (commands.commands.length === 0) { debug(`Emitting events: 'notification' and 'notification:${notification.type}'`); forum.emit(`notification:${notification.type}`, notification); forum.emit('notification', notification); } return commands; }) .then((commands) => commands.execute()); }).catch((err) => { if (err === 'Ignoring notification') { //We do not process the notification, but we can continue with life return Promise.resolve(); } throw err; }); }
[ "function", "notifyHandler", "(", "data", ")", "{", "const", "notification", "=", "Notification", ".", "parse", "(", "data", ")", ";", "return", "evalBlacklist", "(", "notification", ")", ".", "then", "(", "(", ")", "=>", "{", "forum", ".", "emit", "(", "'log'", ",", "`", "${", "notification", ".", "id", "}", "${", "notification", ".", "label", "}", "`", ")", ";", "const", "ids", "=", "{", "post", ":", "notification", ".", "postId", ",", "topic", ":", "notification", ".", "topicId", ",", "user", ":", "notification", ".", "userId", ",", "pm", ":", "-", "1", ",", "chat", ":", "-", "1", "}", ";", "return", "notification", ".", "getText", "(", ")", ".", "then", "(", "(", "postData", ")", "=>", "forum", ".", "Commands", ".", "get", "(", "ids", ",", "postData", ",", "(", "content", ")", "=>", "forum", ".", "Post", ".", "reply", "(", "notification", ".", "topicId", ",", "notification", ".", "postId", ",", "content", ")", ")", ")", ".", "then", "(", "(", "commands", ")", "=>", "{", "if", "(", "commands", ".", "commands", ".", "length", "===", "0", ")", "{", "debug", "(", "`", "${", "notification", ".", "type", "}", "`", ")", ";", "forum", ".", "emit", "(", "`", "${", "notification", ".", "type", "}", "`", ",", "notification", ")", ";", "forum", ".", "emit", "(", "'notification'", ",", "notification", ")", ";", "}", "return", "commands", ";", "}", ")", ".", "then", "(", "(", "commands", ")", "=>", "commands", ".", "execute", "(", ")", ")", ";", "}", ")", ".", "catch", "(", "(", "err", ")", "=>", "{", "if", "(", "err", "===", "'Ignoring notification'", ")", "{", "return", "Promise", ".", "resolve", "(", ")", ";", "}", "throw", "err", ";", "}", ")", ";", "}" ]
Handle notifications that arrive Parse notification from event and process any commands cound within @private @param {*} data Notification data @returns {Promise} Resolved when any commands contained in notificaiton have been processed
[ "Handle", "notifications", "that", "arrive" ]
043f7e9aa9ec12250889fd825ddcf86709b095a3
https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/providers/nodebb/notification.js#L386-L418
train
SockDrawer/SockBot
providers/nodebb/notification.js
evalBlacklist
function evalBlacklist(notification) { return new Promise((resolve, reject) => { const ignoreCategories = forum.config.core.ignoreCategories || []; //if there's no blacklist, we can ignore the hit for getting the category if (ignoreCategories.length) { if (ignoreCategories.some((elem) => elem.toString() === notification.categoryId.toString())) { forum.emit('log', `Notification from category ${notification.categoryId} ignored`); return reject('Ignoring notification'); } } return resolve(notification); }); }
javascript
function evalBlacklist(notification) { return new Promise((resolve, reject) => { const ignoreCategories = forum.config.core.ignoreCategories || []; //if there's no blacklist, we can ignore the hit for getting the category if (ignoreCategories.length) { if (ignoreCategories.some((elem) => elem.toString() === notification.categoryId.toString())) { forum.emit('log', `Notification from category ${notification.categoryId} ignored`); return reject('Ignoring notification'); } } return resolve(notification); }); }
[ "function", "evalBlacklist", "(", "notification", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "const", "ignoreCategories", "=", "forum", ".", "config", ".", "core", ".", "ignoreCategories", "||", "[", "]", ";", "if", "(", "ignoreCategories", ".", "length", ")", "{", "if", "(", "ignoreCategories", ".", "some", "(", "(", "elem", ")", "=>", "elem", ".", "toString", "(", ")", "===", "notification", ".", "categoryId", ".", "toString", "(", ")", ")", ")", "{", "forum", ".", "emit", "(", "'log'", ",", "`", "${", "notification", ".", "categoryId", "}", "`", ")", ";", "return", "reject", "(", "'Ignoring notification'", ")", ";", "}", "}", "return", "resolve", "(", "notification", ")", ";", "}", ")", ";", "}" ]
Evaluate the blacklist. Determine if we want to process this notification or not based on config settings @private @param {*} notification Notification we are parsing @returns {Promise} Rejects with "Ignoring notification" if we do not process this. Resolves with the notification otherwise.
[ "Evaluate", "the", "blacklist", "." ]
043f7e9aa9ec12250889fd825ddcf86709b095a3
https://github.com/SockDrawer/SockBot/blob/043f7e9aa9ec12250889fd825ddcf86709b095a3/providers/nodebb/notification.js#L431-L444
train
ghempton/ember-script
ember-runtime.js
normalizeTuple
function normalizeTuple(target, path) { var hasThis = HAS_THIS.test(path), isGlobal = !hasThis && IS_GLOBAL_PATH.test(path), key; if (!target || isGlobal) target = Ember.lookup; if (hasThis) path = path.slice(5); if (target === Ember.lookup) { key = firstKey(path); target = get(target, key); path = path.slice(key.length+1); } // must return some kind of path to be valid else other things will break. if (!path || path.length===0) throw new Error('Invalid Path'); return [ target, path ]; }
javascript
function normalizeTuple(target, path) { var hasThis = HAS_THIS.test(path), isGlobal = !hasThis && IS_GLOBAL_PATH.test(path), key; if (!target || isGlobal) target = Ember.lookup; if (hasThis) path = path.slice(5); if (target === Ember.lookup) { key = firstKey(path); target = get(target, key); path = path.slice(key.length+1); } // must return some kind of path to be valid else other things will break. if (!path || path.length===0) throw new Error('Invalid Path'); return [ target, path ]; }
[ "function", "normalizeTuple", "(", "target", ",", "path", ")", "{", "var", "hasThis", "=", "HAS_THIS", ".", "test", "(", "path", ")", ",", "isGlobal", "=", "!", "hasThis", "&&", "IS_GLOBAL_PATH", ".", "test", "(", "path", ")", ",", "key", ";", "if", "(", "!", "target", "||", "isGlobal", ")", "target", "=", "Ember", ".", "lookup", ";", "if", "(", "hasThis", ")", "path", "=", "path", ".", "slice", "(", "5", ")", ";", "if", "(", "target", "===", "Ember", ".", "lookup", ")", "{", "key", "=", "firstKey", "(", "path", ")", ";", "target", "=", "get", "(", "target", ",", "key", ")", ";", "path", "=", "path", ".", "slice", "(", "key", ".", "length", "+", "1", ")", ";", "}", "if", "(", "!", "path", "||", "path", ".", "length", "===", "0", ")", "throw", "new", "Error", "(", "'Invalid Path'", ")", ";", "return", "[", "target", ",", "path", "]", ";", "}" ]
assumes path is already normalized
[ "assumes", "path", "is", "already", "normalized" ]
af6596868bb84c2d43eca30ca0d90244ef3419fd
https://github.com/ghempton/ember-script/blob/af6596868bb84c2d43eca30ca0d90244ef3419fd/ember-runtime.js#L1957-L1975
train
ghempton/ember-script
ember-runtime.js
chainsFor
function chainsFor(obj) { var m = metaFor(obj), ret = m.chains; if (!ret) { ret = m.chains = new ChainNode(null, null, obj); } else if (ret.value() !== obj) { ret = m.chains = ret.copy(obj); } return ret; }
javascript
function chainsFor(obj) { var m = metaFor(obj), ret = m.chains; if (!ret) { ret = m.chains = new ChainNode(null, null, obj); } else if (ret.value() !== obj) { ret = m.chains = ret.copy(obj); } return ret; }
[ "function", "chainsFor", "(", "obj", ")", "{", "var", "m", "=", "metaFor", "(", "obj", ")", ",", "ret", "=", "m", ".", "chains", ";", "if", "(", "!", "ret", ")", "{", "ret", "=", "m", ".", "chains", "=", "new", "ChainNode", "(", "null", ",", "null", ",", "obj", ")", ";", "}", "else", "if", "(", "ret", ".", "value", "(", ")", "!==", "obj", ")", "{", "ret", "=", "m", ".", "chains", "=", "ret", ".", "copy", "(", "obj", ")", ";", "}", "return", "ret", ";", "}" ]
get the chains for the current object. If the current object has chains inherited from the proto they will be cloned and reconfigured for the current object.
[ "get", "the", "chains", "for", "the", "current", "object", ".", "If", "the", "current", "object", "has", "chains", "inherited", "from", "the", "proto", "they", "will", "be", "cloned", "and", "reconfigured", "for", "the", "current", "object", "." ]
af6596868bb84c2d43eca30ca0d90244ef3419fd
https://github.com/ghempton/ember-script/blob/af6596868bb84c2d43eca30ca0d90244ef3419fd/ember-runtime.js#L3411-L3419
train
ghempton/ember-script
ember-runtime.js
function() { var ret = Ember.A([]); this.forEach(function(o, idx) { ret[idx] = o; }); return ret ; }
javascript
function() { var ret = Ember.A([]); this.forEach(function(o, idx) { ret[idx] = o; }); return ret ; }
[ "function", "(", ")", "{", "var", "ret", "=", "Ember", ".", "A", "(", "[", "]", ")", ";", "this", ".", "forEach", "(", "function", "(", "o", ",", "idx", ")", "{", "ret", "[", "idx", "]", "=", "o", ";", "}", ")", ";", "return", "ret", ";", "}" ]
Simply converts the enumerable into a genuine array. The order is not guaranteed. Corresponds to the method implemented by Prototype. @method toArray @return {Array} the enumerable as an array.
[ "Simply", "converts", "the", "enumerable", "into", "a", "genuine", "array", ".", "The", "order", "is", "not", "guaranteed", ".", "Corresponds", "to", "the", "method", "implemented", "by", "Prototype", "." ]
af6596868bb84c2d43eca30ca0d90244ef3419fd
https://github.com/ghempton/ember-script/blob/af6596868bb84c2d43eca30ca0d90244ef3419fd/ember-runtime.js#L8340-L8344
train
ghempton/ember-script
ember-runtime.js
function() { if (Ember.Freezable && Ember.Freezable.detect(this)) { return get(this, 'isFrozen') ? this : this.copy().freeze(); } else { throw new Error(Ember.String.fmt("%@ does not support freezing", [this])); } }
javascript
function() { if (Ember.Freezable && Ember.Freezable.detect(this)) { return get(this, 'isFrozen') ? this : this.copy().freeze(); } else { throw new Error(Ember.String.fmt("%@ does not support freezing", [this])); } }
[ "function", "(", ")", "{", "if", "(", "Ember", ".", "Freezable", "&&", "Ember", ".", "Freezable", ".", "detect", "(", "this", ")", ")", "{", "return", "get", "(", "this", ",", "'isFrozen'", ")", "?", "this", ":", "this", ".", "copy", "(", ")", ".", "freeze", "(", ")", ";", "}", "else", "{", "throw", "new", "Error", "(", "Ember", ".", "String", ".", "fmt", "(", "\"%@ does not support freezing\"", ",", "[", "this", "]", ")", ")", ";", "}", "}" ]
If the object implements `Ember.Freezable`, then this will return a new copy if the object is not frozen and the receiver if the object is frozen. Raises an exception if you try to call this method on a object that does not support freezing. You should use this method whenever you want a copy of a freezable object since a freezable object can simply return itself without actually consuming more memory. @method frozenCopy @return {Object} copy of receiver or receiver
[ "If", "the", "object", "implements", "Ember", ".", "Freezable", "then", "this", "will", "return", "a", "new", "copy", "if", "the", "object", "is", "not", "frozen", "and", "the", "receiver", "if", "the", "object", "is", "frozen", "." ]
af6596868bb84c2d43eca30ca0d90244ef3419fd
https://github.com/ghempton/ember-script/blob/af6596868bb84c2d43eca30ca0d90244ef3419fd/ember-runtime.js#L9082-L9088
train
ghempton/ember-script
ember-runtime.js
function(keyName, increment) { if (!increment) { increment = 1; } set(this, keyName, (get(this, keyName) || 0)+increment); return get(this, keyName); }
javascript
function(keyName, increment) { if (!increment) { increment = 1; } set(this, keyName, (get(this, keyName) || 0)+increment); return get(this, keyName); }
[ "function", "(", "keyName", ",", "increment", ")", "{", "if", "(", "!", "increment", ")", "{", "increment", "=", "1", ";", "}", "set", "(", "this", ",", "keyName", ",", "(", "get", "(", "this", ",", "keyName", ")", "||", "0", ")", "+", "increment", ")", ";", "return", "get", "(", "this", ",", "keyName", ")", ";", "}" ]
Set the value of a property to the current value plus some amount. ```javascript person.incrementProperty('age'); team.incrementProperty('score', 2); ``` @method incrementProperty @param {String} keyName The name of the property to increment @param {Object} increment The amount to increment by. Defaults to 1 @return {Object} The new property value
[ "Set", "the", "value", "of", "a", "property", "to", "the", "current", "value", "plus", "some", "amount", "." ]
af6596868bb84c2d43eca30ca0d90244ef3419fd
https://github.com/ghempton/ember-script/blob/af6596868bb84c2d43eca30ca0d90244ef3419fd/ember-runtime.js#L10072-L10076
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
_gpfGenSuperMember
function _gpfGenSuperMember (superMethod, method) { return function GpfSuperableMethod () { var previousSuper = this._super, result; // Add a new ._super() method pointing to the base class member this._super = superMethod; try { // Execute the method result = method.apply(this, arguments); } finally { // Remove it after execution if (undefined === previousSuper) { delete this._super; } else { this._super = previousSuper; } } return result; }; }
javascript
function _gpfGenSuperMember (superMethod, method) { return function GpfSuperableMethod () { var previousSuper = this._super, result; // Add a new ._super() method pointing to the base class member this._super = superMethod; try { // Execute the method result = method.apply(this, arguments); } finally { // Remove it after execution if (undefined === previousSuper) { delete this._super; } else { this._super = previousSuper; } } return result; }; }
[ "function", "_gpfGenSuperMember", "(", "superMethod", ",", "method", ")", "{", "return", "function", "GpfSuperableMethod", "(", ")", "{", "var", "previousSuper", "=", "this", ".", "_super", ",", "result", ";", "this", ".", "_super", "=", "superMethod", ";", "try", "{", "result", "=", "method", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "finally", "{", "if", "(", "undefined", "===", "previousSuper", ")", "{", "delete", "this", ".", "_super", ";", "}", "else", "{", "this", ".", "_super", "=", "previousSuper", ";", "}", "}", "return", "result", ";", "}", ";", "}" ]
Generates a closure in which this._super points to the base method of the overridden member @param {Function} superMethod @param {Function} method @return {Function} @gpf:closure
[ "Generates", "a", "closure", "in", "which", "this", ".", "_super", "points", "to", "the", "base", "method", "of", "the", "overridden", "member" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L73-L92
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
_GpfOldClassDefinition
function _GpfOldClassDefinition (name, Super, definition) { /*jshint validthis:true*/ // constructor this._uid = ++_gpfClassDefUID; _gpfClassDefinitions[this._uid] = this; this._Subs = []; if ("function" === typeof name) { this._name = name.compatibleName() || "anonymous"; // TODO how do we grab the parent constructor (?) this._Constructor = name; } else { this._name = name; this._Super = Super; this._definition = definition; this._build(); } }
javascript
function _GpfOldClassDefinition (name, Super, definition) { /*jshint validthis:true*/ // constructor this._uid = ++_gpfClassDefUID; _gpfClassDefinitions[this._uid] = this; this._Subs = []; if ("function" === typeof name) { this._name = name.compatibleName() || "anonymous"; // TODO how do we grab the parent constructor (?) this._Constructor = name; } else { this._name = name; this._Super = Super; this._definition = definition; this._build(); } }
[ "function", "_GpfOldClassDefinition", "(", "name", ",", "Super", ",", "definition", ")", "{", "this", ".", "_uid", "=", "++", "_gpfClassDefUID", ";", "_gpfClassDefinitions", "[", "this", ".", "_uid", "]", "=", "this", ";", "this", ".", "_Subs", "=", "[", "]", ";", "if", "(", "\"function\"", "===", "typeof", "name", ")", "{", "this", ".", "_name", "=", "name", ".", "compatibleName", "(", ")", "||", "\"anonymous\"", ";", "this", ".", "_Constructor", "=", "name", ";", "}", "else", "{", "this", ".", "_name", "=", "name", ";", "this", ".", "_Super", "=", "Super", ";", "this", ".", "_definition", "=", "definition", ";", "this", ".", "_build", "(", ")", ";", "}", "}" ]
An helper to create class and store its information @param {String|Function} name @param {Function} Super @param {Object} definition @class gpf.ClassDefinition @constructor
[ "An", "helper", "to", "create", "class", "and", "store", "its", "information" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L117-L132
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function (member, memberValue, visibility) { if (undefined === visibility) { visibility = _GPF_VISIBILITY_PUBLIC; } else { visibility = _gpfVisibilityKeywords.indexOf(visibility); if (-1 === visibility) { gpf.Error.classInvalidVisibility(); } } this._addMember(member, memberValue, visibility); }
javascript
function (member, memberValue, visibility) { if (undefined === visibility) { visibility = _GPF_VISIBILITY_PUBLIC; } else { visibility = _gpfVisibilityKeywords.indexOf(visibility); if (-1 === visibility) { gpf.Error.classInvalidVisibility(); } } this._addMember(member, memberValue, visibility); }
[ "function", "(", "member", ",", "memberValue", ",", "visibility", ")", "{", "if", "(", "undefined", "===", "visibility", ")", "{", "visibility", "=", "_GPF_VISIBILITY_PUBLIC", ";", "}", "else", "{", "visibility", "=", "_gpfVisibilityKeywords", ".", "indexOf", "(", "visibility", ")", ";", "if", "(", "-", "1", "===", "visibility", ")", "{", "gpf", ".", "Error", ".", "classInvalidVisibility", "(", ")", ";", "}", "}", "this", ".", "_addMember", "(", "member", ",", "memberValue", ",", "visibility", ")", ";", "}" ]
Adds a member to the class definition. @param {String} member @param {*} memberValue @param {String|number} [visibility=_GPF_VISIBILITY_PUBLIC] visibility
[ "Adds", "a", "member", "to", "the", "class", "definition", "." ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L201-L211
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function (member, memberValue, visibility) { if (_GPF_VISIBILITY_STATIC === visibility) { _gpfAssert(undefined === this._Constructor[member], "Static members can't be overridden"); this._Constructor[member] = memberValue; } else if ("constructor" === member) { this._addConstructor(memberValue, visibility); } else { this._addNonStaticMember(member, memberValue, visibility); } }
javascript
function (member, memberValue, visibility) { if (_GPF_VISIBILITY_STATIC === visibility) { _gpfAssert(undefined === this._Constructor[member], "Static members can't be overridden"); this._Constructor[member] = memberValue; } else if ("constructor" === member) { this._addConstructor(memberValue, visibility); } else { this._addNonStaticMember(member, memberValue, visibility); } }
[ "function", "(", "member", ",", "memberValue", ",", "visibility", ")", "{", "if", "(", "_GPF_VISIBILITY_STATIC", "===", "visibility", ")", "{", "_gpfAssert", "(", "undefined", "===", "this", ".", "_Constructor", "[", "member", "]", ",", "\"Static members can't be overridden\"", ")", ";", "this", ".", "_Constructor", "[", "member", "]", "=", "memberValue", ";", "}", "else", "if", "(", "\"constructor\"", "===", "member", ")", "{", "this", ".", "_addConstructor", "(", "memberValue", ",", "visibility", ")", ";", "}", "else", "{", "this", ".", "_addNonStaticMember", "(", "member", ",", "memberValue", ",", "visibility", ")", ";", "}", "}" ]
Adds a member to the class definition @param {String} member @param {*} memberValue @param {number} visibility
[ "Adds", "a", "member", "to", "the", "class", "definition" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L220-L229
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function (memberValue, visibility) { _gpfAsserts({ "Constructor must be a function": "function" === typeof memberValue, "Own constructor can't be overridden": null === this._definitionConstructor }); if (_gpfUsesSuper(memberValue)) { memberValue = _gpfGenSuperMember(this._Super, memberValue); } _gpfIgnore(visibility); // TODO Handle constructor visibility this._definitionConstructor = memberValue; }
javascript
function (memberValue, visibility) { _gpfAsserts({ "Constructor must be a function": "function" === typeof memberValue, "Own constructor can't be overridden": null === this._definitionConstructor }); if (_gpfUsesSuper(memberValue)) { memberValue = _gpfGenSuperMember(this._Super, memberValue); } _gpfIgnore(visibility); // TODO Handle constructor visibility this._definitionConstructor = memberValue; }
[ "function", "(", "memberValue", ",", "visibility", ")", "{", "_gpfAsserts", "(", "{", "\"Constructor must be a function\"", ":", "\"function\"", "===", "typeof", "memberValue", ",", "\"Own constructor can't be overridden\"", ":", "null", "===", "this", ".", "_definitionConstructor", "}", ")", ";", "if", "(", "_gpfUsesSuper", "(", "memberValue", ")", ")", "{", "memberValue", "=", "_gpfGenSuperMember", "(", "this", ".", "_Super", ",", "memberValue", ")", ";", "}", "_gpfIgnore", "(", "visibility", ")", ";", "this", ".", "_definitionConstructor", "=", "memberValue", ";", "}" ]
Adds a constructor the class definition @param {*} memberValue Must be a function @param {number} visibility @gpf:closure
[ "Adds", "a", "constructor", "the", "class", "definition" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L238-L248
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function (member, memberValue, visibility) { var newType = typeof memberValue, baseMemberValue, baseType, prototype = this._Constructor.prototype; _gpfAssert(!prototype.hasOwnProperty(member), "Existing own member can't be overridden"); baseMemberValue = this._Super.prototype[member]; baseType = typeof baseMemberValue; if ("undefined" !== baseType) { if (null !== baseMemberValue && newType !== baseType) { gpf.Error.classMemberOverloadWithTypeChange(); } if ("function" === newType && _gpfUsesSuper(memberValue)) { memberValue = _gpfGenSuperMember(baseMemberValue, memberValue); } } _gpfIgnore(visibility); // TODO Handle constructor visibility prototype[member] = memberValue; }
javascript
function (member, memberValue, visibility) { var newType = typeof memberValue, baseMemberValue, baseType, prototype = this._Constructor.prototype; _gpfAssert(!prototype.hasOwnProperty(member), "Existing own member can't be overridden"); baseMemberValue = this._Super.prototype[member]; baseType = typeof baseMemberValue; if ("undefined" !== baseType) { if (null !== baseMemberValue && newType !== baseType) { gpf.Error.classMemberOverloadWithTypeChange(); } if ("function" === newType && _gpfUsesSuper(memberValue)) { memberValue = _gpfGenSuperMember(baseMemberValue, memberValue); } } _gpfIgnore(visibility); // TODO Handle constructor visibility prototype[member] = memberValue; }
[ "function", "(", "member", ",", "memberValue", ",", "visibility", ")", "{", "var", "newType", "=", "typeof", "memberValue", ",", "baseMemberValue", ",", "baseType", ",", "prototype", "=", "this", ".", "_Constructor", ".", "prototype", ";", "_gpfAssert", "(", "!", "prototype", ".", "hasOwnProperty", "(", "member", ")", ",", "\"Existing own member can't be overridden\"", ")", ";", "baseMemberValue", "=", "this", ".", "_Super", ".", "prototype", "[", "member", "]", ";", "baseType", "=", "typeof", "baseMemberValue", ";", "if", "(", "\"undefined\"", "!==", "baseType", ")", "{", "if", "(", "null", "!==", "baseMemberValue", "&&", "newType", "!==", "baseType", ")", "{", "gpf", ".", "Error", ".", "classMemberOverloadWithTypeChange", "(", ")", ";", "}", "if", "(", "\"function\"", "===", "newType", "&&", "_gpfUsesSuper", "(", "memberValue", ")", ")", "{", "memberValue", "=", "_gpfGenSuperMember", "(", "baseMemberValue", ",", "memberValue", ")", ";", "}", "}", "_gpfIgnore", "(", "visibility", ")", ";", "prototype", "[", "member", "]", "=", "memberValue", ";", "}" ]
Defines a new non-static member of the class @param {String} member Name of the member to define @param {*} memberValue @param {Number} visibility Visibility of the members @gpf:closure
[ "Defines", "a", "new", "non", "-", "static", "member", "of", "the", "class" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L258-L276
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function (member) { if ("[" !== member.charAt(0) || "]" !== member.charAt(member.length - 1)) { return ""; } return _gpfEncodeAttributeMember(member.substr(1, member.length - 2)); // Extract & encode member name }
javascript
function (member) { if ("[" !== member.charAt(0) || "]" !== member.charAt(member.length - 1)) { return ""; } return _gpfEncodeAttributeMember(member.substr(1, member.length - 2)); // Extract & encode member name }
[ "function", "(", "member", ")", "{", "if", "(", "\"[\"", "!==", "member", ".", "charAt", "(", "0", ")", "||", "\"]\"", "!==", "member", ".", "charAt", "(", "member", ".", "length", "-", "1", ")", ")", "{", "return", "\"\"", ";", "}", "return", "_gpfEncodeAttributeMember", "(", "member", ".", "substr", "(", "1", ",", "member", ".", "length", "-", "2", ")", ")", ";", "}" ]
Check if the member represents an attribute and extracts the name
[ "Check", "if", "the", "member", "represents", "an", "attribute", "and", "extracts", "the", "name" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L279-L284
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function (attributeName, attributeValue) { var attributeArray; if (this._definitionAttributes) { attributeArray = this._definitionAttributes[attributeName]; } else { this._definitionAttributes = {}; } if (undefined === attributeArray) { attributeArray = []; } this._definitionAttributes[attributeName] = attributeArray.concat(attributeValue); }
javascript
function (attributeName, attributeValue) { var attributeArray; if (this._definitionAttributes) { attributeArray = this._definitionAttributes[attributeName]; } else { this._definitionAttributes = {}; } if (undefined === attributeArray) { attributeArray = []; } this._definitionAttributes[attributeName] = attributeArray.concat(attributeValue); }
[ "function", "(", "attributeName", ",", "attributeValue", ")", "{", "var", "attributeArray", ";", "if", "(", "this", ".", "_definitionAttributes", ")", "{", "attributeArray", "=", "this", ".", "_definitionAttributes", "[", "attributeName", "]", ";", "}", "else", "{", "this", ".", "_definitionAttributes", "=", "{", "}", ";", "}", "if", "(", "undefined", "===", "attributeArray", ")", "{", "attributeArray", "=", "[", "]", ";", "}", "this", ".", "_definitionAttributes", "[", "attributeName", "]", "=", "attributeArray", ".", "concat", "(", "attributeValue", ")", ";", "}" ]
store the attribute for later usage
[ "store", "the", "attribute", "for", "later", "usage" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L287-L298
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function (member, memberValue) { var attributeName = this._extractAttributeName(member); if (!attributeName) { return false; } this._addToDefinitionAttributes(attributeName, memberValue); return true; }
javascript
function (member, memberValue) { var attributeName = this._extractAttributeName(member); if (!attributeName) { return false; } this._addToDefinitionAttributes(attributeName, memberValue); return true; }
[ "function", "(", "member", ",", "memberValue", ")", "{", "var", "attributeName", "=", "this", ".", "_extractAttributeName", "(", "member", ")", ";", "if", "(", "!", "attributeName", ")", "{", "return", "false", ";", "}", "this", ".", "_addToDefinitionAttributes", "(", "attributeName", ",", "memberValue", ")", ";", "return", "true", ";", "}" ]
Check if the current member is an attribute declaration. If so, stores it into a temporary map that will be processed as the last step. @param {String} member @param {*} memberValue @returns {Boolean} True when an attribute is detected
[ "Check", "if", "the", "current", "member", "is", "an", "attribute", "declaration", ".", "If", "so", "stores", "it", "into", "a", "temporary", "map", "that", "will", "be", "processed", "as", "the", "last", "step", "." ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L308-L315
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function (memberName) { var visibility = this._defaultVisibility; if (_GPF_VISIBILITY_UNKNOWN === visibility) { if (memberName.charAt(0) === "_") { visibility = _GPF_VISIBILITY_PROTECTED; } else { visibility = _GPF_VISIBILITY_PUBLIC; } } return visibility; }
javascript
function (memberName) { var visibility = this._defaultVisibility; if (_GPF_VISIBILITY_UNKNOWN === visibility) { if (memberName.charAt(0) === "_") { visibility = _GPF_VISIBILITY_PROTECTED; } else { visibility = _GPF_VISIBILITY_PUBLIC; } } return visibility; }
[ "function", "(", "memberName", ")", "{", "var", "visibility", "=", "this", ".", "_defaultVisibility", ";", "if", "(", "_GPF_VISIBILITY_UNKNOWN", "===", "visibility", ")", "{", "if", "(", "memberName", ".", "charAt", "(", "0", ")", "===", "\"_\"", ")", "{", "visibility", "=", "_GPF_VISIBILITY_PROTECTED", ";", "}", "else", "{", "visibility", "=", "_GPF_VISIBILITY_PUBLIC", ";", "}", "}", "return", "visibility", ";", "}" ]
Compute member visibility from default visibility & member name
[ "Compute", "member", "visibility", "from", "default", "visibility", "&", "member", "name" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L321-L331
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function (memberValue, memberName) { if (this._filterAttribute(memberName, memberValue)) { return; } var newVisibility = _gpfVisibilityKeywords.indexOf(memberName); if (_GPF_VISIBILITY_UNKNOWN === newVisibility) { return this._addMember(memberName, memberValue, this._deduceVisibility(memberName)); } if (_GPF_VISIBILITY_UNKNOWN !== this._defaultVisibility) { gpf.Error.classInvalidVisibility(); } this._processDefinition(memberValue, newVisibility); }
javascript
function (memberValue, memberName) { if (this._filterAttribute(memberName, memberValue)) { return; } var newVisibility = _gpfVisibilityKeywords.indexOf(memberName); if (_GPF_VISIBILITY_UNKNOWN === newVisibility) { return this._addMember(memberName, memberValue, this._deduceVisibility(memberName)); } if (_GPF_VISIBILITY_UNKNOWN !== this._defaultVisibility) { gpf.Error.classInvalidVisibility(); } this._processDefinition(memberValue, newVisibility); }
[ "function", "(", "memberValue", ",", "memberName", ")", "{", "if", "(", "this", ".", "_filterAttribute", "(", "memberName", ",", "memberValue", ")", ")", "{", "return", ";", "}", "var", "newVisibility", "=", "_gpfVisibilityKeywords", ".", "indexOf", "(", "memberName", ")", ";", "if", "(", "_GPF_VISIBILITY_UNKNOWN", "===", "newVisibility", ")", "{", "return", "this", ".", "_addMember", "(", "memberName", ",", "memberValue", ",", "this", ".", "_deduceVisibility", "(", "memberName", ")", ")", ";", "}", "if", "(", "_GPF_VISIBILITY_UNKNOWN", "!==", "this", ".", "_defaultVisibility", ")", "{", "gpf", ".", "Error", ".", "classInvalidVisibility", "(", ")", ";", "}", "this", ".", "_processDefinition", "(", "memberValue", ",", "newVisibility", ")", ";", "}" ]
Process definition member. The member may be a visibility keyword, in that case _processDefinition is called recursively @param {*} memberValue @param {string} memberName
[ "Process", "definition", "member", ".", "The", "member", "may", "be", "a", "visibility", "keyword", "in", "that", "case", "_processDefinition", "is", "called", "recursively" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L340-L352
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function (definition, visibility) { var isWScript = _GPF_HOST.WSCRIPT === _gpfHost; this._defaultVisibility = visibility; _gpfObjectForEach(definition, this._processDefinitionMember, this); if (isWScript && definition.hasOwnProperty("toString")) { this._processDefinitionMember(definition.toString, "toString"); } this._defaultVisibility = _GPF_VISIBILITY_UNKNOWN; if (isWScript && definition.hasOwnProperty("constructor")) { this._addConstructor(definition.constructor, this._defaultVisibility); } }
javascript
function (definition, visibility) { var isWScript = _GPF_HOST.WSCRIPT === _gpfHost; this._defaultVisibility = visibility; _gpfObjectForEach(definition, this._processDefinitionMember, this); if (isWScript && definition.hasOwnProperty("toString")) { this._processDefinitionMember(definition.toString, "toString"); } this._defaultVisibility = _GPF_VISIBILITY_UNKNOWN; if (isWScript && definition.hasOwnProperty("constructor")) { this._addConstructor(definition.constructor, this._defaultVisibility); } }
[ "function", "(", "definition", ",", "visibility", ")", "{", "var", "isWScript", "=", "_GPF_HOST", ".", "WSCRIPT", "===", "_gpfHost", ";", "this", ".", "_defaultVisibility", "=", "visibility", ";", "_gpfObjectForEach", "(", "definition", ",", "this", ".", "_processDefinitionMember", ",", "this", ")", ";", "if", "(", "isWScript", "&&", "definition", ".", "hasOwnProperty", "(", "\"toString\"", ")", ")", "{", "this", ".", "_processDefinitionMember", "(", "definition", ".", "toString", ",", "\"toString\"", ")", ";", "}", "this", ".", "_defaultVisibility", "=", "_GPF_VISIBILITY_UNKNOWN", ";", "if", "(", "isWScript", "&&", "definition", ".", "hasOwnProperty", "(", "\"constructor\"", ")", ")", "{", "this", ".", "_addConstructor", "(", "definition", ".", "constructor", ",", "this", ".", "_defaultVisibility", ")", ";", "}", "}" ]
Process class definition @param {Object} definition @param {Number} visibility
[ "Process", "class", "definition" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L360-L371
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function () { var attributes = this._definitionAttributes, Constructor, newPrototype; if (attributes) { _gpfAssert("function" === typeof _gpfAttributesAdd, "Attributes can't be defined before they exist"); Constructor = this._Constructor; newPrototype = Constructor.prototype; _gpfObjectForEach(attributes, function (attributeList, attributeName) { attributeName = _gpfDecodeAttributeMember(attributeName); if (attributeName in newPrototype || attributeName === "Class") { _gpfAttributesAdd(Constructor, attributeName, attributeList); } else { // 2013-12-15 ABZ Exceptional, trace it only console.error("gpf.define: Invalid attribute name '" + attributeName + "'"); } }); } }
javascript
function () { var attributes = this._definitionAttributes, Constructor, newPrototype; if (attributes) { _gpfAssert("function" === typeof _gpfAttributesAdd, "Attributes can't be defined before they exist"); Constructor = this._Constructor; newPrototype = Constructor.prototype; _gpfObjectForEach(attributes, function (attributeList, attributeName) { attributeName = _gpfDecodeAttributeMember(attributeName); if (attributeName in newPrototype || attributeName === "Class") { _gpfAttributesAdd(Constructor, attributeName, attributeList); } else { // 2013-12-15 ABZ Exceptional, trace it only console.error("gpf.define: Invalid attribute name '" + attributeName + "'"); } }); } }
[ "function", "(", ")", "{", "var", "attributes", "=", "this", ".", "_definitionAttributes", ",", "Constructor", ",", "newPrototype", ";", "if", "(", "attributes", ")", "{", "_gpfAssert", "(", "\"function\"", "===", "typeof", "_gpfAttributesAdd", ",", "\"Attributes can't be defined before they exist\"", ")", ";", "Constructor", "=", "this", ".", "_Constructor", ";", "newPrototype", "=", "Constructor", ".", "prototype", ";", "_gpfObjectForEach", "(", "attributes", ",", "function", "(", "attributeList", ",", "attributeName", ")", "{", "attributeName", "=", "_gpfDecodeAttributeMember", "(", "attributeName", ")", ";", "if", "(", "attributeName", "in", "newPrototype", "||", "attributeName", "===", "\"Class\"", ")", "{", "_gpfAttributesAdd", "(", "Constructor", ",", "attributeName", ",", "attributeList", ")", ";", "}", "else", "{", "console", ".", "error", "(", "\"gpf.define: Invalid attribute name '\"", "+", "attributeName", "+", "\"'\"", ")", ";", "}", "}", ")", ";", "}", "}" ]
Process the attributes collected in the definition NOTE: gpf.attributes._add is defined in attributes.js
[ "Process", "the", "attributes", "collected", "in", "the", "definition" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L378-L397
train
ArnaudBuchholz/gpf-js
lost+found/src/define_/classdef.js
function () { var newClass, newPrototype, baseClassDef; // The new class constructor newClass = _getOldNewClassConstructor(this); this._Constructor = newClass; newClass[_GPF_CLASSDEF_MARKER] = this._uid; // Basic JavaScript inheritance mechanism: Defines the newClass prototype as an instance of the super class newPrototype = Object.create(this._Super.prototype); // Populate our constructed prototype object newClass.prototype = newPrototype; // Enforce the constructor to be what we expect newPrototype.constructor = newClass; /* * Defines the link between this class and its base one * (It is necessary to do it here because of the gpf.addAttributes that will test the parent class) */ baseClassDef = _gpfGetClassDefinition(this._Super); baseClassDef._Subs.push(newClass); /* * 2014-04-28 ABZ Changed again from two passes on all members to two passes in which the first one also * collects attributes to simplify the second pass. */ this._processDefinition(this._definition, _GPF_VISIBILITY_UNKNOWN); this._processAttributes(); // Optimization for the constructor this._resolveConstructor(); }
javascript
function () { var newClass, newPrototype, baseClassDef; // The new class constructor newClass = _getOldNewClassConstructor(this); this._Constructor = newClass; newClass[_GPF_CLASSDEF_MARKER] = this._uid; // Basic JavaScript inheritance mechanism: Defines the newClass prototype as an instance of the super class newPrototype = Object.create(this._Super.prototype); // Populate our constructed prototype object newClass.prototype = newPrototype; // Enforce the constructor to be what we expect newPrototype.constructor = newClass; /* * Defines the link between this class and its base one * (It is necessary to do it here because of the gpf.addAttributes that will test the parent class) */ baseClassDef = _gpfGetClassDefinition(this._Super); baseClassDef._Subs.push(newClass); /* * 2014-04-28 ABZ Changed again from two passes on all members to two passes in which the first one also * collects attributes to simplify the second pass. */ this._processDefinition(this._definition, _GPF_VISIBILITY_UNKNOWN); this._processAttributes(); // Optimization for the constructor this._resolveConstructor(); }
[ "function", "(", ")", "{", "var", "newClass", ",", "newPrototype", ",", "baseClassDef", ";", "newClass", "=", "_getOldNewClassConstructor", "(", "this", ")", ";", "this", ".", "_Constructor", "=", "newClass", ";", "newClass", "[", "_GPF_CLASSDEF_MARKER", "]", "=", "this", ".", "_uid", ";", "newPrototype", "=", "Object", ".", "create", "(", "this", ".", "_Super", ".", "prototype", ")", ";", "newClass", ".", "prototype", "=", "newPrototype", ";", "newPrototype", ".", "constructor", "=", "newClass", ";", "baseClassDef", "=", "_gpfGetClassDefinition", "(", "this", ".", "_Super", ")", ";", "baseClassDef", ".", "_Subs", ".", "push", "(", "newClass", ")", ";", "this", ".", "_processDefinition", "(", "this", ".", "_definition", ",", "_GPF_VISIBILITY_UNKNOWN", ")", ";", "this", ".", "_processAttributes", "(", ")", ";", "this", ".", "_resolveConstructor", "(", ")", ";", "}" ]
Create the new Class constructor
[ "Create", "the", "new", "Class", "constructor" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/lost+found/src/define_/classdef.js#L400-L436
train
ArnaudBuchholz/gpf-js
src/http/mock.js
_gpfHttMockMatchRequest
function _gpfHttMockMatchRequest (mockedRequest, request) { var url = mockedRequest.url, match; url.lastIndex = 0; match = url.exec(request.url); if (match) { return mockedRequest.response.apply(mockedRequest, [request].concat(_gpfArrayTail(match))); } }
javascript
function _gpfHttMockMatchRequest (mockedRequest, request) { var url = mockedRequest.url, match; url.lastIndex = 0; match = url.exec(request.url); if (match) { return mockedRequest.response.apply(mockedRequest, [request].concat(_gpfArrayTail(match))); } }
[ "function", "_gpfHttMockMatchRequest", "(", "mockedRequest", ",", "request", ")", "{", "var", "url", "=", "mockedRequest", ".", "url", ",", "match", ";", "url", ".", "lastIndex", "=", "0", ";", "match", "=", "url", ".", "exec", "(", "request", ".", "url", ")", ";", "if", "(", "match", ")", "{", "return", "mockedRequest", ".", "response", ".", "apply", "(", "mockedRequest", ",", "[", "request", "]", ".", "concat", "(", "_gpfArrayTail", "(", "match", ")", ")", ")", ";", "}", "}" ]
Match the provided request with the mocked one @param {gpf.typedef.mockedRequest} mockedRequest Mocked request to match @param {gpf.typedef.httpRequestSettings} request Request to match @return {Promise<gpf.typedef.httpRequestResponse>|undefined} undefined if not matching @since 0.2.2
[ "Match", "the", "provided", "request", "with", "the", "mocked", "one" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http/mock.js#L57-L65
train
ArnaudBuchholz/gpf-js
src/http/mock.js
_gpfHttMockMatch
function _gpfHttMockMatch (mockedRequests, request) { var result; mockedRequests.every(function (mockedRequest) { result = _gpfHttMockMatchRequest(mockedRequest, request); return result === undefined; }); return result; }
javascript
function _gpfHttMockMatch (mockedRequests, request) { var result; mockedRequests.every(function (mockedRequest) { result = _gpfHttMockMatchRequest(mockedRequest, request); return result === undefined; }); return result; }
[ "function", "_gpfHttMockMatch", "(", "mockedRequests", ",", "request", ")", "{", "var", "result", ";", "mockedRequests", ".", "every", "(", "function", "(", "mockedRequest", ")", "{", "result", "=", "_gpfHttMockMatchRequest", "(", "mockedRequest", ",", "request", ")", ";", "return", "result", "===", "undefined", ";", "}", ")", ";", "return", "result", ";", "}" ]
Match the provided request to the list of mocked ones @param {gpf.typedef.mockedRequest[]} mockedRequests List of mocked requests for the given method @param {gpf.typedef.httpRequestSettings} request Request to match @return {Promise<gpf.typedef.httpRequestResponse>|undefined} undefined if no mocked request matches @since 0.2.2
[ "Match", "the", "provided", "request", "to", "the", "list", "of", "mocked", "ones" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http/mock.js#L75-L82
train
ArnaudBuchholz/gpf-js
src/http/mock.js
_gpfHttpMockAdd
function _gpfHttpMockAdd (definition) { var method = definition.method.toUpperCase(), id = method + "." + _gpfHttpMockLastId++; _gpfHttpMockGetMockedRequests(method).unshift(Object.assign({ id: id }, definition)); return id; }
javascript
function _gpfHttpMockAdd (definition) { var method = definition.method.toUpperCase(), id = method + "." + _gpfHttpMockLastId++; _gpfHttpMockGetMockedRequests(method).unshift(Object.assign({ id: id }, definition)); return id; }
[ "function", "_gpfHttpMockAdd", "(", "definition", ")", "{", "var", "method", "=", "definition", ".", "method", ".", "toUpperCase", "(", ")", ",", "id", "=", "method", "+", "\".\"", "+", "_gpfHttpMockLastId", "++", ";", "_gpfHttpMockGetMockedRequests", "(", "method", ")", ".", "unshift", "(", "Object", ".", "assign", "(", "{", "id", ":", "id", "}", ",", "definition", ")", ")", ";", "return", "id", ";", "}" ]
Add a mocked request @param {gpf.typedef.mockedRequest} definition Mocked request definition @return {gpf.typedef.mockedRequestID} Mocked request identifier, to be used with {@link gpf.http.mock.remove} @see gpf.http @since 0.2.2
[ "Add", "a", "mocked", "request" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http/mock.js#L112-L119
train
ArnaudBuchholz/gpf-js
src/http/mock.js
_gpfHttpMockRemove
function _gpfHttpMockRemove (id) { var method = id.substring(_GPF_START, id.indexOf(".")); _gpfHttpMockedRequests[method] = _gpfHttpMockGetMockedRequests(method).filter(function (mockedRequest) { return mockedRequest.id !== id; }); }
javascript
function _gpfHttpMockRemove (id) { var method = id.substring(_GPF_START, id.indexOf(".")); _gpfHttpMockedRequests[method] = _gpfHttpMockGetMockedRequests(method).filter(function (mockedRequest) { return mockedRequest.id !== id; }); }
[ "function", "_gpfHttpMockRemove", "(", "id", ")", "{", "var", "method", "=", "id", ".", "substring", "(", "_GPF_START", ",", "id", ".", "indexOf", "(", "\".\"", ")", ")", ";", "_gpfHttpMockedRequests", "[", "method", "]", "=", "_gpfHttpMockGetMockedRequests", "(", "method", ")", ".", "filter", "(", "function", "(", "mockedRequest", ")", "{", "return", "mockedRequest", ".", "id", "!==", "id", ";", "}", ")", ";", "}" ]
Removes a mocked request @param {gpf.typedef.mockedRequestID} id Mocked request identifier returned by {@link gpf.http.mock} @since 0.2.2
[ "Removes", "a", "mocked", "request" ]
0888295c99a1ff285ead60273cc7ef656e7fd812
https://github.com/ArnaudBuchholz/gpf-js/blob/0888295c99a1ff285ead60273cc7ef656e7fd812/src/http/mock.js#L127-L132
train
popeindustries/buddy
lib/resolver/config.js
resolveEnvSources
function resolveEnvSources(env) { let paths = []; if (process.env[env]) { paths = process.env[env].includes(path.delimiter) ? process.env[env].split(path.delimiter) : [process.env[env]]; } return paths; }
javascript
function resolveEnvSources(env) { let paths = []; if (process.env[env]) { paths = process.env[env].includes(path.delimiter) ? process.env[env].split(path.delimiter) : [process.env[env]]; } return paths; }
[ "function", "resolveEnvSources", "(", "env", ")", "{", "let", "paths", "=", "[", "]", ";", "if", "(", "process", ".", "env", "[", "env", "]", ")", "{", "paths", "=", "process", ".", "env", "[", "env", "]", ".", "includes", "(", "path", ".", "delimiter", ")", "?", "process", ".", "env", "[", "env", "]", ".", "split", "(", "path", ".", "delimiter", ")", ":", "[", "process", ".", "env", "[", "env", "]", "]", ";", "}", "return", "paths", ";", "}" ]
Resolve environment variable sources for 'env' @param {String} env @returns {Array}
[ "Resolve", "environment", "variable", "sources", "for", "env" ]
c38afc2e6915743eb6cfcf5aba59a8699142c7a5
https://github.com/popeindustries/buddy/blob/c38afc2e6915743eb6cfcf5aba59a8699142c7a5/lib/resolver/config.js#L66-L74
train
makeup-js/makeup-expander
docs/static/bundle.js
function(target) { // Only store the `module` in the local cache since `module.exports` may not be accurate // if there was a circular dependency var module = localCache[target] || (localCache[target] = requireModule(target, dirname)); return module.exports; }
javascript
function(target) { // Only store the `module` in the local cache since `module.exports` may not be accurate // if there was a circular dependency var module = localCache[target] || (localCache[target] = requireModule(target, dirname)); return module.exports; }
[ "function", "(", "target", ")", "{", "var", "module", "=", "localCache", "[", "target", "]", "||", "(", "localCache", "[", "target", "]", "=", "requireModule", "(", "target", ",", "dirname", ")", ")", ";", "return", "module", ".", "exports", ";", "}" ]
this is the require used by the module
[ "this", "is", "the", "require", "used", "by", "the", "module" ]
9274abb14e4fd051ddcc609dbc9fe9ac6605631c
https://github.com/makeup-js/makeup-expander/blob/9274abb14e4fd051ddcc609dbc9fe9ac6605631c/docs/static/bundle.js#L127-L132
train