id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
46,900
kogarashisan/LiquidLava
lib/packages/core-classes.js
function() { var data_source = this._foreach_scope.getValue(), new_uids = data_source.getUIDs(), new_uid_to_index_map = data_source.getUIDToIndexMap(), count = data_source.getCount(), i = 0, uid, template, removed_templates = [], child_properties, current_templates = []; for (; i < this._current_count; i++) { uid = this._current_uids[i]; if (!(uid in new_uid_to_index_map)) { removed_templates.push(this._current_hash[uid]); delete this._current_hash[uid]; } } for (i = 0; i < count; i++) { uid = new_uids[i]; child_properties = { foreach_index: i, foreach_name: data_source.getNameAt(new_uid_to_index_map[uid]) }; child_properties[this._as] = data_source.getValueAt(new_uid_to_index_map[uid]); if (uid in this._current_hash) { template = this._current_hash[uid]; template.batchSetProperties(child_properties); } else { template = new Lava.system.Template(this._config.template, this._widget, this, child_properties); this._current_hash[uid] = template; } current_templates.push(template); } removed_templates.length && this._removeTemplates(removed_templates); this._current_count = count; this._current_uids = new_uids; this._current_templates = current_templates; this._requires_refresh_children = false; }
javascript
function() { var data_source = this._foreach_scope.getValue(), new_uids = data_source.getUIDs(), new_uid_to_index_map = data_source.getUIDToIndexMap(), count = data_source.getCount(), i = 0, uid, template, removed_templates = [], child_properties, current_templates = []; for (; i < this._current_count; i++) { uid = this._current_uids[i]; if (!(uid in new_uid_to_index_map)) { removed_templates.push(this._current_hash[uid]); delete this._current_hash[uid]; } } for (i = 0; i < count; i++) { uid = new_uids[i]; child_properties = { foreach_index: i, foreach_name: data_source.getNameAt(new_uid_to_index_map[uid]) }; child_properties[this._as] = data_source.getValueAt(new_uid_to_index_map[uid]); if (uid in this._current_hash) { template = this._current_hash[uid]; template.batchSetProperties(child_properties); } else { template = new Lava.system.Template(this._config.template, this._widget, this, child_properties); this._current_hash[uid] = template; } current_templates.push(template); } removed_templates.length && this._removeTemplates(removed_templates); this._current_count = count; this._current_uids = new_uids; this._current_templates = current_templates; this._requires_refresh_children = false; }
[ "function", "(", ")", "{", "var", "data_source", "=", "this", ".", "_foreach_scope", ".", "getValue", "(", ")", ",", "new_uids", "=", "data_source", ".", "getUIDs", "(", ")", ",", "new_uid_to_index_map", "=", "data_source", ".", "getUIDToIndexMap", "(", ")",...
Remove old templates, create new
[ "Remove", "old", "templates", "create", "new" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L12427-L12486
46,901
kogarashisan/LiquidLava
lib/packages/core-classes.js
function() { if (Lava.schema.DEBUG && (this._argument.isWaitingRefresh() || this._foreach_scope.isWaitingRefresh())) Lava.t("Rendering a view in dirty state"); this._requires_refresh_children && this._refreshChildren(); return this._refresher.render(this._current_templates); }
javascript
function() { if (Lava.schema.DEBUG && (this._argument.isWaitingRefresh() || this._foreach_scope.isWaitingRefresh())) Lava.t("Rendering a view in dirty state"); this._requires_refresh_children && this._refreshChildren(); return this._refresher.render(this._current_templates); }
[ "function", "(", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "(", "this", ".", "_argument", ".", "isWaitingRefresh", "(", ")", "||", "this", ".", "_foreach_scope", ".", "isWaitingRefresh", "(", ")", ")", ")", "Lava", ".", "t", "("...
Version of `_renderContent` for usage with refresher instance @returns {string}
[ "Version", "of", "_renderContent", "for", "usage", "with", "refresher", "instance" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L12533-L12539
46,902
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(template) { var index = this._content.indexOf(template); if (index == -1) { if (Lava.schema.DEBUG && template != this._else_content) Lava.t(); this._else_content = null; } else { this._content[index] = null; } template.destroy(); }
javascript
function(template) { var index = this._content.indexOf(template); if (index == -1) { if (Lava.schema.DEBUG && template != this._else_content) Lava.t(); this._else_content = null; } else { this._content[index] = null; } template.destroy(); }
[ "function", "(", "template", ")", "{", "var", "index", "=", "this", ".", "_content", ".", "indexOf", "(", "template", ")", ";", "if", "(", "index", "==", "-", "1", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "template", "!=", ...
Branches that are not in DOM are destroyed @param {Lava.system.Template} template
[ "Branches", "that", "are", "not", "in", "DOM", "are", "destroyed" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L12836-L12849
46,903
kogarashisan/LiquidLava
lib/packages/core-classes.js
function() { if (Lava.schema.DEBUG && this._active_argument_index != -1 && this._arguments[this._active_argument_index].isWaitingRefresh()) Lava.t(); this._active_template = this._getActiveTemplate(); return this._refresher.render(this._active_template ? [this._active_template] : []); }
javascript
function() { if (Lava.schema.DEBUG && this._active_argument_index != -1 && this._arguments[this._active_argument_index].isWaitingRefresh()) Lava.t(); this._active_template = this._getActiveTemplate(); return this._refresher.render(this._active_template ? [this._active_template] : []); }
[ "function", "(", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "this", ".", "_active_argument_index", "!=", "-", "1", "&&", "this", ".", "_arguments", "[", "this", ".", "_active_argument_index", "]", ".", "isWaitingRefresh", "(", ")", "...
Version of `_renderContent` which uses created refresher instance @returns {string}
[ "Version", "of", "_renderContent", "which", "uses", "created", "refresher", "instance" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L12896-L12902
46,904
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(config, widget, parent_view, template, properties) { var name, count, i; if (Lava.schema.DEBUG && !config.is_extended) Lava.t("Widget was created with partial (unextended) config"); if (Lava.schema.DEBUG) { for (name in this._property_descriptors) { if (!(name in this._properties)) Lava.t("All widget properties must have a default value"); } if (config.default_events) { for (i = 0, count = config.default_events.length; i < count; i++) { if (!Lava.view_manager.isEventRouted(config.default_events[i])) Lava.t('Event is not routed: ' + config.default_events[i]); } } } this._parent_widget = widget; this.View$init(config, this, parent_view, template, properties); for (name in config.bindings) { this._bindings[name] = new Lava.scope.Binding(config.bindings[name], this); } }
javascript
function(config, widget, parent_view, template, properties) { var name, count, i; if (Lava.schema.DEBUG && !config.is_extended) Lava.t("Widget was created with partial (unextended) config"); if (Lava.schema.DEBUG) { for (name in this._property_descriptors) { if (!(name in this._properties)) Lava.t("All widget properties must have a default value"); } if (config.default_events) { for (i = 0, count = config.default_events.length; i < count; i++) { if (!Lava.view_manager.isEventRouted(config.default_events[i])) Lava.t('Event is not routed: ' + config.default_events[i]); } } } this._parent_widget = widget; this.View$init(config, this, parent_view, template, properties); for (name in config.bindings) { this._bindings[name] = new Lava.scope.Binding(config.bindings[name], this); } }
[ "function", "(", "config", ",", "widget", ",", "parent_view", ",", "template", ",", "properties", ")", "{", "var", "name", ",", "count", ",", "i", ";", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "config", ".", "is_extended", ")", "Lav...
Create widget instance @param {_cWidget} config @param {Lava.widget.Standard} widget @param {Lava.view.Abstract} parent_view @param {Lava.system.Template} template @param {Object} properties
[ "Create", "widget", "instance" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L13183-L13212
46,905
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(config) { var locale = Lava.schema.LOCALE, resource_owner, component_resource, resources; if ('resources_cache' in config) { resources = config.resources_cache[locale]; } if ('resource_id' in config) { resource_owner = this['locateViewBy' + config.resource_id.locator_type](config.resource_id.locator); if (Lava.schema.DEBUG && (!resource_owner || !resource_owner.isWidget)) Lava.t("Resource root not found: " + config.resource_id.locator_type + '=' + config.resource_id.locator); component_resource = resource_owner.getResource(config.resource_id.name, Lava.schema.LOCALE); if (component_resource) { if (Lava.schema.DEBUG && component_resource.type != 'component') Lava.t("resource value is not a component"); resources = resources ? Lava.resources.mergeResources(component_resource.value, resources) : component_resource.value; } } if (resources) { this._resources[locale] = resources; Lava.resources.mergeRootContainerStacks(resources); } }
javascript
function(config) { var locale = Lava.schema.LOCALE, resource_owner, component_resource, resources; if ('resources_cache' in config) { resources = config.resources_cache[locale]; } if ('resource_id' in config) { resource_owner = this['locateViewBy' + config.resource_id.locator_type](config.resource_id.locator); if (Lava.schema.DEBUG && (!resource_owner || !resource_owner.isWidget)) Lava.t("Resource root not found: " + config.resource_id.locator_type + '=' + config.resource_id.locator); component_resource = resource_owner.getResource(config.resource_id.name, Lava.schema.LOCALE); if (component_resource) { if (Lava.schema.DEBUG && component_resource.type != 'component') Lava.t("resource value is not a component"); resources = resources ? Lava.resources.mergeResources(component_resource.value, resources) : component_resource.value; } } if (resources) { this._resources[locale] = resources; Lava.resources.mergeRootContainerStacks(resources); } }
[ "function", "(", "config", ")", "{", "var", "locale", "=", "Lava", ".", "schema", ".", "LOCALE", ",", "resource_owner", ",", "component_resource", ",", "resources", ";", "if", "(", "'resources_cache'", "in", "config", ")", "{", "resources", "=", "config", ...
Get, merge and prepare resources for this widget @param {_cWidget} config
[ "Get", "merge", "and", "prepare", "resources", "for", "this", "widget" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L13236-L13273
46,906
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(name, template_arguments) { var result = null; if (name in this._include_handlers) { result = this[this._include_handlers[name]](template_arguments); } else { result = this._config.includes[name]; } return result; }
javascript
function(name, template_arguments) { var result = null; if (name in this._include_handlers) { result = this[this._include_handlers[name]](template_arguments); } else { result = this._config.includes[name]; } return result; }
[ "function", "(", "name", ",", "template_arguments", ")", "{", "var", "result", "=", "null", ";", "if", "(", "name", "in", "this", ".", "_include_handlers", ")", "{", "result", "=", "this", "[", "this", ".", "_include_handlers", "[", "name", "]", "]", "...
Get view's include @param {string} name Include name @param {Array} template_arguments Evaluated argument values from view's template @returns {?_tTemplate}
[ "Get", "view", "s", "include" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L13281-L13297
46,907
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(element, position) { if (this._is_inDOM) Lava.t("inject: widget is already in DOM"); if (Lava.schema.DEBUG && this._parent_view) Lava.t("Widget: only top-level widgets can be inserted into DOM"); if (Lava.schema.DEBUG && !this._container) Lava.t("Widget: root widgets must have a container"); // Otherwise, if you assign data to a widget, that was removed from DOM, // and then render it - it will render with old data. Lava.ScopeManager.refresh(); // lock, cause render operation can change data. Although it's not recommended to change data in render(). Lava.ScopeManager.lock(); Firestorm.DOM.insertHTML(element, this.render(), position || 'Top'); Lava.ScopeManager.unlock(); this.broadcastInDOM(); }
javascript
function(element, position) { if (this._is_inDOM) Lava.t("inject: widget is already in DOM"); if (Lava.schema.DEBUG && this._parent_view) Lava.t("Widget: only top-level widgets can be inserted into DOM"); if (Lava.schema.DEBUG && !this._container) Lava.t("Widget: root widgets must have a container"); // Otherwise, if you assign data to a widget, that was removed from DOM, // and then render it - it will render with old data. Lava.ScopeManager.refresh(); // lock, cause render operation can change data. Although it's not recommended to change data in render(). Lava.ScopeManager.lock(); Firestorm.DOM.insertHTML(element, this.render(), position || 'Top'); Lava.ScopeManager.unlock(); this.broadcastInDOM(); }
[ "function", "(", "element", ",", "position", ")", "{", "if", "(", "this", ".", "_is_inDOM", ")", "Lava", ".", "t", "(", "\"inject: widget is already in DOM\"", ")", ";", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "this", ".", "_parent_view", "...
Render and insert the widget instance into DOM @param {HTMLElement} element @param {_eInsertPosition} position
[ "Render", "and", "insert", "the", "widget", "instance", "into", "DOM" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L13328-L13344
46,908
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(name, arguments_array) { if (Lava.schema.DEBUG && !(name in this._modifiers)) Lava.t("Unknown widget modifier: " + name); return this[this._modifiers[name]].apply(this, arguments_array); }
javascript
function(name, arguments_array) { if (Lava.schema.DEBUG && !(name in this._modifiers)) Lava.t("Unknown widget modifier: " + name); return this[this._modifiers[name]].apply(this, arguments_array); }
[ "function", "(", "name", ",", "arguments_array", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "(", "name", "in", "this", ".", "_modifiers", ")", ")", "Lava", ".", "t", "(", "\"Unknown widget modifier: \"", "+", "name", ")", ";",...
Call a template method @param {string} name Modifier name @param {Array} arguments_array Evaluated template arguments @returns {*}
[ "Call", "a", "template", "method" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L13402-L13408
46,909
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(role, view, template_arguments) { var result = false; if (role in this._role_handlers) { this[this._role_handlers[role]](view, template_arguments); result = true; } return result; }
javascript
function(role, view, template_arguments) { var result = false; if (role in this._role_handlers) { this[this._role_handlers[role]](view, template_arguments); result = true; } return result; }
[ "function", "(", "role", ",", "view", ",", "template_arguments", ")", "{", "var", "result", "=", "false", ";", "if", "(", "role", "in", "this", ".", "_role_handlers", ")", "{", "this", "[", "this", ".", "_role_handlers", "[", "role", "]", "]", "(", "...
Handle a view with a role in this widget @param {string} role Role name @param {Lava.view.Abstract} view @param {Array.<*>} template_arguments @returns {boolean} <kw>true</kw>, if the role was handled, and <kw>false</kw> otherwise
[ "Handle", "a", "view", "with", "a", "role", "in", "this", "widget" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L13439-L13452
46,910
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(resource_name, locale) { locale = locale || Lava.schema.LOCALE; return ((locale in this._resources) && (resource_name in this._resources[locale])) ? this._resources[locale][resource_name] : null; }
javascript
function(resource_name, locale) { locale = locale || Lava.schema.LOCALE; return ((locale in this._resources) && (resource_name in this._resources[locale])) ? this._resources[locale][resource_name] : null; }
[ "function", "(", "resource_name", ",", "locale", ")", "{", "locale", "=", "locale", "||", "Lava", ".", "schema", ".", "LOCALE", ";", "return", "(", "(", "locale", "in", "this", ".", "_resources", ")", "&&", "(", "resource_name", "in", "this", ".", "_re...
Get a resource object by it's name @param {string} resource_name @param {string} locale @returns {*}
[ "Get", "a", "resource", "object", "by", "it", "s", "name" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L13523-L13531
46,911
danigb/audio-contour
index.js
Contour
function Contour (ac, options) { var env = ac.createGain() var opts = Contour.params(options, env) var isL = opts.ramp === 'linear' var tail = ac.createGain() tail.connect(env) var head = ac.createGain() head.connect(tail) var cv = Voltage(ac) cv.connect(head) env.start = function (time) { time = Math.max(time || 0, ac.currentTime) if (env.onstart) env.onstart(time) cv.start(time) head.gain.setValueAtTime(0, time) head.gain.setValueAtTime(0.01, time + 0.000001) ramp(isL, head, opts.l1, time + opts.t1) ramp(isL, head, opts.l2, time + opts.t1 + opts.t2) ramp(isL, head, opts.l3, time + opts.t1 + opts.t2 + opts.t3) if (isFinite(opts.duration)) env.stop(time + opts.duration) } env.stop = function (time) { time = Math.max(time || 0, ac.currentTime) tail.gain.cancelScheduledValues(time) tail.gain.setValueAtTime(env.gain.value, time) var endsAt = time + opts.t4 ramp(isL, tail, 0.0001, endsAt) if (env.onended) { var s = Voltage(ac, 0) s.connect(ac.destination) s.onended = env.onended s.start(ac.currentTime) s.stop(endsAt) } return endsAt } return env }
javascript
function Contour (ac, options) { var env = ac.createGain() var opts = Contour.params(options, env) var isL = opts.ramp === 'linear' var tail = ac.createGain() tail.connect(env) var head = ac.createGain() head.connect(tail) var cv = Voltage(ac) cv.connect(head) env.start = function (time) { time = Math.max(time || 0, ac.currentTime) if (env.onstart) env.onstart(time) cv.start(time) head.gain.setValueAtTime(0, time) head.gain.setValueAtTime(0.01, time + 0.000001) ramp(isL, head, opts.l1, time + opts.t1) ramp(isL, head, opts.l2, time + opts.t1 + opts.t2) ramp(isL, head, opts.l3, time + opts.t1 + opts.t2 + opts.t3) if (isFinite(opts.duration)) env.stop(time + opts.duration) } env.stop = function (time) { time = Math.max(time || 0, ac.currentTime) tail.gain.cancelScheduledValues(time) tail.gain.setValueAtTime(env.gain.value, time) var endsAt = time + opts.t4 ramp(isL, tail, 0.0001, endsAt) if (env.onended) { var s = Voltage(ac, 0) s.connect(ac.destination) s.onended = env.onended s.start(ac.currentTime) s.stop(endsAt) } return endsAt } return env }
[ "function", "Contour", "(", "ac", ",", "options", ")", "{", "var", "env", "=", "ac", ".", "createGain", "(", ")", "var", "opts", "=", "Contour", ".", "params", "(", "options", ",", "env", ")", "var", "isL", "=", "opts", ".", "ramp", "===", "'linear...
Create an envelope generator. @param {AudioContext} ac - the audio context @param {Object} options - (Optional) the envelope options @return {AudioNode} the envelope generator node
[ "Create", "an", "envelope", "generator", "." ]
14c75fe55f747717029c83dd52e9021bb03ef058
https://github.com/danigb/audio-contour/blob/14c75fe55f747717029c83dd52e9021bb03ef058/index.js#L22-L62
46,912
alexindigo/deeply
mutable.js
mutable
function mutable(/* a[, b[, ...]] */) { var args = Array.prototype.slice.call(arguments) , result = args.shift() ; while (args.length) { result = merge.call(this, result, args.shift()); } return result; }
javascript
function mutable(/* a[, b[, ...]] */) { var args = Array.prototype.slice.call(arguments) , result = args.shift() ; while (args.length) { result = merge.call(this, result, args.shift()); } return result; }
[ "function", "mutable", "(", "/* a[, b[, ...]] */", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ",", "result", "=", "args", ".", "shift", "(", ")", ";", "while", "(", "args", ".", "length", ...
Deeply merges properties of the provided objects, into the first object. @param {...mixed} value - values to merge @returns {mixed} first value with merged in properties from other values
[ "Deeply", "merges", "properties", "of", "the", "provided", "objects", "into", "the", "first", "object", "." ]
d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1
https://github.com/alexindigo/deeply/blob/d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1/mutable.js#L12-L24
46,913
alexindigo/deeply
extra/functions_clone.js
functionsCloneAdapter
function functionsCloneAdapter(to, from, merge) { var copy = cloneFunction(from); // to fully stand up to Ludicrous name // let's clone prototype chain copy.prototype = merge(undefined, from.prototype); // duplicate function's properties reduceObject(copy, from, merge); return copy; }
javascript
function functionsCloneAdapter(to, from, merge) { var copy = cloneFunction(from); // to fully stand up to Ludicrous name // let's clone prototype chain copy.prototype = merge(undefined, from.prototype); // duplicate function's properties reduceObject(copy, from, merge); return copy; }
[ "function", "functionsCloneAdapter", "(", "to", ",", "from", ",", "merge", ")", "{", "var", "copy", "=", "cloneFunction", "(", "from", ")", ";", "// to fully stand up to Ludicrous name", "// let's clone prototype chain", "copy", ".", "prototype", "=", "merge", "(", ...
Clones provided source function and replaces target function with the clone. Also cloning the prototype tree. @param {function} to - target function to ignore @param {function} from - function to clone @param {function} merge - iterator to merge sub elements @returns {function} - cloned source function
[ "Clones", "provided", "source", "function", "and", "replaces", "target", "function", "with", "the", "clone", ".", "Also", "cloning", "the", "prototype", "tree", "." ]
d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1
https://github.com/alexindigo/deeply/blob/d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1/extra/functions_clone.js#L18-L30
46,914
brunnolou/springs
example/index.js
update
function update() { el.style.transform = 'scale3d(' + s1(x) + ', ' + s2(y) + ', 1)'; requestAnimationFrame(update); }
javascript
function update() { el.style.transform = 'scale3d(' + s1(x) + ', ' + s2(y) + ', 1)'; requestAnimationFrame(update); }
[ "function", "update", "(", ")", "{", "el", ".", "style", ".", "transform", "=", "'scale3d('", "+", "s1", "(", "x", ")", "+", "', '", "+", "s2", "(", "y", ")", "+", "', 1)'", ";", "requestAnimationFrame", "(", "update", ")", ";", "}" ]
Request Animation Frame logic.
[ "Request", "Animation", "Frame", "logic", "." ]
b48f83004e1564f7f2f21450a5bef3b8419100ca
https://github.com/brunnolou/springs/blob/b48f83004e1564f7f2f21450a5bef3b8419100ca/example/index.js#L33-L37
46,915
alexindigo/deeply
extra/functions_extend.js
functionsExtendAdapter
function functionsExtendAdapter(to, from, merge) { var copy = cloneFunction(from); // keep from.prototype in the prototype chain copy.prototype = from.prototype; // duplicate function's properties reduceObject(copy, from, merge); return copy; }
javascript
function functionsExtendAdapter(to, from, merge) { var copy = cloneFunction(from); // keep from.prototype in the prototype chain copy.prototype = from.prototype; // duplicate function's properties reduceObject(copy, from, merge); return copy; }
[ "function", "functionsExtendAdapter", "(", "to", ",", "from", ",", "merge", ")", "{", "var", "copy", "=", "cloneFunction", "(", "from", ")", ";", "// keep from.prototype in the prototype chain", "copy", ".", "prototype", "=", "from", ".", "prototype", ";", "// d...
Clones provided source function and replaces target function with the clone. While keeping original prototype in the prototype chain. @param {function} to - target function to ignore @param {function} from - function to clone @param {function} merge - iterator to merge sub elements @returns {function} - cloned source function
[ "Clones", "provided", "source", "function", "and", "replaces", "target", "function", "with", "the", "clone", ".", "While", "keeping", "original", "prototype", "in", "the", "prototype", "chain", "." ]
d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1
https://github.com/alexindigo/deeply/blob/d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1/extra/functions_extend.js#L18-L29
46,916
kogarashisan/LiquidLava
lib/packages/core.js
function() { this._initGlobal(Lava.schema.system.VIEW_MANAGER_CLASS, 'view_manager'); this._initGlobal(Lava.schema.system.APP_CLASS, 'app'); this._initGlobal(Lava.schema.popover_manager.CLASS, 'popover_manager'); this._initGlobal(Lava.schema.focus_manager.CLASS, 'focus_manager'); }
javascript
function() { this._initGlobal(Lava.schema.system.VIEW_MANAGER_CLASS, 'view_manager'); this._initGlobal(Lava.schema.system.APP_CLASS, 'app'); this._initGlobal(Lava.schema.popover_manager.CLASS, 'popover_manager'); this._initGlobal(Lava.schema.focus_manager.CLASS, 'focus_manager'); }
[ "function", "(", ")", "{", "this", ".", "_initGlobal", "(", "Lava", ".", "schema", ".", "system", ".", "VIEW_MANAGER_CLASS", ",", "'view_manager'", ")", ";", "this", ".", "_initGlobal", "(", "Lava", ".", "schema", ".", "system", ".", "APP_CLASS", ",", "'...
Create global class instances
[ "Create", "global", "class", "instances" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L246-L253
46,917
kogarashisan/LiquidLava
lib/packages/core.js
function(msg) { if (typeof(window) == 'undefined') throw new Error(msg); // Node environment if (window.console) { window.console.error(msg); } }
javascript
function(msg) { if (typeof(window) == 'undefined') throw new Error(msg); // Node environment if (window.console) { window.console.error(msg); } }
[ "function", "(", "msg", ")", "{", "if", "(", "typeof", "(", "window", ")", "==", "'undefined'", ")", "throw", "new", "Error", "(", "msg", ")", ";", "// Node environment", "if", "(", "window", ".", "console", ")", "{", "window", ".", "console", ".", "...
Log a recoverable error @param {string} msg
[ "Log", "a", "recoverable", "error" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L290-L298
46,918
kogarashisan/LiquidLava
lib/packages/core.js
function(widget_title) { if (Lava.schema.DEBUG && !(widget_title in this.widgets)) Lava.t("Widget config not found: " + widget_title); var config = this.widgets[widget_title]; if (!config.is_extended) { Lava.extenders[config.extender_type](config); } return config; }
javascript
function(widget_title) { if (Lava.schema.DEBUG && !(widget_title in this.widgets)) Lava.t("Widget config not found: " + widget_title); var config = this.widgets[widget_title]; if (!config.is_extended) { Lava.extenders[config.extender_type](config); } return config; }
[ "function", "(", "widget_title", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "(", "widget_title", "in", "this", ".", "widgets", ")", ")", "Lava", ".", "t", "(", "\"Widget config not found: \"", "+", "widget_title", ")", ";", "var...
Get extended config of global named widget @param {string} widget_title @returns {_cWidget}
[ "Get", "extended", "config", "of", "global", "named", "widget" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L315-L329
46,919
kogarashisan/LiquidLava
lib/packages/core.js
function(extends_title, config, properties) { var widget_config = this.getWidgetConfig(extends_title), constructor; if (config) { if (Lava.schema.DEBUG && config['extends'] && config['extends'] != extends_title) Lava.t("Malformed widget config"); config['extends'] = extends_title; Lava.extenders[config.extender_type || widget_config.extender_type](config); } else { // all widgets from schema must have their class present config = widget_config; } constructor = Lava.ClassManager.getConstructor(config['class']); if (Lava.schema.DEBUG && !constructor) Lava.t('Class not found: ' + class_name); return /** @type {Lava.widget.Standard} */ new constructor(config, null, null, null, properties); }
javascript
function(extends_title, config, properties) { var widget_config = this.getWidgetConfig(extends_title), constructor; if (config) { if (Lava.schema.DEBUG && config['extends'] && config['extends'] != extends_title) Lava.t("Malformed widget config"); config['extends'] = extends_title; Lava.extenders[config.extender_type || widget_config.extender_type](config); } else { // all widgets from schema must have their class present config = widget_config; } constructor = Lava.ClassManager.getConstructor(config['class']); if (Lava.schema.DEBUG && !constructor) Lava.t('Class not found: ' + class_name); return /** @type {Lava.widget.Standard} */ new constructor(config, null, null, null, properties); }
[ "function", "(", "extends_title", ",", "config", ",", "properties", ")", "{", "var", "widget_config", "=", "this", ".", "getWidgetConfig", "(", "extends_title", ")", ",", "constructor", ";", "if", "(", "config", ")", "{", "if", "(", "Lava", ".", "schema", ...
Create a root widget instance @param {string} extends_title Name of global parent widget @param {_cWidget} [config] Partial config for new widget, will be extended with parent's config @param {Object} [properties] Properties for created widget @returns {Lava.widget.Standard} Created widget instance
[ "Create", "a", "root", "widget", "instance" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L338-L361
46,920
kogarashisan/LiquidLava
lib/packages/core.js
function(widget_title, widget_config) { if (!Lava.schema.widget.ALLOW_REDEFINITION && (widget_title in this.widgets)) Lava.t("storeWidgetSchema: widget is already defined: " + widget_title); this.widgets[widget_title] = widget_config; if (('sugar' in widget_config) && widget_config.sugar.tag_name) { this.sugar_map[widget_config.sugar.tag_name] = {widget_title: widget_title}; } }
javascript
function(widget_title, widget_config) { if (!Lava.schema.widget.ALLOW_REDEFINITION && (widget_title in this.widgets)) Lava.t("storeWidgetSchema: widget is already defined: " + widget_title); this.widgets[widget_title] = widget_config; if (('sugar' in widget_config) && widget_config.sugar.tag_name) { this.sugar_map[widget_config.sugar.tag_name] = {widget_title: widget_title}; } }
[ "function", "(", "widget_title", ",", "widget_config", ")", "{", "if", "(", "!", "Lava", ".", "schema", ".", "widget", ".", "ALLOW_REDEFINITION", "&&", "(", "widget_title", "in", "this", ".", "widgets", ")", ")", "Lava", ".", "t", "(", "\"storeWidgetSchema...
Register a global widget config @param {string} widget_title Title for new global widget @param {_cWidget} widget_config
[ "Register", "a", "global", "widget", "config" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L464-L477
46,921
kogarashisan/LiquidLava
lib/packages/core.js
function() { this.init && this.init(); // focus manager must be initialized before any widgets are in DOM, so it could receive the focus event // which can be fired after insertion Lava.schema.focus_manager.IS_ENABLED && this.focus_manager && this.focus_manager.enable(); var body = document.body, app_class = Firestorm.Element.getProperty(body, 'lava-app'), bootstrap_targets, i = 0, count; if (app_class != null) { this._elementToWidget(body); } else { bootstrap_targets = Firestorm.selectElements('script[type="lava/app"],lava-app'); for (count = bootstrap_targets.length; i < count; i++) { if (Firestorm.Element.getTagName(bootstrap_targets[i]) == 'script') { this._scriptToWidget(bootstrap_targets[i]); } else { this._elementToWidget(bootstrap_targets[i]); } } } Lava.schema.popover_manager.IS_ENABLED && this.popover_manager && this.popover_manager.enable(); }
javascript
function() { this.init && this.init(); // focus manager must be initialized before any widgets are in DOM, so it could receive the focus event // which can be fired after insertion Lava.schema.focus_manager.IS_ENABLED && this.focus_manager && this.focus_manager.enable(); var body = document.body, app_class = Firestorm.Element.getProperty(body, 'lava-app'), bootstrap_targets, i = 0, count; if (app_class != null) { this._elementToWidget(body); } else { bootstrap_targets = Firestorm.selectElements('script[type="lava/app"],lava-app'); for (count = bootstrap_targets.length; i < count; i++) { if (Firestorm.Element.getTagName(bootstrap_targets[i]) == 'script') { this._scriptToWidget(bootstrap_targets[i]); } else { this._elementToWidget(bootstrap_targets[i]); } } } Lava.schema.popover_manager.IS_ENABLED && this.popover_manager && this.popover_manager.enable(); }
[ "function", "(", ")", "{", "this", ".", "init", "&&", "this", ".", "init", "(", ")", ";", "// focus manager must be initialized before any widgets are in DOM, so it could receive the focus event", "// which can be fired after insertion", "Lava", ".", "schema", ".", "focus_man...
Parse the page &lt;body&gt; or special "lava-app" regions in the page and replace them with widgets
[ "Parse", "the", "page", "&lt", ";", "body&gt", ";", "or", "special", "lava", "-", "app", "regions", "in", "the", "page", "and", "replace", "them", "with", "widgets" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L482-L517
46,922
kogarashisan/LiquidLava
lib/packages/core.js
function(element) { var widget, raw_template = Lava.TemplateParser.parseRaw(Firestorm.Element.getOuterHTML(element)), raw_tag, config, constructor; if (Lava.schema.DEBUG && raw_template.length != 1) Lava.t(); raw_tag = raw_template[0]; config = Lava.parsers.Common.toWidget(raw_tag); config.is_extended = true; config['class'] = raw_tag.attributes['lava-app']; if (raw_tag.attributes.id) Firestorm.Element.removeProperty(element, 'id'); // needed for captureExistingElement constructor = Lava.ClassManager.getConstructor(config['class'] || 'Lava.widget.Standard', 'Lava.widget'); if (Lava.schema.DEBUG && !constructor) Lava.t('Class not found: ' + config['class']); widget = /** @type {Lava.widget.Standard} */ new constructor(config); widget.injectIntoExistingElement(element); return widget; }
javascript
function(element) { var widget, raw_template = Lava.TemplateParser.parseRaw(Firestorm.Element.getOuterHTML(element)), raw_tag, config, constructor; if (Lava.schema.DEBUG && raw_template.length != 1) Lava.t(); raw_tag = raw_template[0]; config = Lava.parsers.Common.toWidget(raw_tag); config.is_extended = true; config['class'] = raw_tag.attributes['lava-app']; if (raw_tag.attributes.id) Firestorm.Element.removeProperty(element, 'id'); // needed for captureExistingElement constructor = Lava.ClassManager.getConstructor(config['class'] || 'Lava.widget.Standard', 'Lava.widget'); if (Lava.schema.DEBUG && !constructor) Lava.t('Class not found: ' + config['class']); widget = /** @type {Lava.widget.Standard} */ new constructor(config); widget.injectIntoExistingElement(element); return widget; }
[ "function", "(", "element", ")", "{", "var", "widget", ",", "raw_template", "=", "Lava", ".", "TemplateParser", ".", "parseRaw", "(", "Firestorm", ".", "Element", ".", "getOuterHTML", "(", "element", ")", ")", ",", "raw_tag", ",", "config", ",", "construct...
Convert a DOM element to widget instance @param {HTMLElement} element @returns {Lava.widget.Standard}
[ "Convert", "a", "DOM", "element", "to", "widget", "instance" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L524-L547
46,923
kogarashisan/LiquidLava
lib/packages/core.js
function(script_element) { var widget, config, constructor, id = Firestorm.Element.getProperty(script_element, 'id'), class_name = Firestorm.Element.getProperty(script_element, 'lava-app'); config = { type: 'widget', is_extended: true, template: null, container: {type: 'Morph'} }; config.template = Lava.TemplateParser.parse(Firestorm.Element.getProperty(script_element, 'html'), config); if (id) { config.id = id; Firestorm.Element.removeProperty(script_element, 'id'); } constructor = Lava.ClassManager.getConstructor(class_name || 'Lava.widget.Standard', 'Lava.widget'); if (Lava.schema.DEBUG && !constructor) Lava.t('Class not found: ' + class_name); widget = /** @type {Lava.widget.Standard} */ new constructor(config); widget.inject(script_element, 'After'); Firestorm.Element.destroy(script_element); return widget; }
javascript
function(script_element) { var widget, config, constructor, id = Firestorm.Element.getProperty(script_element, 'id'), class_name = Firestorm.Element.getProperty(script_element, 'lava-app'); config = { type: 'widget', is_extended: true, template: null, container: {type: 'Morph'} }; config.template = Lava.TemplateParser.parse(Firestorm.Element.getProperty(script_element, 'html'), config); if (id) { config.id = id; Firestorm.Element.removeProperty(script_element, 'id'); } constructor = Lava.ClassManager.getConstructor(class_name || 'Lava.widget.Standard', 'Lava.widget'); if (Lava.schema.DEBUG && !constructor) Lava.t('Class not found: ' + class_name); widget = /** @type {Lava.widget.Standard} */ new constructor(config); widget.inject(script_element, 'After'); Firestorm.Element.destroy(script_element); return widget; }
[ "function", "(", "script_element", ")", "{", "var", "widget", ",", "config", ",", "constructor", ",", "id", "=", "Firestorm", ".", "Element", ".", "getProperty", "(", "script_element", ",", "'id'", ")", ",", "class_name", "=", "Firestorm", ".", "Element", ...
Convert a script DOM element to widget instance @param {HTMLElement} script_element @returns {Lava.widget.Standard}
[ "Convert", "a", "script", "DOM", "element", "to", "widget", "instance" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L554-L582
46,924
kogarashisan/LiquidLava
lib/packages/core.js
function(path) { var class_body = this.classes[path], i = 0, count; if (Lava.schema.DEBUG && !class_body) Lava.t("[Lava::_loadClass] Class does not exists: " + path); if ('Extends' in class_body) { if (!this.ClassManager.hasClass(class_body.Extends)) { this._loadClass(class_body.Extends); } } if ('Implements' in class_body) { if (typeof(class_body.Implements) == 'string') { if (!this.ClassManager.hasClass(class_body.Implements)) { this._loadClass(class_body.Implements); } } else { for (count = class_body.Implements.length; i < count; i++) { if (!this.ClassManager.hasClass(class_body.Implements[i])) { this._loadClass(class_body.Implements[i]); } } } } this.ClassManager.define(path, class_body); }
javascript
function(path) { var class_body = this.classes[path], i = 0, count; if (Lava.schema.DEBUG && !class_body) Lava.t("[Lava::_loadClass] Class does not exists: " + path); if ('Extends' in class_body) { if (!this.ClassManager.hasClass(class_body.Extends)) { this._loadClass(class_body.Extends); } } if ('Implements' in class_body) { if (typeof(class_body.Implements) == 'string') { if (!this.ClassManager.hasClass(class_body.Implements)) { this._loadClass(class_body.Implements); } } else { for (count = class_body.Implements.length; i < count; i++) { if (!this.ClassManager.hasClass(class_body.Implements[i])) { this._loadClass(class_body.Implements[i]); } } } } this.ClassManager.define(path, class_body); }
[ "function", "(", "path", ")", "{", "var", "class_body", "=", "this", ".", "classes", "[", "path", "]", ",", "i", "=", "0", ",", "count", ";", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "class_body", ")", "Lava", ".", "t", "(", "...
Recursively define a class, stored in `this.classes` @param {string} path
[ "Recursively", "define", "a", "class", "stored", "in", "this", ".", "classes" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L661-L691
46,925
kogarashisan/LiquidLava
lib/packages/core.js
function () { this.popover_manager && this.popover_manager.destroy(); this.view_manager && this.view_manager.destroy(); this.app.destroy(); this.view_manager.destroy(); }
javascript
function () { this.popover_manager && this.popover_manager.destroy(); this.view_manager && this.view_manager.destroy(); this.app.destroy(); this.view_manager.destroy(); }
[ "function", "(", ")", "{", "this", ".", "popover_manager", "&&", "this", ".", "popover_manager", ".", "destroy", "(", ")", ";", "this", ".", "view_manager", "&&", "this", ".", "view_manager", ".", "destroy", "(", ")", ";", "this", ".", "app", ".", "des...
Destroy global objects. Widgets must be destroyed manually, before calling this method.
[ "Destroy", "global", "objects", ".", "Widgets", "must", "be", "destroyed", "manually", "before", "calling", "this", "method", "." ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L846-L853
46,926
kogarashisan/LiquidLava
lib/packages/core.js
function(value) { var result = ''; if (value) { result = value.toString(); result = result[0].toUpperCase() + result.substr(1); } return result; }
javascript
function(value) { var result = ''; if (value) { result = value.toString(); result = result[0].toUpperCase() + result.substr(1); } return result; }
[ "function", "(", "value", ")", "{", "var", "result", "=", "''", ";", "if", "(", "value", ")", "{", "result", "=", "value", ".", "toString", "(", ")", ";", "result", "=", "result", "[", "0", "]", ".", "toUpperCase", "(", ")", "+", "result", ".", ...
Upper-case the first letter @param value @returns {string}
[ "Upper", "-", "case", "the", "first", "letter" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L1120-L1131
46,927
kogarashisan/LiquidLava
lib/packages/core.js
function(value) { if (Lava.schema.DEBUG && typeof(value) != 'boolean') Lava.t("translateBoolean: argument is not boolean type"); return Lava.locales[Lava.schema.LOCALE].booleans[+value]; }
javascript
function(value) { if (Lava.schema.DEBUG && typeof(value) != 'boolean') Lava.t("translateBoolean: argument is not boolean type"); return Lava.locales[Lava.schema.LOCALE].booleans[+value]; }
[ "function", "(", "value", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "typeof", "(", "value", ")", "!=", "'boolean'", ")", "Lava", ".", "t", "(", "\"translateBoolean: argument is not boolean type\"", ")", ";", "return", "Lava", ".", "lo...
Translate a boolean type into user language @param value @returns {string}
[ "Translate", "a", "boolean", "type", "into", "user", "language" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L1150-L1155
46,928
kogarashisan/LiquidLava
lib/packages/core.js
function(widget_title, locale, locale_resources) { if (Lava.schema.DEBUG && !(widget_title in Lava.widgets)) Lava.t("Widget config not found: " + widget_title); var config = Lava.widgets[widget_title]; if (config.is_extended) Lava.t("Widget is already extended, can not add resources: " + widget_title); if (!config.resources) { config.resources = {} } if (Lava.schema.DEBUG && (locale in config.resources)) Lava.t("Locale is already defined: " + locale); config.resources[locale] = locale_resources; }
javascript
function(widget_title, locale, locale_resources) { if (Lava.schema.DEBUG && !(widget_title in Lava.widgets)) Lava.t("Widget config not found: " + widget_title); var config = Lava.widgets[widget_title]; if (config.is_extended) Lava.t("Widget is already extended, can not add resources: " + widget_title); if (!config.resources) { config.resources = {} } if (Lava.schema.DEBUG && (locale in config.resources)) Lava.t("Locale is already defined: " + locale); config.resources[locale] = locale_resources; }
[ "function", "(", "widget_title", ",", "locale", ",", "locale_resources", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "(", "widget_title", "in", "Lava", ".", "widgets", ")", ")", "Lava", ".", "t", "(", "\"Widget config not found: \"...
Attach resources object to global widget definition @param {string} widget_title The name in {@link Lava#widgets} @param {string} locale Locale of the resource object @param {Object} locale_resources The object with resources for given locale
[ "Attach", "resources", "object", "to", "global", "widget", "definition" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L1271-L1287
46,929
kogarashisan/LiquidLava
lib/packages/core.js
function(top_resources, bottom_resources) { var name, result = Firestorm.Object.copy(top_resources); for (name in bottom_resources) { if (name in result) { if (Lava.schema.DEBUG && result[name].type != bottom_resources[name].type) Lava.t("Resource types mismatch: " + name); if (bottom_resources[name].type == 'component') { result[name] = { type: 'component', value: this.mergeResources(result[name].value, bottom_resources[name].value) }; } else if (bottom_resources[name].type == 'container_stack') { if (result[name].type != 'container_stack') Lava.t(); result[name] = { type: 'container_stack', value: bottom_resources[name].value.concat(result[name].value) } } } else { result[name] = bottom_resources[name]; } } return result; }
javascript
function(top_resources, bottom_resources) { var name, result = Firestorm.Object.copy(top_resources); for (name in bottom_resources) { if (name in result) { if (Lava.schema.DEBUG && result[name].type != bottom_resources[name].type) Lava.t("Resource types mismatch: " + name); if (bottom_resources[name].type == 'component') { result[name] = { type: 'component', value: this.mergeResources(result[name].value, bottom_resources[name].value) }; } else if (bottom_resources[name].type == 'container_stack') { if (result[name].type != 'container_stack') Lava.t(); result[name] = { type: 'container_stack', value: bottom_resources[name].value.concat(result[name].value) } } } else { result[name] = bottom_resources[name]; } } return result; }
[ "function", "(", "top_resources", ",", "bottom_resources", ")", "{", "var", "name", ",", "result", "=", "Firestorm", ".", "Object", ".", "copy", "(", "top_resources", ")", ";", "for", "(", "name", "in", "bottom_resources", ")", "{", "if", "(", "name", "i...
Merge resource objects. `top_resources` is expected to be a copy or a new empty object. Properties in `top_resources` have priority over `bottom_resources` @param {Object} top_resources Child resources @param {Object} bottom_resources Parent resources
[ "Merge", "resource", "objects", ".", "top_resources", "is", "expected", "to", "be", "a", "copy", "or", "a", "new", "empty", "object", ".", "Properties", "in", "top_resources", "have", "priority", "over", "bottom_resources" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L1297-L1336
46,930
kogarashisan/LiquidLava
lib/packages/core.js
function(resource_object) { for (var name in resource_object) { if (resource_object[name].type == 'container_stack') { resource_object[name] = { type: 'container', value: this._mergeRootContainerStack(resource_object[name].value) } } } }
javascript
function(resource_object) { for (var name in resource_object) { if (resource_object[name].type == 'container_stack') { resource_object[name] = { type: 'container', value: this._mergeRootContainerStack(resource_object[name].value) } } } }
[ "function", "(", "resource_object", ")", "{", "for", "(", "var", "name", "in", "resource_object", ")", "{", "if", "(", "resource_object", "[", "name", "]", ".", "type", "==", "'container_stack'", ")", "{", "resource_object", "[", "name", "]", "=", "{", "...
Container operations are stacked until first usage to guarantee correct inheritance @param {Object} resource_object
[ "Container", "operations", "are", "stacked", "until", "first", "usage", "to", "guarantee", "correct", "inheritance" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L1342-L1355
46,931
kogarashisan/LiquidLava
lib/packages/core.js
function(stack) { var i = 0, count = stack.length, result = {}, operation; if (Lava.schema.DEBUG && !Array.isArray(stack)) Lava.t(); for (; i < count; i++) { operation = stack[i]; this[this._container_resources_operations_map[operation.name]](result, operation.name, operation.value); } return result; }
javascript
function(stack) { var i = 0, count = stack.length, result = {}, operation; if (Lava.schema.DEBUG && !Array.isArray(stack)) Lava.t(); for (; i < count; i++) { operation = stack[i]; this[this._container_resources_operations_map[operation.name]](result, operation.name, operation.value); } return result; }
[ "function", "(", "stack", ")", "{", "var", "i", "=", "0", ",", "count", "=", "stack", ".", "length", ",", "result", "=", "{", "}", ",", "operation", ";", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "Array", ".", "isArray", "(", "...
Perform merging of "container_stack" resource into "container" resource @param {Array} stack @returns {Object}
[ "Perform", "merging", "of", "container_stack", "resource", "into", "container", "resource" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L1362-L1378
46,932
kogarashisan/LiquidLava
lib/packages/core.js
function(target_object, path, value) { var path_segments = path.split('.'), segment, resource_name = path_segments.pop(), i = 0, count = path_segments.length; if (Lava.schema.DEBUG && /[a-z]/.test(resource_name)) Lava.t("Terminal resource names must be uppercase"); for (; i < count; i++) { segment = path_segments[i]; if (Lava.schema.DEBUG && /[A-Z]/.test(segment)) Lava.t("Resource component names must be lowercase"); if (!(segment in target_object)) { target_object[segment] = { type: 'component', value: {} }; } else { if (Lava.schema.DEBUG && target_object[segment].type != 'component') Lava.t("Malformed resource definition, path is not component: " + path); } target_object = target_object[segment].value; } if (resource_name in target_object) Lava.t("Resource is already defined: " + path); target_object[resource_name] = value; }
javascript
function(target_object, path, value) { var path_segments = path.split('.'), segment, resource_name = path_segments.pop(), i = 0, count = path_segments.length; if (Lava.schema.DEBUG && /[a-z]/.test(resource_name)) Lava.t("Terminal resource names must be uppercase"); for (; i < count; i++) { segment = path_segments[i]; if (Lava.schema.DEBUG && /[A-Z]/.test(segment)) Lava.t("Resource component names must be lowercase"); if (!(segment in target_object)) { target_object[segment] = { type: 'component', value: {} }; } else { if (Lava.schema.DEBUG && target_object[segment].type != 'component') Lava.t("Malformed resource definition, path is not component: " + path); } target_object = target_object[segment].value; } if (resource_name in target_object) Lava.t("Resource is already defined: " + path); target_object[resource_name] = value; }
[ "function", "(", "target_object", ",", "path", ",", "value", ")", "{", "var", "path_segments", "=", "path", ".", "split", "(", "'.'", ")", ",", "segment", ",", "resource_name", "=", "path_segments", ".", "pop", "(", ")", ",", "i", "=", "0", ",", "cou...
Helper function which puts the value inside the resources object under given path string. Used while parsing templates @param {Object} target_object The resources object which is being parsed @param {string} path Path inside the resources object @param {*} value
[ "Helper", "function", "which", "puts", "the", "value", "inside", "the", "resources", "object", "under", "given", "path", "string", ".", "Used", "while", "parsing", "templates" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L1434-L1469
46,933
kogarashisan/LiquidLava
lib/packages/core.js
function(dest_container, source_container, property_name) { var name, dest = dest_container[property_name], source = source_container[property_name]; for (name in source) { if (!(name in dest)) { dest[name] = source[name]; } } }
javascript
function(dest_container, source_container, property_name) { var name, dest = dest_container[property_name], source = source_container[property_name]; for (name in source) { if (!(name in dest)) { dest[name] = source[name]; } } }
[ "function", "(", "dest_container", ",", "source_container", ",", "property_name", ")", "{", "var", "name", ",", "dest", "=", "dest_container", "[", "property_name", "]", ",", "source", "=", "source_container", "[", "property_name", "]", ";", "for", "(", "name"...
Common property merging algorithm, suitable for most cases @param {_cWidget} dest_container The child config @param {_cWidget} source_container The parent config @param {string} property_name The name of the property to merge
[ "Common", "property", "merging", "algorithm", "suitable", "for", "most", "cases" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L1874-L1890
46,934
kogarashisan/LiquidLava
lib/packages/core.js
function(dest, source, map) { var name; for (name in source) { if (!(name in dest)) { dest[name] = source[name]; } else if (name in map) { if (map[name] == true) { Firestorm.implement(dest[name], source[name]); } else { this._mergeWithMap(dest[name], source[name], map[name]); } } } }
javascript
function(dest, source, map) { var name; for (name in source) { if (!(name in dest)) { dest[name] = source[name]; } else if (name in map) { if (map[name] == true) { Firestorm.implement(dest[name], source[name]); } else { this._mergeWithMap(dest[name], source[name], map[name]); } } } }
[ "function", "(", "dest", ",", "source", ",", "map", ")", "{", "var", "name", ";", "for", "(", "name", "in", "source", ")", "{", "if", "(", "!", "(", "name", "in", "dest", ")", ")", "{", "dest", "[", "name", "]", "=", "source", "[", "name", "]...
Advanced merging algorithm @param {Object} dest @param {Object} source @param {Object} map
[ "Advanced", "merging", "algorithm" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L1898-L1924
46,935
kogarashisan/LiquidLava
lib/packages/core.js
function(config, parent_config) { var locale_cache = {}; if ('resources' in config) { if (Lava.schema.LOCALE in config.resources) { locale_cache = Lava.resources.mergeResources(locale_cache, config.resources[Lava.schema.LOCALE]); } if ('default' in config.resources) { locale_cache = Lava.resources.mergeResources(locale_cache, config.resources['default']); } } if (parent_config && ('resources_cache' in parent_config)) { locale_cache = Lava.resources.mergeResources(locale_cache, parent_config.resources_cache[Lava.schema.LOCALE]); } if (!Firestorm.Object.isEmpty(locale_cache)) { config.resources_cache = {}; config.resources_cache[Lava.schema.LOCALE] = locale_cache; } }
javascript
function(config, parent_config) { var locale_cache = {}; if ('resources' in config) { if (Lava.schema.LOCALE in config.resources) { locale_cache = Lava.resources.mergeResources(locale_cache, config.resources[Lava.schema.LOCALE]); } if ('default' in config.resources) { locale_cache = Lava.resources.mergeResources(locale_cache, config.resources['default']); } } if (parent_config && ('resources_cache' in parent_config)) { locale_cache = Lava.resources.mergeResources(locale_cache, parent_config.resources_cache[Lava.schema.LOCALE]); } if (!Firestorm.Object.isEmpty(locale_cache)) { config.resources_cache = {}; config.resources_cache[Lava.schema.LOCALE] = locale_cache; } }
[ "function", "(", "config", ",", "parent_config", ")", "{", "var", "locale_cache", "=", "{", "}", ";", "if", "(", "'resources'", "in", "config", ")", "{", "if", "(", "Lava", ".", "schema", ".", "LOCALE", "in", "config", ".", "resources", ")", "{", "lo...
Merge algorithm for resources @param {_cWidget} config @param {_cWidget} parent_config
[ "Merge", "algorithm", "for", "resources" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L2008-L2036
46,936
kogarashisan/LiquidLava
lib/packages/core.js
function(config) { var parent_config, parent_widget_name; if ('extends' in config) { parent_widget_name = config['extends']; // returns already extended configs parent_config = Lava.getWidgetConfig(parent_widget_name); for (var name in parent_config) { if (this._exceptions.indexOf(name) == -1) { if (!(name in config)) { config[name] = parent_config[name]; } else if (name in this._widget_config_merged_properties) { this[this._widget_config_merged_properties[name]](config, parent_config, name, parent_widget_name); } } } // delay merging of storage until storage_schema is merged if ('storage' in parent_config) { if (!('storage' in config)) { config['storage'] = parent_config['storage']; } else { this._mergeStorage(config, parent_config, 'storage', parent_widget_name); } } } if (Lava.schema.RESOURCES_ENABLED) { this._extendResources(config, parent_config); } if (config.real_class && !('class_locator' in config)) { config['class'] = Lava.ClassManager.hasConstructor(config.real_class) ? config.real_class : 'Lava.widget.' + config.real_class; } else { config['class'] = null; } config.is_extended = true; }
javascript
function(config) { var parent_config, parent_widget_name; if ('extends' in config) { parent_widget_name = config['extends']; // returns already extended configs parent_config = Lava.getWidgetConfig(parent_widget_name); for (var name in parent_config) { if (this._exceptions.indexOf(name) == -1) { if (!(name in config)) { config[name] = parent_config[name]; } else if (name in this._widget_config_merged_properties) { this[this._widget_config_merged_properties[name]](config, parent_config, name, parent_widget_name); } } } // delay merging of storage until storage_schema is merged if ('storage' in parent_config) { if (!('storage' in config)) { config['storage'] = parent_config['storage']; } else { this._mergeStorage(config, parent_config, 'storage', parent_widget_name); } } } if (Lava.schema.RESOURCES_ENABLED) { this._extendResources(config, parent_config); } if (config.real_class && !('class_locator' in config)) { config['class'] = Lava.ClassManager.hasConstructor(config.real_class) ? config.real_class : 'Lava.widget.' + config.real_class; } else { config['class'] = null; } config.is_extended = true; }
[ "function", "(", "config", ")", "{", "var", "parent_config", ",", "parent_widget_name", ";", "if", "(", "'extends'", "in", "config", ")", "{", "parent_widget_name", "=", "config", "[", "'extends'", "]", ";", "// returns already extended configs", "parent_config", ...
Extend raw widget config @param {_cWidget} config
[ "Extend", "raw", "widget", "config" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L2054-L2112
46,937
kogarashisan/LiquidLava
lib/packages/core.js
function() { this._enable = (Firestorm.Environment.requestAnimationFrame && Lava.schema.system.ALLOW_REQUEST_ANIMATION_FRAME) ? this._enable_AnimationFrame : this._enable_Interval; }
javascript
function() { this._enable = (Firestorm.Environment.requestAnimationFrame && Lava.schema.system.ALLOW_REQUEST_ANIMATION_FRAME) ? this._enable_AnimationFrame : this._enable_Interval; }
[ "function", "(", ")", "{", "this", ".", "_enable", "=", "(", "Firestorm", ".", "Environment", ".", "requestAnimationFrame", "&&", "Lava", ".", "schema", ".", "system", ".", "ALLOW_REQUEST_ANIMATION_FRAME", ")", "?", "this", ".", "_enable_AnimationFrame", ":", ...
Initialize Lava.Cron object
[ "Initialize", "Lava", ".", "Cron", "object" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L2147-L2153
46,938
kogarashisan/LiquidLava
lib/packages/core.js
function(event_name) { var self = this, freeze_protection = this._freeze_protected_events.indexOf(event_name) != -1; // I'm not sure about this, but looks like the argument should be specifically named "event" // http://stackoverflow.com/questions/11188729/jquery-keyup-event-trouble-in-opera // see also this to understand the roots of such behaviour: // http://stackoverflow.com/questions/4968194/event-keyword-in-js return (Firestorm.Environment.browser_name == 'ie') ? function(event) { // IE bug: there can be fractional values for coordinates if ('x' in event.page) { event.page.x = Math.floor(event.page.x); event.page.y = Math.floor(event.page.y); event.client.x = Math.floor(event.client.x); event.client.y = Math.floor(event.client.y); } self._onDomEvent(event_name, event, freeze_protection); } : function(event) { self._onDomEvent(event_name, event, freeze_protection); }; }
javascript
function(event_name) { var self = this, freeze_protection = this._freeze_protected_events.indexOf(event_name) != -1; // I'm not sure about this, but looks like the argument should be specifically named "event" // http://stackoverflow.com/questions/11188729/jquery-keyup-event-trouble-in-opera // see also this to understand the roots of such behaviour: // http://stackoverflow.com/questions/4968194/event-keyword-in-js return (Firestorm.Environment.browser_name == 'ie') ? function(event) { // IE bug: there can be fractional values for coordinates if ('x' in event.page) { event.page.x = Math.floor(event.page.x); event.page.y = Math.floor(event.page.y); event.client.x = Math.floor(event.client.x); event.client.y = Math.floor(event.client.y); } self._onDomEvent(event_name, event, freeze_protection); } : function(event) { self._onDomEvent(event_name, event, freeze_protection); }; }
[ "function", "(", "event_name", ")", "{", "var", "self", "=", "this", ",", "freeze_protection", "=", "this", ".", "_freeze_protected_events", ".", "indexOf", "(", "event_name", ")", "!=", "-", "1", ";", "// I'm not sure about this, but looks like the argument should be...
Used to bind `_onDomEvent` to Core instance @param {string} event_name DOM event name @returns {Function}
[ "Used", "to", "bind", "_onDomEvent", "to", "Core", "instance" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L2373-L2400
46,939
kogarashisan/LiquidLava
lib/packages/core.js
function(event_name) { this._event_listeners[event_name] = this._createEventWrapper(event_name); if ((event_name in this._dom_event_support) && this._dom_event_support[event_name].delegation) { Firestorm.Element.addDelegation(window, event_name, '*', this._event_listeners[event_name]); } else { Firestorm.Element.addListener(window, event_name, this._event_listeners[event_name]); } }
javascript
function(event_name) { this._event_listeners[event_name] = this._createEventWrapper(event_name); if ((event_name in this._dom_event_support) && this._dom_event_support[event_name].delegation) { Firestorm.Element.addDelegation(window, event_name, '*', this._event_listeners[event_name]); } else { Firestorm.Element.addListener(window, event_name, this._event_listeners[event_name]); } }
[ "function", "(", "event_name", ")", "{", "this", ".", "_event_listeners", "[", "event_name", "]", "=", "this", ".", "_createEventWrapper", "(", "event_name", ")", ";", "if", "(", "(", "event_name", "in", "this", ".", "_dom_event_support", ")", "&&", "this", ...
Attach a listener to window object, start listening to the event @param {string} event_name DOM event name
[ "Attach", "a", "listener", "to", "window", "object", "start", "listening", "to", "the", "event" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L2406-L2420
46,940
kogarashisan/LiquidLava
lib/packages/core.js
function(event_name) { if ((event_name in this._dom_event_support) && this._dom_event_support[event_name].delegation) { Firestorm.Element.removeDelegation(window, event_name, '*', this._event_listeners[event_name]); } else { Firestorm.Element.removeListener(window, event_name, this._event_listeners[event_name]); } }
javascript
function(event_name) { if ((event_name in this._dom_event_support) && this._dom_event_support[event_name].delegation) { Firestorm.Element.removeDelegation(window, event_name, '*', this._event_listeners[event_name]); } else { Firestorm.Element.removeListener(window, event_name, this._event_listeners[event_name]); } }
[ "function", "(", "event_name", ")", "{", "if", "(", "(", "event_name", "in", "this", ".", "_dom_event_support", ")", "&&", "this", ".", "_dom_event_support", "[", "event_name", "]", ".", "delegation", ")", "{", "Firestorm", ".", "Element", ".", "removeDelega...
Stop listening to DOM event @param {string} event_name DOM event name
[ "Stop", "listening", "to", "DOM", "event" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L2426-L2438
46,941
kogarashisan/LiquidLava
lib/packages/core.js
function(target, level) { if (!this._scope_refresh_queues[level]) { if (this._min_scope_refresh_level > level) { this._min_scope_refresh_level = level; } this._scope_refresh_queues[level] = []; } // It absolutely must be an object, but it has no methods for performance reasons - to stay as light as possible return { index: this._scope_refresh_queues[level].push(target) - 1 } }
javascript
function(target, level) { if (!this._scope_refresh_queues[level]) { if (this._min_scope_refresh_level > level) { this._min_scope_refresh_level = level; } this._scope_refresh_queues[level] = []; } // It absolutely must be an object, but it has no methods for performance reasons - to stay as light as possible return { index: this._scope_refresh_queues[level].push(target) - 1 } }
[ "function", "(", "target", ",", "level", ")", "{", "if", "(", "!", "this", ".", "_scope_refresh_queues", "[", "level", "]", ")", "{", "if", "(", "this", ".", "_min_scope_refresh_level", ">", "level", ")", "{", "this", ".", "_min_scope_refresh_level", "=", ...
Normal version outside of view refresh cycle - adds scope into refresh queue. @param {Lava.mixin.Refreshable} target @param {number} level @returns {{index: number}}
[ "Normal", "version", "outside", "of", "view", "refresh", "cycle", "-", "adds", "scope", "into", "refresh", "queue", "." ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L2590-L2609
46,942
kogarashisan/LiquidLava
lib/packages/core.js
function(refresh_ticket, level) { if (Lava.schema.DEBUG && refresh_ticket == null) Lava.t(); this._scope_refresh_queues[level][refresh_ticket.index] = null; }
javascript
function(refresh_ticket, level) { if (Lava.schema.DEBUG && refresh_ticket == null) Lava.t(); this._scope_refresh_queues[level][refresh_ticket.index] = null; }
[ "function", "(", "refresh_ticket", ",", "level", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "refresh_ticket", "==", "null", ")", "Lava", ".", "t", "(", ")", ";", "this", ".", "_scope_refresh_queues", "[", "level", "]", "[", "refres...
Remove a scope from update queue @param {{index: number}} refresh_ticket @param {number} level
[ "Remove", "a", "scope", "from", "update", "queue" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L2655-L2661
46,943
kogarashisan/LiquidLava
lib/packages/core.js
function() { if (this._is_refreshing) { Lava.logError("ScopeManager: recursive call to ScopeManager#refresh()"); return; } var count_refresh_cycles = 0, count_levels = this._scope_refresh_queues.length; if (count_levels == 0) { return; } this._is_refreshing = true; this._has_exceptions = false; this._refresh_id++; // find the first existent queue while (this._min_scope_refresh_level < count_levels) { if (this._min_scope_refresh_level in this._scope_refresh_queues) { break; } this._min_scope_refresh_level++; } if (this._min_scope_refresh_level < count_levels) { while (this._scopeRefreshCycle()) { count_refresh_cycles++; } } this._scopeMalfunctionCycle(); if (this._has_exceptions) { this._scope_refresh_queues = this._preserveScopeRefreshQueues(); } else { Lava.schema.DEBUG && this.debugVerify(); this._scope_refresh_queues = []; } this._scope_refresh_current_indices = []; if (this.statistics.max_refresh_cycles < count_refresh_cycles) { this.statistics.max_refresh_cycles = count_refresh_cycles; } this._has_infinite_loop = this._has_exceptions; this._is_refreshing = false; }
javascript
function() { if (this._is_refreshing) { Lava.logError("ScopeManager: recursive call to ScopeManager#refresh()"); return; } var count_refresh_cycles = 0, count_levels = this._scope_refresh_queues.length; if (count_levels == 0) { return; } this._is_refreshing = true; this._has_exceptions = false; this._refresh_id++; // find the first existent queue while (this._min_scope_refresh_level < count_levels) { if (this._min_scope_refresh_level in this._scope_refresh_queues) { break; } this._min_scope_refresh_level++; } if (this._min_scope_refresh_level < count_levels) { while (this._scopeRefreshCycle()) { count_refresh_cycles++; } } this._scopeMalfunctionCycle(); if (this._has_exceptions) { this._scope_refresh_queues = this._preserveScopeRefreshQueues(); } else { Lava.schema.DEBUG && this.debugVerify(); this._scope_refresh_queues = []; } this._scope_refresh_current_indices = []; if (this.statistics.max_refresh_cycles < count_refresh_cycles) { this.statistics.max_refresh_cycles = count_refresh_cycles; } this._has_infinite_loop = this._has_exceptions; this._is_refreshing = false; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "_is_refreshing", ")", "{", "Lava", ".", "logError", "(", "\"ScopeManager: recursive call to ScopeManager#refresh()\"", ")", ";", "return", ";", "}", "var", "count_refresh_cycles", "=", "0", ",", "count_levels", ...
The main refresh loop
[ "The", "main", "refresh", "loop" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L2676-L2745
46,944
kogarashisan/LiquidLava
lib/packages/core.js
function() { var current_level = this._min_scope_refresh_level, count_levels = this._scope_refresh_queues.length, current_queue, i, count; for (;current_level < count_levels; current_level++) { if (current_level in this._scope_refresh_queues) { current_queue = this._scope_refresh_queues[current_level]; count = current_queue.length; if (current_level in this._scope_refresh_current_indices) { i = this._scope_refresh_current_indices[current_level]; } else { this._scope_refresh_current_indices[current_level] = 0; i = 0; } while (i < count) { if (current_queue[i]) { current_queue[i].refresh(this._refresh_id, true); } i++; this._scope_refresh_current_indices[current_level] = i; } } } }
javascript
function() { var current_level = this._min_scope_refresh_level, count_levels = this._scope_refresh_queues.length, current_queue, i, count; for (;current_level < count_levels; current_level++) { if (current_level in this._scope_refresh_queues) { current_queue = this._scope_refresh_queues[current_level]; count = current_queue.length; if (current_level in this._scope_refresh_current_indices) { i = this._scope_refresh_current_indices[current_level]; } else { this._scope_refresh_current_indices[current_level] = 0; i = 0; } while (i < count) { if (current_queue[i]) { current_queue[i].refresh(this._refresh_id, true); } i++; this._scope_refresh_current_indices[current_level] = i; } } } }
[ "function", "(", ")", "{", "var", "current_level", "=", "this", ".", "_min_scope_refresh_level", ",", "count_levels", "=", "this", ".", "_scope_refresh_queues", ".", "length", ",", "current_queue", ",", "i", ",", "count", ";", "for", "(", ";", "current_level",...
A refresh cycle that is launched in case of circular scope dependency It will refresh all dirty scopes one time
[ "A", "refresh", "cycle", "that", "is", "launched", "in", "case", "of", "circular", "scope", "dependency", "It", "will", "refresh", "all", "dirty", "scopes", "one", "time" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L2828-L2871
46,945
kogarashisan/LiquidLava
lib/packages/core.js
function(scope) { var index = this._debug_all_scopes.indexOf(scope); if (index == -1) Lava.t(); this._debug_all_scopes.splice(index, 1); }
javascript
function(scope) { var index = this._debug_all_scopes.indexOf(scope); if (index == -1) Lava.t(); this._debug_all_scopes.splice(index, 1); }
[ "function", "(", "scope", ")", "{", "var", "index", "=", "this", ".", "_debug_all_scopes", ".", "indexOf", "(", "scope", ")", ";", "if", "(", "index", "==", "-", "1", ")", "Lava", ".", "t", "(", ")", ";", "this", ".", "_debug_all_scopes", ".", "spl...
Remove a scope from `_debug_all_scopes` @param {Lava.mixin.Refreshable} scope
[ "Remove", "a", "scope", "from", "_debug_all_scopes" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core.js#L2942-L2948
46,946
mkay581/build-tools
src/utils.js
function (paths) { let scope = function (path) { return process.cwd() + '/' + path; }; if (typeof paths === 'string') { return scope(paths); } else { return paths.map(function (path) { return scope(path); }); } }
javascript
function (paths) { let scope = function (path) { return process.cwd() + '/' + path; }; if (typeof paths === 'string') { return scope(paths); } else { return paths.map(function (path) { return scope(path); }); } }
[ "function", "(", "paths", ")", "{", "let", "scope", "=", "function", "(", "path", ")", "{", "return", "process", ".", "cwd", "(", ")", "+", "'/'", "+", "path", ";", "}", ";", "if", "(", "typeof", "paths", "===", "'string'", ")", "{", "return", "s...
Resolves a relative path to the external project. @param paths
[ "Resolves", "a", "relative", "path", "to", "the", "external", "project", "." ]
005cb840b5db017a33597a8d44d941d156a7a000
https://github.com/mkay581/build-tools/blob/005cb840b5db017a33597a8d44d941d156a7a000/src/utils.js#L7-L18
46,947
mkay581/build-tools
src/utils.js
function () { let rootPath = process.cwd(), config; try { config = require(rootPath + '/bt-config'); } catch (err) { console.warn("Project has no configuration file for bt command!"); } return config; }
javascript
function () { let rootPath = process.cwd(), config; try { config = require(rootPath + '/bt-config'); } catch (err) { console.warn("Project has no configuration file for bt command!"); } return config; }
[ "function", "(", ")", "{", "let", "rootPath", "=", "process", ".", "cwd", "(", ")", ",", "config", ";", "try", "{", "config", "=", "require", "(", "rootPath", "+", "'/bt-config'", ")", ";", "}", "catch", "(", "err", ")", "{", "console", ".", "warn"...
Returns the build-tools configuration, whether its as a bt-config file or grunt file. @returns {undefined|Object}
[ "Returns", "the", "build", "-", "tools", "configuration", "whether", "its", "as", "a", "bt", "-", "config", "file", "or", "grunt", "file", "." ]
005cb840b5db017a33597a8d44d941d156a7a000
https://github.com/mkay581/build-tools/blob/005cb840b5db017a33597a8d44d941d156a7a000/src/utils.js#L24-L34
46,948
titon/probe
src/probe.js
mapPrototypes
function mapPrototypes(vendor, protos, funcs) { var p, f, proto, func; // Loop over each prototype for (p = 0; (proto = protos[p]); p++) { // Loop over each function for (f = 0; (func = funcs[f]); f++) { // Skip if the function already exists on the prototype // We don't wont to cause collisions with built-ins or user defined if (!vendor[func] || proto[func] || proto.prototype[func]) { continue; } // Objects can only use static methods // Applying to the prototype disrupts object literals if (proto === Object) { proto[func] = vendor[func]; } else { extendPrototype.call(this, vendor, proto, func); } } } }
javascript
function mapPrototypes(vendor, protos, funcs) { var p, f, proto, func; // Loop over each prototype for (p = 0; (proto = protos[p]); p++) { // Loop over each function for (f = 0; (func = funcs[f]); f++) { // Skip if the function already exists on the prototype // We don't wont to cause collisions with built-ins or user defined if (!vendor[func] || proto[func] || proto.prototype[func]) { continue; } // Objects can only use static methods // Applying to the prototype disrupts object literals if (proto === Object) { proto[func] = vendor[func]; } else { extendPrototype.call(this, vendor, proto, func); } } } }
[ "function", "mapPrototypes", "(", "vendor", ",", "protos", ",", "funcs", ")", "{", "var", "p", ",", "f", ",", "proto", ",", "func", ";", "// Loop over each prototype", "for", "(", "p", "=", "0", ";", "(", "proto", "=", "protos", "[", "p", "]", ")", ...
Loop over each collection and extend the prototypes. @param {Object} vendor @param {Array} protos @param {Array} funcs
[ "Loop", "over", "each", "collection", "and", "extend", "the", "prototypes", "." ]
86ebdab49fe92405194cf0abfffe1b91d22d7735
https://github.com/titon/probe/blob/86ebdab49fe92405194cf0abfffe1b91d22d7735/src/probe.js#L21-L45
46,949
titon/probe
src/probe.js
extendPrototype
function extendPrototype(vendor, proto, func) { proto.prototype[func] = function() { var args = slice.call(arguments) || []; args.unshift(this); return vendor[func].apply(this, args); }; }
javascript
function extendPrototype(vendor, proto, func) { proto.prototype[func] = function() { var args = slice.call(arguments) || []; args.unshift(this); return vendor[func].apply(this, args); }; }
[ "function", "extendPrototype", "(", "vendor", ",", "proto", ",", "func", ")", "{", "proto", ".", "prototype", "[", "func", "]", "=", "function", "(", ")", "{", "var", "args", "=", "slice", ".", "call", "(", "arguments", ")", "||", "[", "]", ";", "a...
Extend the prototype with the vendor function. Prepend the "this" value to the beginning of the arguments. @param {Object} vendor @param {Object} proto @param {Function} func
[ "Extend", "the", "prototype", "with", "the", "vendor", "function", ".", "Prepend", "the", "this", "value", "to", "the", "beginning", "of", "the", "arguments", "." ]
86ebdab49fe92405194cf0abfffe1b91d22d7735
https://github.com/titon/probe/blob/86ebdab49fe92405194cf0abfffe1b91d22d7735/src/probe.js#L55-L62
46,950
alexindigo/deeply
lib/reduce_object.js
reduceObject
function reduceObject(target, source, merge) { // clone exposed properties Object.keys(source).reduce(function(acc, key) { acc[key] = merge(acc[key], source[key]); return acc; }, target); return target; }
javascript
function reduceObject(target, source, merge) { // clone exposed properties Object.keys(source).reduce(function(acc, key) { acc[key] = merge(acc[key], source[key]); return acc; }, target); return target; }
[ "function", "reduceObject", "(", "target", ",", "source", ",", "merge", ")", "{", "// clone exposed properties", "Object", ".", "keys", "(", "source", ")", ".", "reduce", "(", "function", "(", "acc", ",", "key", ")", "{", "acc", "[", "key", "]", "=", "...
Iterates over own properties of the provided object and copies then over to the target object. While recursively running merge on the elements. @param {mixed} target - target object to modify @param {mixed} source - source object to read from @param {function} merge - iterator to merge sub elements @returns {mixed} - modified target object
[ "Iterates", "over", "own", "properties", "of", "the", "provided", "object", "and", "copies", "then", "over", "to", "the", "target", "object", ".", "While", "recursively", "running", "merge", "on", "the", "elements", "." ]
d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1
https://github.com/alexindigo/deeply/blob/d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1/lib/reduce_object.js#L14-L25
46,951
kogarashisan/LiquidLava
dependencies/jison/lib/jison.js
commonjsMain
function commonjsMain (args) { var cwd = require("file").path(require("file").cwd()); if (!args[1]) throw new Error('Usage: '+args[0]+' FILE'); var source = cwd.join(args[1]).read({charset: "utf-8"}); exports.parser.parse(source); }
javascript
function commonjsMain (args) { var cwd = require("file").path(require("file").cwd()); if (!args[1]) throw new Error('Usage: '+args[0]+' FILE'); var source = cwd.join(args[1]).read({charset: "utf-8"}); exports.parser.parse(source); }
[ "function", "commonjsMain", "(", "args", ")", "{", "var", "cwd", "=", "require", "(", "\"file\"", ")", ".", "path", "(", "require", "(", "\"file\"", ")", ".", "cwd", "(", ")", ")", ";", "if", "(", "!", "args", "[", "1", "]", ")", "throw", "new", ...
default main method for generated commonjs modules
[ "default", "main", "method", "for", "generated", "commonjs", "modules" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/dependencies/jison/lib/jison.js#L889-L895
46,952
zxjly/reactweb-cli
libs/ask.js
prompt
function prompt (data, key, prompt, done) { // skip prompts whose when condition is not met if (prompt.when && !evaluate(prompt.when, data)) { return done() } var promptDefault = prompt.default if (typeof prompt.default === 'function') { promptDefault = function () { return prompt.default.bind(this)(data) } } inquirer.prompt([{ type: promptMapping[prompt.type] || prompt.type, name: key, message: prompt.message || prompt.label || key, default: promptDefault, choices: prompt.choices || [], validate: prompt.validate || function () { return true } }], function (answers) { if (Array.isArray(answers[key])) { data[key] = {} answers[key].forEach(function (multiChoiceAnswer) { data[key][multiChoiceAnswer] = true }) } else if (typeof answers[key] === 'string') { data[key] = answers[key].replace(/"/g, '\\"') } else { data[key] = answers[key] } done() }) }
javascript
function prompt (data, key, prompt, done) { // skip prompts whose when condition is not met if (prompt.when && !evaluate(prompt.when, data)) { return done() } var promptDefault = prompt.default if (typeof prompt.default === 'function') { promptDefault = function () { return prompt.default.bind(this)(data) } } inquirer.prompt([{ type: promptMapping[prompt.type] || prompt.type, name: key, message: prompt.message || prompt.label || key, default: promptDefault, choices: prompt.choices || [], validate: prompt.validate || function () { return true } }], function (answers) { if (Array.isArray(answers[key])) { data[key] = {} answers[key].forEach(function (multiChoiceAnswer) { data[key][multiChoiceAnswer] = true }) } else if (typeof answers[key] === 'string') { data[key] = answers[key].replace(/"/g, '\\"') } else { data[key] = answers[key] } done() }) }
[ "function", "prompt", "(", "data", ",", "key", ",", "prompt", ",", "done", ")", "{", "// skip prompts whose when condition is not met", "if", "(", "prompt", ".", "when", "&&", "!", "evaluate", "(", "prompt", ".", "when", ",", "data", ")", ")", "{", "return...
Inquirer prompt wrapper. @param {Object} data @param {String} key @param {Object} prompt @param {Function} done
[ "Inquirer", "prompt", "wrapper", "." ]
f104c295463ab79e9add0f8ca3f01e38393c5498
https://github.com/zxjly/reactweb-cli/blob/f104c295463ab79e9add0f8ca3f01e38393c5498/libs/ask.js#L34-L67
46,953
mkopit/url-embed
lib/utils.js
function (path) { let classes = []; let files = fs.readdirSync(path); for (let i = 0; i < files.length; i++) { let clazz = require(path + '/' + files[i]); classes.push(clazz); } return classes; }
javascript
function (path) { let classes = []; let files = fs.readdirSync(path); for (let i = 0; i < files.length; i++) { let clazz = require(path + '/' + files[i]); classes.push(clazz); } return classes; }
[ "function", "(", "path", ")", "{", "let", "classes", "=", "[", "]", ";", "let", "files", "=", "fs", ".", "readdirSync", "(", "path", ")", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "files", ".", "length", ";", "i", "++", ")", "{", ...
Requires in all class files in a directory @param {String} [path] - path containing classes
[ "Requires", "in", "all", "class", "files", "in", "a", "directory" ]
e6038f816abdc25499b5cace4dd97a2ea271889c
https://github.com/mkopit/url-embed/blob/e6038f816abdc25499b5cace4dd97a2ea271889c/lib/utils.js#L14-L24
46,954
rainforestapp/decaf
src/parser.js
utility
function utility(name, o) { const {root} = o.scope; if (root.utilities[name]) { return root.utilities[name]; } const ref = root.freeVariable(name); root.assign(ref, UTILITIES[name](o)); root.utilities[name] = ref; }
javascript
function utility(name, o) { const {root} = o.scope; if (root.utilities[name]) { return root.utilities[name]; } const ref = root.freeVariable(name); root.assign(ref, UTILITIES[name](o)); root.utilities[name] = ref; }
[ "function", "utility", "(", "name", ",", "o", ")", "{", "const", "{", "root", "}", "=", "o", ".", "scope", ";", "if", "(", "root", ".", "utilities", "[", "name", "]", ")", "{", "return", "root", ".", "utilities", "[", "name", "]", ";", "}", "co...
Helper for ensuring that utility functions are assigned at the top level. copied from coffee-script compiler
[ "Helper", "for", "ensuring", "that", "utility", "functions", "are", "assigned", "at", "the", "top", "level", ".", "copied", "from", "coffee", "-", "script", "compiler" ]
7f909e3b46d3371ee7d69a9c7e4ac6fb981e0150
https://github.com/rainforestapp/decaf/blob/7f909e3b46d3371ee7d69a9c7e4ac6fb981e0150/src/parser.js#L1729-L1739
46,955
bvalosek/sticky
lib/Repository.js
Repository
function Repository(T) { var mapper = this._mapper = new Mapper(T); this._toMany = function(x) { return mapper.toMany(x); }; this._toSingle = function(x) { return mapper.toSingle(x); }; // Implementation pointers this._get = null; this._getAll = null; this._query = null; this._add = null; this._remove = null; this._fetch = null; this._update = null; this._transforms = []; }
javascript
function Repository(T) { var mapper = this._mapper = new Mapper(T); this._toMany = function(x) { return mapper.toMany(x); }; this._toSingle = function(x) { return mapper.toSingle(x); }; // Implementation pointers this._get = null; this._getAll = null; this._query = null; this._add = null; this._remove = null; this._fetch = null; this._update = null; this._transforms = []; }
[ "function", "Repository", "(", "T", ")", "{", "var", "mapper", "=", "this", ".", "_mapper", "=", "new", "Mapper", "(", "T", ")", ";", "this", ".", "_toMany", "=", "function", "(", "x", ")", "{", "return", "mapper", ".", "toMany", "(", "x", ")", "...
A repository pattern that uses a series of sourced providers that attempt to fire off CRUD-ish methods. Gaurentees a promise-based API and consistent arity of return values. @constructor @param {Function} T
[ "A", "repository", "pattern", "that", "uses", "a", "series", "of", "sourced", "providers", "that", "attempt", "to", "fire", "off", "CRUD", "-", "ish", "methods", ".", "Gaurentees", "a", "promise", "-", "based", "API", "and", "consistent", "arity", "of", "r...
8cb5fdba05be161e5936f7208558bc4702aae59a
https://github.com/bvalosek/sticky/blob/8cb5fdba05be161e5936f7208558bc4702aae59a/lib/Repository.js#L13-L29
46,956
cqql/rfc6902-json-diff-js
lib/diff.js
matrixToOperations
function matrixToOperations (matrix, i, j) { if (i === 0 && j === 0) { return []; } else if (i === 0) { return matrixToOperations(matrix, i, j - 1).concat("add"); } else if (j === 0) { return matrixToOperations(matrix, i - 1, j).concat("remove"); } else { var left = matrix[i][j - 1]; var up = matrix[i - 1][j]; var upleft = matrix[i - 1][j - 1]; if (upleft <= up && upleft <= left) { if (upleft === matrix[i][j]) { return matrixToOperations(matrix, i - 1, j - 1).concat("eq"); } else { return matrixToOperations(matrix, i - 1, j - 1).concat("replace"); } } else if (left <= upleft && left <= up) { return matrixToOperations(matrix, i, j - 1).concat("add"); } else { return matrixToOperations(matrix, i - 1, j).concat("remove"); } } }
javascript
function matrixToOperations (matrix, i, j) { if (i === 0 && j === 0) { return []; } else if (i === 0) { return matrixToOperations(matrix, i, j - 1).concat("add"); } else if (j === 0) { return matrixToOperations(matrix, i - 1, j).concat("remove"); } else { var left = matrix[i][j - 1]; var up = matrix[i - 1][j]; var upleft = matrix[i - 1][j - 1]; if (upleft <= up && upleft <= left) { if (upleft === matrix[i][j]) { return matrixToOperations(matrix, i - 1, j - 1).concat("eq"); } else { return matrixToOperations(matrix, i - 1, j - 1).concat("replace"); } } else if (left <= upleft && left <= up) { return matrixToOperations(matrix, i, j - 1).concat("add"); } else { return matrixToOperations(matrix, i - 1, j).concat("remove"); } } }
[ "function", "matrixToOperations", "(", "matrix", ",", "i", ",", "j", ")", "{", "if", "(", "i", "===", "0", "&&", "j", "===", "0", ")", "{", "return", "[", "]", ";", "}", "else", "if", "(", "i", "===", "0", ")", "{", "return", "matrixToOperations"...
Backtrace an optimal path through a levenshtein distance matrix. @returns {Array} List of operations
[ "Backtrace", "an", "optimal", "path", "through", "a", "levenshtein", "distance", "matrix", "." ]
ee57be69d5331751cd70c2616535e278581088be
https://github.com/cqql/rfc6902-json-diff-js/blob/ee57be69d5331751cd70c2616535e278581088be/lib/diff.js#L16-L40
46,957
xiaokekeT/react-headrooms
src/index.js
normalizeTolerance
function normalizeTolerance (t) { return t === Object(t) ? t : { down: t, up: t } }
javascript
function normalizeTolerance (t) { return t === Object(t) ? t : { down: t, up: t } }
[ "function", "normalizeTolerance", "(", "t", ")", "{", "return", "t", "===", "Object", "(", "t", ")", "?", "t", ":", "{", "down", ":", "t", ",", "up", ":", "t", "}", "}" ]
Helper function for normalizing tolerance option to object format
[ "Helper", "function", "for", "normalizing", "tolerance", "option", "to", "object", "format" ]
94961e6dca7bfb88d24991ca3a0c713841fdd3b1
https://github.com/xiaokekeT/react-headrooms/blob/94961e6dca7bfb88d24991ca3a0c713841fdd3b1/src/index.js#L9-L11
46,958
hkjels/ntask
lib/pool.js
sortByLabel
function sortByLabel(a, b) { if (a.sortval > b.sortval) return -1; else if (a.sortval == b.sortval) return 0; else return 1; }
javascript
function sortByLabel(a, b) { if (a.sortval > b.sortval) return -1; else if (a.sortval == b.sortval) return 0; else return 1; }
[ "function", "sortByLabel", "(", "a", ",", "b", ")", "{", "if", "(", "a", ".", "sortval", ">", "b", ".", "sortval", ")", "return", "-", "1", ";", "else", "if", "(", "a", ".", "sortval", "==", "b", ".", "sortval", ")", "return", "0", ";", "else",...
Sort by label Will sort descending by the label specified Use the reverse flag or function for ascending results
[ "Sort", "by", "label" ]
e0552042e743ef9584bc0f911245635df7acd634
https://github.com/hkjels/ntask/blob/e0552042e743ef9584bc0f911245635df7acd634/lib/pool.js#L154-L158
46,959
waigo/waigo
src/loader.js
function(folder, options) { options = _.extend({ matchFiles: /.+/ig, keepExtensions: false, }, options); return new Promise(function(resolve, reject) { var files = {}; var walker = walk(folder, { followSymlinks: false }); walker.on('file', function(file, stat) { var dirname = path.dirname(file), filename = path.join(path.relative(folder, dirname), path.basename(file)); if (!filename.match(options.matchFiles)) { return; } // strip extension from filename? if (!options.keepExtensions) { var extname = path.extname(filename), filename = filename.substr(0, filename.length - extname.length); } files[filename] = file; }); walker.on('end', function() { resolve(files); }); }); }
javascript
function(folder, options) { options = _.extend({ matchFiles: /.+/ig, keepExtensions: false, }, options); return new Promise(function(resolve, reject) { var files = {}; var walker = walk(folder, { followSymlinks: false }); walker.on('file', function(file, stat) { var dirname = path.dirname(file), filename = path.join(path.relative(folder, dirname), path.basename(file)); if (!filename.match(options.matchFiles)) { return; } // strip extension from filename? if (!options.keepExtensions) { var extname = path.extname(filename), filename = filename.substr(0, filename.length - extname.length); } files[filename] = file; }); walker.on('end', function() { resolve(files); }); }); }
[ "function", "(", "folder", ",", "options", ")", "{", "options", "=", "_", ".", "extend", "(", "{", "matchFiles", ":", "/", ".+", "/", "ig", ",", "keepExtensions", ":", "false", ",", "}", ",", "options", ")", ";", "return", "new", "Promise", "(", "f...
Walk given folder and its subfolders and return all files. @param {String} folder Root folder. @param {Object} [options] Additional options. @param {String} [options.matchFiles] Filter files by this regex. @param {String} [options.keepExtensions] If enabled then file names will keep their extensions. @return {Promise} @private
[ "Walk", "given", "folder", "and", "its", "subfolders", "and", "return", "all", "files", "." ]
b2f50cd66b8b19016e2c7de75733330c791c76ff
https://github.com/waigo/waigo/blob/b2f50cd66b8b19016e2c7de75733330c791c76ff/src/loader.js#L68-L102
46,960
enquirer/readline-ui
index.js
UI
function UI(options) { if (!(this instanceof UI)) { var ui = Object.create(UI.prototype); UI.apply(ui, arguments); return ui; } debug('initializing from <%s>', __filename); this.options = utils.createOptions(options); this.appendedLines = 0; this.height = 0; this.initInterface(); }
javascript
function UI(options) { if (!(this instanceof UI)) { var ui = Object.create(UI.prototype); UI.apply(ui, arguments); return ui; } debug('initializing from <%s>', __filename); this.options = utils.createOptions(options); this.appendedLines = 0; this.height = 0; this.initInterface(); }
[ "function", "UI", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "UI", ")", ")", "{", "var", "ui", "=", "Object", ".", "create", "(", "UI", ".", "prototype", ")", ";", "UI", ".", "apply", "(", "ui", ",", "arguments", ")", ...
Create a readline interface to use in prompts
[ "Create", "a", "readline", "interface", "to", "use", "in", "prompts" ]
38e682c1f17d6b299c67d01caac651e0de98417e
https://github.com/enquirer/readline-ui/blob/38e682c1f17d6b299c67d01caac651e0de98417e/index.js#L14-L25
46,961
waigo/waigo
src/models/cron.js
function(crontab) { let _config = this[$EXTRA]; _config.logger.info(`Setting up cron schedule ${crontab}`); _config.job = new CronJob({ cronTime: crontab, onTick: _.bind(co.wrap(this._cronCallback), this), start: true, }); /* calculate and save time between runs */ // we add 1 second to next date otherwise, _getNextDateFrom() returns // the same date back let nextRunDate = _config.job.nextDate().add(1, 'seconds'); _config.timeBetweenRunsMs = _config.job.cronTime._getNextDateFrom(nextRunDate).valueOf() - nextRunDate.valueOf(); }
javascript
function(crontab) { let _config = this[$EXTRA]; _config.logger.info(`Setting up cron schedule ${crontab}`); _config.job = new CronJob({ cronTime: crontab, onTick: _.bind(co.wrap(this._cronCallback), this), start: true, }); /* calculate and save time between runs */ // we add 1 second to next date otherwise, _getNextDateFrom() returns // the same date back let nextRunDate = _config.job.nextDate().add(1, 'seconds'); _config.timeBetweenRunsMs = _config.job.cronTime._getNextDateFrom(nextRunDate).valueOf() - nextRunDate.valueOf(); }
[ "function", "(", "crontab", ")", "{", "let", "_config", "=", "this", "[", "$EXTRA", "]", ";", "_config", ".", "logger", ".", "info", "(", "`", "${", "crontab", "}", "`", ")", ";", "_config", ".", "job", "=", "new", "CronJob", "(", "{", "cronTime", ...
Start the cron scheduler for this job.
[ "Start", "the", "cron", "scheduler", "for", "this", "job", "." ]
b2f50cd66b8b19016e2c7de75733330c791c76ff
https://github.com/waigo/waigo/blob/b2f50cd66b8b19016e2c7de75733330c791c76ff/src/models/cron.js#L105-L124
46,962
alexindigo/deeply
extra/arrays_append_unique.js
arraysAppendUniqueAdapter
function arraysAppendUniqueAdapter(to, from, merge) { // transfer actual values from.reduce(function(target, value) { // append only if new element isn't present yet if (target.indexOf(value) == -1) { target.push(merge(undefined, value)); } return target; }, to); return to; }
javascript
function arraysAppendUniqueAdapter(to, from, merge) { // transfer actual values from.reduce(function(target, value) { // append only if new element isn't present yet if (target.indexOf(value) == -1) { target.push(merge(undefined, value)); } return target; }, to); return to; }
[ "function", "arraysAppendUniqueAdapter", "(", "to", ",", "from", ",", "merge", ")", "{", "// transfer actual values", "from", ".", "reduce", "(", "function", "(", "target", ",", "value", ")", "{", "// append only if new element isn't present yet", "if", "(", "target...
Adapter to merge arrays by appending cloned elements of the second array to the first unless they already exist in the target array @param {array} to - target array to update @param {array} from - array to clone @param {function} merge - iterator to merge sub elements @returns {array} - modified target object
[ "Adapter", "to", "merge", "arrays", "by", "appending", "cloned", "elements", "of", "the", "second", "array", "to", "the", "first", "unless", "they", "already", "exist", "in", "the", "target", "array" ]
d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1
https://github.com/alexindigo/deeply/blob/d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1/extra/arrays_append_unique.js#L15-L30
46,963
bvalosek/sticky
util/fieldPicker.js
fieldPicker
function fieldPicker(fields) { var map = {}; if (fields instanceof Array) { fields.forEach(function(f) { map[f] = f; }); } else if (typeof fields === 'object') { for (var key in fields) { map[key] = fields[key]; } } return function(input, output) { var target = output || input; for (var key in target) { if (map[key] === undefined) delete target[key]; } }; }
javascript
function fieldPicker(fields) { var map = {}; if (fields instanceof Array) { fields.forEach(function(f) { map[f] = f; }); } else if (typeof fields === 'object') { for (var key in fields) { map[key] = fields[key]; } } return function(input, output) { var target = output || input; for (var key in target) { if (map[key] === undefined) delete target[key]; } }; }
[ "function", "fieldPicker", "(", "fields", ")", "{", "var", "map", "=", "{", "}", ";", "if", "(", "fields", "instanceof", "Array", ")", "{", "fields", ".", "forEach", "(", "function", "(", "f", ")", "{", "map", "[", "f", "]", "=", "f", ";", "}", ...
Map fields from a provider exclusively
[ "Map", "fields", "from", "a", "provider", "exclusively" ]
8cb5fdba05be161e5936f7208558bc4702aae59a
https://github.com/bvalosek/sticky/blob/8cb5fdba05be161e5936f7208558bc4702aae59a/util/fieldPicker.js#L6-L25
46,964
magne4000/node-libquassel
src/libquassel.js
splitOnce
function splitOnce(str, character) { const i = str.indexOf(character); return [ str.slice(0, i), str.slice(i+1) ]; }
javascript
function splitOnce(str, character) { const i = str.indexOf(character); return [ str.slice(0, i), str.slice(i+1) ]; }
[ "function", "splitOnce", "(", "str", ",", "character", ")", "{", "const", "i", "=", "str", ".", "indexOf", "(", "character", ")", ";", "return", "[", "str", ".", "slice", "(", "0", ",", "i", ")", ",", "str", ".", "slice", "(", "i", "+", "1", ")...
This event is fired when quasselcore information are received @typedef {Event} Event:coreinfoinit @property {Object} data @property {boolean} data.Configured - Is the core configured @property {number} data.CoreFeatures @property {String} data.CoreInfo @property {boolean} data.LoginEnabled @property {boolean} data.MsgType - Is always "ClientInitAck" @property {number} data.ProtocolVersion @property {Array} [data.StorageBackends] @property {boolean} data.SupportSsl @property {boolean} data.SupportsCompression This event is fired upon successful login @typedef {Event} Event:login This event is fired upon unsuccessful login @typedef {Event} Event:loginfailed This event is fired upon successful session initialization @typedef {Event} Event:init @property {Object} obj This event is fired when {@link Identity} objects are first initialized @typedef {Event} Event:identities.init @property {Map<number, Identity>} identities This event is fired when a buffer is added to a network @typedef {Event} Event:network.addbuffer @property {number} networkId @property {number|String} bufferId Network latency value @typedef {Event} Event:network.latency @property {number} networkId @property {number} value Network connection state @typedef {Event} Event:network.connectionstate @property {number} networkId @property {number} connectionState This event is fired when a network state is switched to connected @typedef {Event} Event:network.connected @property {number} networkId This event is fired when a network state is switched to disconnected @typedef {Event} Event:network.disconnected @property {number} networkId This event is fired when a user is renamed on a network @typedef {Event} Event:network.userrenamed @property {number} networkId @property {String} oldNick @property {String} nick This event is fired when current connected user is renamed on a network @typedef {Event} Event:network.mynick @property {number} networkId @property {String} nick This event is fired when the name of a network changes @typedef {Event} Event:network.networkname @property {number} networkId @property {String} networkName This event is fired when the server on which a network is connected changes @typedef {Event} Event:network.server @property {number} networkId @property {String} server This event is fired when a network server list is updated @typedef {Event} Event:network.serverlist @property {number} networkId @property {Object[]} serverlist Fired when encoding for sent messages has changed @typedef {Event} Event:network.codec.decoding @property {number} networkId @property {String} codec Fired when encoding for received messages has changed @typedef {Event} Event:network.codec.encoding @property {number} networkId @property {String} codec Fired when server encoding has changed @typedef {Event} Event:network.codec.server @property {number} networkId @property {String} codec Fired when the list of commands to perform on connection to a server has changed @typedef {Event} Event:network.perform @property {number} networkId @property {String[]} commands Fired when the network identity changed @typedef {Event} Event:network.identity @property {number} networkId @property {number} identityId Fired when interval value for reconnecting to the network changed @typedef {Event} Event:network.autoreconnect.interval @property {number} networkId @property {number} interval Fired when retries value for reconnecting to the network changed @typedef {Event} Event:network.autoreconnect.retries @property {number} networkId @property {number} retries Fired when auto identify service changed @typedef {Event} Event:network.autoidentify.service @property {number} networkId @property {String} service Fired when auto identify service password changed @typedef {Event} Event:network.autoidentify.password @property {number} networkId @property {String} password Fired when Unlimited reconnect retries value has changed @typedef {Event} Event:network.unlimitedreconnectretries @property {number} networkId @property {boolean} unlimitedreconnectretries Fired when Use Sasl value has changed @typedef {Event} Event:network.usesasl @property {number} networkId @property {boolean} usesasl Fired when Sasl account has changed @typedef {Event} Event:network.sasl.account @property {number} networkId @property {String} account Fired when Sasl account password has changed @typedef {Event} Event:network.sasl.password @property {number} networkId @property {String} password Fired when Rejoin Channels value has changed @typedef {Event} Event:network.rejoinchannels @property {number} networkId @property {boolean} rejoinchannels Fired when Use Custom Message Rate value has changed @typedef {Event} Event:network.usecustommessagerate @property {number} networkId @property {boolean} usecustommessagerate Fired when Unlimited Message Rate Burst Size value has changed @typedef {Event} Event:network.messagerate.unlimited @property {number} networkId @property {boolean} unlimited Fired when Message Rate Burst Size value has changed @typedef {Event} Event:network.messagerate.burstsize @property {number} networkId @property {number} burstsize Fired when Message Rate Delay value has changed @typedef {Event} Event:network.messagerate.delay @property {number} networkId @property {number} delay Buffer has been marked as read @typedef {Event} Event:buffer.read @property {number} bufferId Buffer's last seen message updated @typedef {Event} Event:buffer.lastseen @property {number} bufferId @property {number} messageId Buffer's markeline attached to a message @typedef {Event} Event:buffer.markerline @property {number} bufferId @property {number} messageId Buffer's activity which represents all unread message types for this buffer @typedef {Event} Event:buffer.activity @property {number} bufferId @property {number} unreadTypes Buffer has been removed @typedef {Event} Event:buffer.remove @property {number} bufferId Buffer has been renamed @typedef {Event} Event:buffer.rename @property {number} bufferId bufferId2 has been merged into bufferId1 @typedef {Event} Event:buffer.merge @property {number} bufferId1 @property {number} bufferId2 Buffer's hidden state removed @typedef {Event} Event:bufferview.bufferunhide @property {number} bufferViewId @property {number} bufferId Buffer's hidden state set @typedef {Event} Event:bufferview.bufferhidden @property {number} bufferViewId @property {number} bufferId @property {String} type Either "temp" or "perm" Buffer set as inactive @typedef {Event} Event:buffer.deactivate @property {number} bufferId User has left a channel @typedef {Event} Event:user.part @property {number} networkId @property {String} nick @property {number} bufferId User has left a network @typedef {Event} Event:user.quit @property {number} networkId @property {String} nick User away state changed @typedef {Event} Event:user.away @property {number} networkId @property {String} nick @property {boolean} isAway User realname changed @typedef {Event} Event:user.realname @property {number} networkId @property {String} nick @property {String} realname User joined a channel @typedef {Event} Event:channel.join @property {number} bufferId @property {String} nick User mode has been added @typedef {Event} Event:channel.addusermode @property {number} bufferId @property {String} nick @property {String} mode User mode has been removed @typedef {Event} Event:channel.removeusermode @property {number} bufferId @property {String} nick @property {String} mode Channel topic changed @typedef {Event} Event:channel.topic @property {number} bufferId @property {String} topic Core information @typedef {Event} Event:coreinfo @property {Object} data {@link IRCBuffer} activated @typedef {Event} Event:buffer.activate @property {number} bufferId Backlogs received @typedef {Event} Event:buffer.backlog @property {number} bufferId @property {number[]} messageIds {@link IRCMessage} received on a buffer @typedef {Event} Event:buffer.message @property {number} bufferId @property {number} messageId Buffers order changed @typedef {Event} Event:bufferview.orderchanged @property {number} bufferViewId {@link BufferView} manager init request received @typedef {Event} Event:bufferview.ids @property {number[]} ids {@link BufferView} initialized @typedef {Event} Event:bufferview.init @property {number} bufferViewId {@link BufferView} networkId updated @typedef {Event} Event:bufferview.networkid @property {number} bufferViewId @property {number} networkId {@link BufferView} search updated @typedef {Event} Event:bufferview.search @property {number} bufferViewId @property {boolean} search {@link BufferView} hideInactiveNetworks updated @typedef {Event} Event:bufferview.hideinactivenetworks @property {number} bufferViewId @property {boolean} hideinactivenetworks {@link BufferView} hideInactiveBuffers updated @typedef {Event} Event:bufferview.hideinactivebuffers @property {number} bufferViewId @property {boolean} hideinactivebuffers {@link BufferView} allowedBufferTypes updated @typedef {Event} Event:bufferview.allowedbuffertypes @property {number} bufferViewId @property {number} allowedbuffertypes {@link BufferView} addNewBuffersAutomatically updated @typedef {Event} Event:bufferview.addnewbuffersautomatically @property {number} bufferViewId @property {boolean} addnewbuffersautomatically {@link BufferView} minimumActivity updated @typedef {Event} Event:bufferview.minimumactivity @property {number} bufferViewId @property {boolean} minimumactivity {@link BufferView} bufferViewName updated @typedef {Event} Event:bufferview.bufferviewname @property {number} bufferViewId @property {String} bufferviewname {@link BufferView} disableDecoration updated @typedef {Event} Event:bufferview.disabledecoration @property {number} bufferViewId @property {boolean} disabledecoration {@link BufferView} object updated @typedef {Event} Event:bufferview.update @property {number} bufferViewId @property {object} data {@link IgnoreList} updated @typedef {Event} Event:ignorelist {@link HighLightRuleManager} updated @typedef {Event} Event:highlightrules {@link Identity} updated @typedef {Event} Event:identity New {@link Identity} created @typedef {Event} Event:identity.new @property {number} identityId {@link Identity} removed @typedef {Event} Event:identity.remove @property {number} identityId User connected to the {@link Network} @typedef {Event} Event:network.adduser @property {number} networkId @property {String} nick New {@link Network} created @typedef {Event} Event:network.new @property {number} networkId {@link Network} removed @typedef {Event} Event:network.remove @property {number} networkId {@link Network} is ready @typedef {Event} Event:network.init @property {number} networkId Aliases updated @typedef {Event} Event:aliases This event is fired when the core needs to be setup @typedef {Event} Event:setup @property {Object[]} backends - List of available storage backends @property {String} backends[].DisplayName - Storage backends name @property {String} backends[].Description - Storage backends description @property {String[]} backends[].SetupKeys - Keys that will need a corresponding value to configure chosen storage backend @property {Object} backends[].SetupDefaults - Defaults values for corresponding SetupKeys This event is fired if the setup of the core was successful @typedef {Event} Event:setupok This event is fired if the setup of the core has failed @typedef {Event} Event:setupfailed @property {Object} error - The reason of the failure This event is fired if an unhandled message is received @typedef {Event} Event:unhandled @property {Object} obj An error occured @typedef {Event} Event:error @property {Object} error
[ "This", "event", "is", "fired", "when", "quasselcore", "information", "are", "received" ]
0cf97378ebe170b0abf4bdcc112933009a84156f
https://github.com/magne4000/node-libquassel/blob/0cf97378ebe170b0abf4bdcc112933009a84156f/src/libquassel.js#L1601-L1604
46,965
azu/performance-mark-metadata
docs/index.js
getRndColor
function getRndColor() { const r = (255 * Math.random()) | 0, g = (255 * Math.random()) | 0, b = (255 * Math.random()) | 0; return "rgb(" + r + "," + g + "," + b + ")"; }
javascript
function getRndColor() { const r = (255 * Math.random()) | 0, g = (255 * Math.random()) | 0, b = (255 * Math.random()) | 0; return "rgb(" + r + "," + g + "," + b + ")"; }
[ "function", "getRndColor", "(", ")", "{", "const", "r", "=", "(", "255", "*", "Math", ".", "random", "(", ")", ")", "|", "0", ",", "g", "=", "(", "255", "*", "Math", ".", "random", "(", ")", ")", "|", "0", ",", "b", "=", "(", "255", "*", ...
It is junk code
[ "It", "is", "junk", "code" ]
a190d1cdb3b6b965f67ad8095c61e37aeb86bd9d
https://github.com/azu/performance-mark-metadata/blob/a190d1cdb3b6b965f67ad8095c61e37aeb86bd9d/docs/index.js#L78-L83
46,966
Soreine/prismjs-components-loader
src/componentDefinitions.js
getDependencies
function getDependencies(component, Prism) { // Cast require to an Array const deps = [].concat(component.require || []); if (Prism) { return deps.filter( dep => // Remove dependencies that are already loaded !Prism.languages[dep] ); } return deps; }
javascript
function getDependencies(component, Prism) { // Cast require to an Array const deps = [].concat(component.require || []); if (Prism) { return deps.filter( dep => // Remove dependencies that are already loaded !Prism.languages[dep] ); } return deps; }
[ "function", "getDependencies", "(", "component", ",", "Prism", ")", "{", "// Cast require to an Array", "const", "deps", "=", "[", "]", ".", "concat", "(", "component", ".", "require", "||", "[", "]", ")", ";", "if", "(", "Prism", ")", "{", "return", "de...
List the dependencies for a component. If Prism is provided, only returns dependencies that are not present in `Prism.languages` @param {Object} component Component definition @param {Prism} Prism instance @return {Array<String>}
[ "List", "the", "dependencies", "for", "a", "component", ".", "If", "Prism", "is", "provided", "only", "returns", "dependencies", "that", "are", "not", "present", "in", "Prism", ".", "languages" ]
e9bbe31e9a407317c99e1fc3848fc7d8a7468f1b
https://github.com/Soreine/prismjs-components-loader/blob/e9bbe31e9a407317c99e1fc3848fc7d8a7468f1b/src/componentDefinitions.js#L59-L71
46,967
darsain/utilus
gulpfile.js
clean
function clean(done) { var del = require('del'); del(cfg.destination).then(function () { if (typeof done === 'function') done(); else process.exit(); }); }
javascript
function clean(done) { var del = require('del'); del(cfg.destination).then(function () { if (typeof done === 'function') done(); else process.exit(); }); }
[ "function", "clean", "(", "done", ")", "{", "var", "del", "=", "require", "(", "'del'", ")", ";", "del", "(", "cfg", ".", "destination", ")", ".", "then", "(", "function", "(", ")", "{", "if", "(", "typeof", "done", "===", "'function'", ")", "done"...
cleanup after itself
[ "cleanup", "after", "itself" ]
36b41f8581a12aa64e0d1d53b080674bf6a0f3c0
https://github.com/darsain/utilus/blob/36b41f8581a12aa64e0d1d53b080674bf6a0f3c0/gulpfile.js#L25-L31
46,968
darsain/utilus
gulpfile.js
serve
function serve() { var browserSync = require('browser-sync'); browserSync({ server: { baseDir: cfg.destination }, ui: false, online: false, open: false, minify: false }); gulp.watch(['*'], {cwd: cfg.destination}).on('change', browserSync.reload); }
javascript
function serve() { var browserSync = require('browser-sync'); browserSync({ server: { baseDir: cfg.destination }, ui: false, online: false, open: false, minify: false }); gulp.watch(['*'], {cwd: cfg.destination}).on('change', browserSync.reload); }
[ "function", "serve", "(", ")", "{", "var", "browserSync", "=", "require", "(", "'browser-sync'", ")", ";", "browserSync", "(", "{", "server", ":", "{", "baseDir", ":", "cfg", ".", "destination", "}", ",", "ui", ":", "false", ",", "online", ":", "false"...
watch files for changes and reload
[ "watch", "files", "for", "changes", "and", "reload" ]
36b41f8581a12aa64e0d1d53b080674bf6a0f3c0
https://github.com/darsain/utilus/blob/36b41f8581a12aa64e0d1d53b080674bf6a0f3c0/gulpfile.js#L65-L79
46,969
waigo/waigo
src/support/lodashMixins.js
function(type, obj) { switch (type) { case 'greet': var name = _.get(obj, 'profile.displayName') || _.get(obj, 'username', '') || obj; return _.get(name, 'length') ? name : 'Hey'; break; } return obj; }
javascript
function(type, obj) { switch (type) { case 'greet': var name = _.get(obj, 'profile.displayName') || _.get(obj, 'username', '') || obj; return _.get(name, 'length') ? name : 'Hey'; break; } return obj; }
[ "function", "(", "type", ",", "obj", ")", "{", "switch", "(", "type", ")", "{", "case", "'greet'", ":", "var", "name", "=", "_", ".", "get", "(", "obj", ",", "'profile.displayName'", ")", "||", "_", ".", "get", "(", "obj", ",", "'username'", ",", ...
Format user name for display. @param {String} type How to format. @param {User|String} obj The user object or username string. @return {*}
[ "Format", "user", "name", "for", "display", "." ]
b2f50cd66b8b19016e2c7de75733330c791c76ff
https://github.com/waigo/waigo/blob/b2f50cd66b8b19016e2c7de75733330c791c76ff/src/support/lodashMixins.js#L20-L30
46,970
ngokevin/redux-localstorage-slicer
index.js
createSlicer
function createSlicer(version) { if (version !== undefined) { // For invalidation. var currentVersion = localStorage.getItem(LS_VERSION_KEY); if (version > currentVersion) { localStorage.removeItem('redux'); localStorage.setItem(LS_VERSION_KEY, version); } } return function (paths) { return function (state) { var syncedState = {}; Object.keys(state).forEach(function (path) { // Loop through each branch of the state, building our synced state. var substate = state[path]; if (!substate) { return; } if (substate.__persist) { // Only persist if __persist is specified. var persist = substate.__persist; if (persist === true) { // Sync the whole state if __persist is just `true`. syncedState[path] = substate; } else if (persist.constructor === Function) { // Sync state according to function. var subsubstate = persist(substate); // Always have to keep __persist around. if (!subsubstate.__persist) { subsubstate.__persist = persist; } syncedState[path] = subsubstate; } else if (persist.constructor === Array) { (function () { // Sync state filtering by array of keys. var subsubstate = {}; persist.forEach(function (key) { subsubstate[key] = substate[key]; }); // Always have to keep __persist around. if (!subsubstate.__persist) { subsubstate.__persist = persist; } syncedState[path] = subsubstate; })(); } else if (persist.constructor === String) { // Deserialized a stored persist function. eval is OK here, right? syncedState[path] = eval(persist)(substate); } } }); return syncedState; }; }; }
javascript
function createSlicer(version) { if (version !== undefined) { // For invalidation. var currentVersion = localStorage.getItem(LS_VERSION_KEY); if (version > currentVersion) { localStorage.removeItem('redux'); localStorage.setItem(LS_VERSION_KEY, version); } } return function (paths) { return function (state) { var syncedState = {}; Object.keys(state).forEach(function (path) { // Loop through each branch of the state, building our synced state. var substate = state[path]; if (!substate) { return; } if (substate.__persist) { // Only persist if __persist is specified. var persist = substate.__persist; if (persist === true) { // Sync the whole state if __persist is just `true`. syncedState[path] = substate; } else if (persist.constructor === Function) { // Sync state according to function. var subsubstate = persist(substate); // Always have to keep __persist around. if (!subsubstate.__persist) { subsubstate.__persist = persist; } syncedState[path] = subsubstate; } else if (persist.constructor === Array) { (function () { // Sync state filtering by array of keys. var subsubstate = {}; persist.forEach(function (key) { subsubstate[key] = substate[key]; }); // Always have to keep __persist around. if (!subsubstate.__persist) { subsubstate.__persist = persist; } syncedState[path] = subsubstate; })(); } else if (persist.constructor === String) { // Deserialized a stored persist function. eval is OK here, right? syncedState[path] = eval(persist)(substate); } } }); return syncedState; }; }; }
[ "function", "createSlicer", "(", "version", ")", "{", "if", "(", "version", "!==", "undefined", ")", "{", "// For invalidation.", "var", "currentVersion", "=", "localStorage", ".", "getItem", "(", "LS_VERSION_KEY", ")", ";", "if", "(", "version", ">", "current...
Slicer that allows each reducer to define their own persist configuration.
[ "Slicer", "that", "allows", "each", "reducer", "to", "define", "their", "own", "persist", "configuration", "." ]
50db9f8b7c1a74419534bedfcc7ce5f7f8bb4e51
https://github.com/ngokevin/redux-localstorage-slicer/blob/50db9f8b7c1a74419534bedfcc7ce5f7f8bb4e51/index.js#L14-L75
46,971
shinout/FASTAReader
lib/FASTAReader.js
idx2pos
function idx2pos(idx, prelen, linelen) { prelen = prelen || 0; linelen = linelen || 50; idx = Number(idx); return Math.max(0, idx - prelen - Math.floor((idx - prelen)/(linelen + 1))) + 1; }
javascript
function idx2pos(idx, prelen, linelen) { prelen = prelen || 0; linelen = linelen || 50; idx = Number(idx); return Math.max(0, idx - prelen - Math.floor((idx - prelen)/(linelen + 1))) + 1; }
[ "function", "idx2pos", "(", "idx", ",", "prelen", ",", "linelen", ")", "{", "prelen", "=", "prelen", "||", "0", ";", "linelen", "=", "linelen", "||", "50", ";", "idx", "=", "Number", "(", "idx", ")", ";", "return", "Math", ".", "max", "(", "0", "...
FASTAReader.idx2pos convert charcter index to DNA base position @param number idx : character index (leftside) @param number prelen : header data length @param number linelen : one line length @return number : DNA base position
[ "FASTAReader", ".", "idx2pos", "convert", "charcter", "index", "to", "DNA", "base", "position" ]
f9b55f2f15e364804957569cfe60fc7305ff1543
https://github.com/shinout/FASTAReader/blob/f9b55f2f15e364804957569cfe60fc7305ff1543/lib/FASTAReader.js#L288-L293
46,972
leesei/hkbus
helper.js
string2Boolean
function string2Boolean (string, defaultTrue) { // console.log('2bool:', String(string).toLowerCase()); switch (String(string).toLowerCase()) { case '': return (defaultTrue === undefined) ? false : defaultTrue; case 'true': case '1': case 'yes': case 'y': return true; case 'false': case '0': case 'no': case 'n': return false; default: // you could throw an error, but 'undefined' seems a more logical reply return undefined; } }
javascript
function string2Boolean (string, defaultTrue) { // console.log('2bool:', String(string).toLowerCase()); switch (String(string).toLowerCase()) { case '': return (defaultTrue === undefined) ? false : defaultTrue; case 'true': case '1': case 'yes': case 'y': return true; case 'false': case '0': case 'no': case 'n': return false; default: // you could throw an error, but 'undefined' seems a more logical reply return undefined; } }
[ "function", "string2Boolean", "(", "string", ",", "defaultTrue", ")", "{", "// console.log('2bool:', String(string).toLowerCase());", "switch", "(", "String", "(", "string", ")", ".", "toLowerCase", "(", ")", ")", "{", "case", "''", ":", "return", "(", "defaultTru...
Convert sensible strings to Boolean, useful for parsing URL queries
[ "Convert", "sensible", "strings", "to", "Boolean", "useful", "for", "parsing", "URL", "queries" ]
5cafa725aa7412fc77d91f336a9d631c0da7616f
https://github.com/leesei/hkbus/blob/5cafa725aa7412fc77d91f336a9d631c0da7616f/helper.js#L2-L21
46,973
nikku/selection-update
index.js
calculateUpdate
function calculateUpdate(currentSelection, currentValue, newValue) { var currentCursor = currentSelection.start, newCursor = currentCursor, diff = newValue.length - currentValue.length, idx; var lengthDelta = newValue.length - currentValue.length; var currentTail = currentValue.substring(currentCursor); // check if we can remove common ending from the equation // to be able to properly detect a selection change for // the following scenarios: // // * (AAATTT|TF) => (AAAT|TF) // * (AAAT|TF) => (AAATTT|TF) // if (newValue.lastIndexOf(currentTail) === newValue.length - currentTail.length) { currentValue = currentValue.substring(0, currentValue.length - currentTail.length); newValue = newValue.substring(0, newValue.length - currentTail.length); } // diff var diff = createDiff(currentValue, newValue); if (diff) { if (diff.type === 'remove') { newCursor = diff.newStart; } else { newCursor = diff.newEnd; } } return range(newCursor); }
javascript
function calculateUpdate(currentSelection, currentValue, newValue) { var currentCursor = currentSelection.start, newCursor = currentCursor, diff = newValue.length - currentValue.length, idx; var lengthDelta = newValue.length - currentValue.length; var currentTail = currentValue.substring(currentCursor); // check if we can remove common ending from the equation // to be able to properly detect a selection change for // the following scenarios: // // * (AAATTT|TF) => (AAAT|TF) // * (AAAT|TF) => (AAATTT|TF) // if (newValue.lastIndexOf(currentTail) === newValue.length - currentTail.length) { currentValue = currentValue.substring(0, currentValue.length - currentTail.length); newValue = newValue.substring(0, newValue.length - currentTail.length); } // diff var diff = createDiff(currentValue, newValue); if (diff) { if (diff.type === 'remove') { newCursor = diff.newStart; } else { newCursor = diff.newEnd; } } return range(newCursor); }
[ "function", "calculateUpdate", "(", "currentSelection", ",", "currentValue", ",", "newValue", ")", "{", "var", "currentCursor", "=", "currentSelection", ".", "start", ",", "newCursor", "=", "currentCursor", ",", "diff", "=", "newValue", ".", "length", "-", "curr...
Calculate the selection update for the given current and new input values. @param {Object} currentSelection as {start, end} @param {String} currentValue @param {String} newValue @return {Object} newSelection as {start, end}
[ "Calculate", "the", "selection", "update", "for", "the", "given", "current", "and", "new", "input", "values", "." ]
22379d4b3fa4f23d76027eda978e0e6753bd37aa
https://github.com/nikku/selection-update/blob/22379d4b3fa4f23d76027eda978e0e6753bd37aa/index.js#L13-L48
46,974
basicdays/co-pg
lib/client-factory.js
buildNativeCoClientBuilder
function buildNativeCoClientBuilder(clientBuilder) { return function nativeCoClientBuilder(config) { var connection = clientBuilder(config); connection.connectAsync = promissory(connection.connect); connection.queryAsync = promissory(connection.query); // for backwards compatibility connection.connectPromise = connection.connectAsync; connection.queryPromise = connection.queryAsync; return connection; }; }
javascript
function buildNativeCoClientBuilder(clientBuilder) { return function nativeCoClientBuilder(config) { var connection = clientBuilder(config); connection.connectAsync = promissory(connection.connect); connection.queryAsync = promissory(connection.query); // for backwards compatibility connection.connectPromise = connection.connectAsync; connection.queryPromise = connection.queryAsync; return connection; }; }
[ "function", "buildNativeCoClientBuilder", "(", "clientBuilder", ")", "{", "return", "function", "nativeCoClientBuilder", "(", "config", ")", "{", "var", "connection", "=", "clientBuilder", "(", "config", ")", ";", "connection", ".", "connectAsync", "=", "promissory"...
Wrap the `pg` `clientBuilder` function to add co extensions. Since the exposed `clientBuilder` function from `pg.native` is a simple function that wraps the construction of a native client connection, we don't have easy access to the prototype to inherit prior to construction of the connection. Instead, we call the `pg` `connectionBuilder` to get an instance of the connection and add additional methods directly to the constructed object. The methods are *not* added to the `pg` `Connection` prototype however, as that would alter the prototype in `pg`, and would increase the `co-pg` footprint beyond constructed objects that have been tunneled through this package. @param {function} clientBuilder the native client builder from `pg` @returns {function} the native client builder with co extensions
[ "Wrap", "the", "pg", "clientBuilder", "function", "to", "add", "co", "extensions", "." ]
14924931b6fe0d14d7903d4917f0681bee874a37
https://github.com/basicdays/co-pg/blob/14924931b6fe0d14d7903d4917f0681bee874a37/lib/client-factory.js#L35-L48
46,975
Kami/node-buildbot-github
lib/pollers.js
BuildbotPoller
function BuildbotPoller(options, interval) { Poller.call(this, 'buildbot', options, interval); this._host = this._options['host']; this._port = this._options['port']; this._username = this._options['username']; this._password = this._options['password']; this._numBuilds = this._options['num_builds']; this._fetchBuildDataReqObj = null; }
javascript
function BuildbotPoller(options, interval) { Poller.call(this, 'buildbot', options, interval); this._host = this._options['host']; this._port = this._options['port']; this._username = this._options['username']; this._password = this._options['password']; this._numBuilds = this._options['num_builds']; this._fetchBuildDataReqObj = null; }
[ "function", "BuildbotPoller", "(", "options", ",", "interval", ")", "{", "Poller", ".", "call", "(", "this", ",", "'buildbot'", ",", "options", ",", "interval", ")", ";", "this", ".", "_host", "=", "this", ".", "_options", "[", "'host'", "]", ";", "thi...
Polls buildbot for new builds
[ "Polls", "buildbot", "for", "new", "builds" ]
7cc457a11617ea4925d0782cd13a8f7789707199
https://github.com/Kami/node-buildbot-github/blob/7cc457a11617ea4925d0782cd13a8f7789707199/lib/pollers.js#L49-L59
46,976
soajs/connect-mongo-soajs
lib/index.js
MongoStore
function MongoStore(options) { options = options || {}; for (var property in defaultOptions) { if (defaultOptions.hasOwnProperty(property)) { if (!options.hasOwnProperty(property) || (typeof defaultOptions[property] !== typeof options[property])) options[property] = defaultOptions[property]; } } Store.call(this, options.store); var dbProperties = ["name", "prefix", "servers", "credentials", "URLParam", "extraParam"]; var dbPropertiesLen = dbProperties.length; var dbOptions = {}; for (var i = 0; i < dbPropertiesLen; i++) dbOptions[dbProperties[i]] = options[dbProperties[i]]; this.mongo = new Mongo(dbOptions); this.mongo.ensureIndex(options.collection, {expires: 1}, {expireAfterSeconds: 0}, function (err, result) { if (err) throw new Error('Error setting TTL index on collection : ' + options.collection + ' <' + err + '>'); }); this._options = { "collection": options.collection, "stringify": options.stringify, "expireAfter": options.expireAfter }; }
javascript
function MongoStore(options) { options = options || {}; for (var property in defaultOptions) { if (defaultOptions.hasOwnProperty(property)) { if (!options.hasOwnProperty(property) || (typeof defaultOptions[property] !== typeof options[property])) options[property] = defaultOptions[property]; } } Store.call(this, options.store); var dbProperties = ["name", "prefix", "servers", "credentials", "URLParam", "extraParam"]; var dbPropertiesLen = dbProperties.length; var dbOptions = {}; for (var i = 0; i < dbPropertiesLen; i++) dbOptions[dbProperties[i]] = options[dbProperties[i]]; this.mongo = new Mongo(dbOptions); this.mongo.ensureIndex(options.collection, {expires: 1}, {expireAfterSeconds: 0}, function (err, result) { if (err) throw new Error('Error setting TTL index on collection : ' + options.collection + ' <' + err + '>'); }); this._options = { "collection": options.collection, "stringify": options.stringify, "expireAfter": options.expireAfter }; }
[ "function", "MongoStore", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "for", "(", "var", "property", "in", "defaultOptions", ")", "{", "if", "(", "defaultOptions", ".", "hasOwnProperty", "(", "property", ")", ")", "{", "if",...
Initialize MongoStore with the given `options`. @param {Object} options
[ "Initialize", "MongoStore", "with", "the", "given", "options", "." ]
27b7b0b0f25e75168857fd9d2be83cc07a0da868
https://github.com/soajs/connect-mongo-soajs/blob/27b7b0b0f25e75168857fd9d2be83cc07a0da868/lib/index.js#L52-L81
46,977
tmont/jarvis
src/stacktrace.js
function(e) { var stack = e.stacktrace; var lines = stack.split('\n'), ANON = '{anonymous}', lineRE = /.*line (\d+), column (\d+) in ((<anonymous function\:?\s*(\S+))|([^\(]+)\([^\)]*\))(?: in )?(.*)\s*$/i, i, j, len; for (i = 2, j = 0, len = lines.length; i < len - 2; i++) { if (lineRE.test(lines[i])) { var location = RegExp.$6 + ':' + RegExp.$1 + ':' + RegExp.$2; var fnName = RegExp.$3; fnName = fnName.replace(/<anonymous function\:?\s?(\S+)?>/g, ANON); lines[j++] = fnName + '@' + location; } } lines.splice(j, lines.length - j); return lines; }
javascript
function(e) { var stack = e.stacktrace; var lines = stack.split('\n'), ANON = '{anonymous}', lineRE = /.*line (\d+), column (\d+) in ((<anonymous function\:?\s*(\S+))|([^\(]+)\([^\)]*\))(?: in )?(.*)\s*$/i, i, j, len; for (i = 2, j = 0, len = lines.length; i < len - 2; i++) { if (lineRE.test(lines[i])) { var location = RegExp.$6 + ':' + RegExp.$1 + ':' + RegExp.$2; var fnName = RegExp.$3; fnName = fnName.replace(/<anonymous function\:?\s?(\S+)?>/g, ANON); lines[j++] = fnName + '@' + location; } } lines.splice(j, lines.length - j); return lines; }
[ "function", "(", "e", ")", "{", "var", "stack", "=", "e", ".", "stacktrace", ";", "var", "lines", "=", "stack", ".", "split", "(", "'\\n'", ")", ",", "ANON", "=", "'{anonymous}'", ",", "lineRE", "=", "/", ".*line (\\d+), column (\\d+) in ((<anonymous functio...
Given an Error object, return a formatted Array based on Opera 10's stacktrace string. @param e - Error object to inspect @return Array<String> of function calls, files and line numbers
[ "Given", "an", "Error", "object", "return", "a", "formatted", "Array", "based", "on", "Opera", "10", "s", "stacktrace", "string", "." ]
8264b88904415f64310f0640937978867ca2d1b8
https://github.com/tmont/jarvis/blob/8264b88904415f64310f0640937978867ca2d1b8/src/stacktrace.js#L164-L178
46,978
tmont/jarvis
src/stacktrace.js
function(e) { var lines = e.message.split('\n'), ANON = '{anonymous}', lineRE = /Line\s+(\d+).*script\s+(http\S+)(?:.*in\s+function\s+(\S+))?/i, i, j, len; for (i = 4, j = 0, len = lines.length; i < len; i += 2) { //TODO: RegExp.exec() would probably be cleaner here if (lineRE.test(lines[i])) { lines[j++] = (RegExp.$3 ? RegExp.$3 + '()@' + RegExp.$2 + RegExp.$1 : ANON + '()@' + RegExp.$2 + ':' + RegExp.$1) + ' -- ' + lines[i + 1].replace(/^\s+/, ''); } } lines.splice(j, lines.length - j); return lines; }
javascript
function(e) { var lines = e.message.split('\n'), ANON = '{anonymous}', lineRE = /Line\s+(\d+).*script\s+(http\S+)(?:.*in\s+function\s+(\S+))?/i, i, j, len; for (i = 4, j = 0, len = lines.length; i < len; i += 2) { //TODO: RegExp.exec() would probably be cleaner here if (lineRE.test(lines[i])) { lines[j++] = (RegExp.$3 ? RegExp.$3 + '()@' + RegExp.$2 + RegExp.$1 : ANON + '()@' + RegExp.$2 + ':' + RegExp.$1) + ' -- ' + lines[i + 1].replace(/^\s+/, ''); } } lines.splice(j, lines.length - j); return lines; }
[ "function", "(", "e", ")", "{", "var", "lines", "=", "e", ".", "message", ".", "split", "(", "'\\n'", ")", ",", "ANON", "=", "'{anonymous}'", ",", "lineRE", "=", "/", "Line\\s+(\\d+).*script\\s+(http\\S+)(?:.*in\\s+function\\s+(\\S+))?", "/", "i", ",", "i", ...
Opera 7.x-9.x only!
[ "Opera", "7", ".", "x", "-", "9", ".", "x", "only!" ]
8264b88904415f64310f0640937978867ca2d1b8
https://github.com/tmont/jarvis/blob/8264b88904415f64310f0640937978867ca2d1b8/src/stacktrace.js#L181-L193
46,979
tmont/jarvis
src/stacktrace.js
function(curr) { var ANON = '{anonymous}', fnRE = /function\s*([\w\-$]+)?\s*\(/i, stack = [], fn, args, maxStackSize = 10; while (curr && stack.length < maxStackSize) { fn = fnRE.test(curr.toString()) ? RegExp.$1 || ANON : ANON; args = Array.prototype.slice.call(curr['arguments'] || []); stack[stack.length] = fn + '(' + this.stringifyArguments(args) + ')'; curr = curr.caller; } return stack; }
javascript
function(curr) { var ANON = '{anonymous}', fnRE = /function\s*([\w\-$]+)?\s*\(/i, stack = [], fn, args, maxStackSize = 10; while (curr && stack.length < maxStackSize) { fn = fnRE.test(curr.toString()) ? RegExp.$1 || ANON : ANON; args = Array.prototype.slice.call(curr['arguments'] || []); stack[stack.length] = fn + '(' + this.stringifyArguments(args) + ')'; curr = curr.caller; } return stack; }
[ "function", "(", "curr", ")", "{", "var", "ANON", "=", "'{anonymous}'", ",", "fnRE", "=", "/", "function\\s*([\\w\\-$]+)?\\s*\\(", "/", "i", ",", "stack", "=", "[", "]", ",", "fn", ",", "args", ",", "maxStackSize", "=", "10", ";", "while", "(", "curr",...
Safari, IE, and others
[ "Safari", "IE", "and", "others" ]
8264b88904415f64310f0640937978867ca2d1b8
https://github.com/tmont/jarvis/blob/8264b88904415f64310f0640937978867ca2d1b8/src/stacktrace.js#L196-L205
46,980
tmont/jarvis
src/stacktrace.js
function(args) { for (var i = 0; i < args.length; ++i) { var arg = args[i]; if (arg === undefined) { args[i] = 'undefined'; } else if (arg === null) { args[i] = 'null'; } else if (arg.constructor) { if (arg.constructor === Array) { if (arg.length < 3) { args[i] = '[' + this.stringifyArguments(arg) + ']'; } else { args[i] = '[' + this.stringifyArguments(Array.prototype.slice.call(arg, 0, 1)) + '...' + this.stringifyArguments(Array.prototype.slice.call(arg, -1)) + ']'; } } else if (arg.constructor === Object) { args[i] = '#object'; } else if (arg.constructor === Function) { args[i] = '#function'; } else if (arg.constructor === String) { args[i] = '"' + arg + '"'; } } } return args.join(','); }
javascript
function(args) { for (var i = 0; i < args.length; ++i) { var arg = args[i]; if (arg === undefined) { args[i] = 'undefined'; } else if (arg === null) { args[i] = 'null'; } else if (arg.constructor) { if (arg.constructor === Array) { if (arg.length < 3) { args[i] = '[' + this.stringifyArguments(arg) + ']'; } else { args[i] = '[' + this.stringifyArguments(Array.prototype.slice.call(arg, 0, 1)) + '...' + this.stringifyArguments(Array.prototype.slice.call(arg, -1)) + ']'; } } else if (arg.constructor === Object) { args[i] = '#object'; } else if (arg.constructor === Function) { args[i] = '#function'; } else if (arg.constructor === String) { args[i] = '"' + arg + '"'; } } } return args.join(','); }
[ "function", "(", "args", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "++", "i", ")", "{", "var", "arg", "=", "args", "[", "i", "]", ";", "if", "(", "arg", "===", "undefined", ")", "{", "args", "[",...
Given arguments array as a String, subsituting type names for non-string types. @param {Arguments} object @return {Array} of Strings with stringified arguments
[ "Given", "arguments", "array", "as", "a", "String", "subsituting", "type", "names", "for", "non", "-", "string", "types", "." ]
8264b88904415f64310f0640937978867ca2d1b8
https://github.com/tmont/jarvis/blob/8264b88904415f64310f0640937978867ca2d1b8/src/stacktrace.js#L213-L237
46,981
liquidlight/postcss-pseudo-content-insert
index.js
arrayHasValue
function arrayHasValue(arr, value) { var idx = arr.indexOf(value); if (idx !== -1) { return true; } return false; }
javascript
function arrayHasValue(arr, value) { var idx = arr.indexOf(value); if (idx !== -1) { return true; } return false; }
[ "function", "arrayHasValue", "(", "arr", ",", "value", ")", "{", "var", "idx", "=", "arr", ".", "indexOf", "(", "value", ")", ";", "if", "(", "idx", "!==", "-", "1", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks to see if a value exists in an array
[ "Checks", "to", "see", "if", "a", "value", "exists", "in", "an", "array" ]
51fd77d93a0cfb6a718a19d311f8e0b7108b82e5
https://github.com/liquidlight/postcss-pseudo-content-insert/blob/51fd77d93a0cfb6a718a19d311f8e0b7108b82e5/index.js#L19-L25
46,982
lakenen/wrap-range-text
index.js
getTextNodes
function getTextNodes(el) { el = el || document.body var doc = el.ownerDocument || document , walker = doc.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false) , textNodes = [] , node while (node = walker.nextNode()) { textNodes.push(node) } return textNodes }
javascript
function getTextNodes(el) { el = el || document.body var doc = el.ownerDocument || document , walker = doc.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false) , textNodes = [] , node while (node = walker.nextNode()) { textNodes.push(node) } return textNodes }
[ "function", "getTextNodes", "(", "el", ")", "{", "el", "=", "el", "||", "document", ".", "body", "var", "doc", "=", "el", ".", "ownerDocument", "||", "document", ",", "walker", "=", "doc", ".", "createTreeWalker", "(", "el", ",", "NodeFilter", ".", "SH...
return all text nodes that are contained within `el`
[ "return", "all", "text", "nodes", "that", "are", "contained", "within", "el" ]
b71282c935ba2412e1662b7e77f8b954e3033196
https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L3-L15
46,983
lakenen/wrap-range-text
index.js
rangesIntersect
function rangesIntersect(rangeA, rangeB) { return rangeA.compareBoundaryPoints(Range.END_TO_START, rangeB) === -1 && rangeA.compareBoundaryPoints(Range.START_TO_END, rangeB) === 1 }
javascript
function rangesIntersect(rangeA, rangeB) { return rangeA.compareBoundaryPoints(Range.END_TO_START, rangeB) === -1 && rangeA.compareBoundaryPoints(Range.START_TO_END, rangeB) === 1 }
[ "function", "rangesIntersect", "(", "rangeA", ",", "rangeB", ")", "{", "return", "rangeA", ".", "compareBoundaryPoints", "(", "Range", ".", "END_TO_START", ",", "rangeB", ")", "===", "-", "1", "&&", "rangeA", ".", "compareBoundaryPoints", "(", "Range", ".", ...
return true if `rangeA` intersects `rangeB`
[ "return", "true", "if", "rangeA", "intersects", "rangeB" ]
b71282c935ba2412e1662b7e77f8b954e3033196
https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L18-L21
46,984
lakenen/wrap-range-text
index.js
createRangeFromNode
function createRangeFromNode(node) { var range = node.ownerDocument.createRange() try { range.selectNode(node) } catch (e) { range.selectNodeContents(node) } return range }
javascript
function createRangeFromNode(node) { var range = node.ownerDocument.createRange() try { range.selectNode(node) } catch (e) { range.selectNodeContents(node) } return range }
[ "function", "createRangeFromNode", "(", "node", ")", "{", "var", "range", "=", "node", ".", "ownerDocument", ".", "createRange", "(", ")", "try", "{", "range", ".", "selectNode", "(", "node", ")", "}", "catch", "(", "e", ")", "{", "range", ".", "select...
create and return a range that selects `node`
[ "create", "and", "return", "a", "range", "that", "selects", "node" ]
b71282c935ba2412e1662b7e77f8b954e3033196
https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L24-L32
46,985
lakenen/wrap-range-text
index.js
rangeIntersectsNode
function rangeIntersectsNode(range, node) { if (range.intersectsNode) { return range.intersectsNode(node) } else { return rangesIntersect(range, createRangeFromNode(node)) } }
javascript
function rangeIntersectsNode(range, node) { if (range.intersectsNode) { return range.intersectsNode(node) } else { return rangesIntersect(range, createRangeFromNode(node)) } }
[ "function", "rangeIntersectsNode", "(", "range", ",", "node", ")", "{", "if", "(", "range", ".", "intersectsNode", ")", "{", "return", "range", ".", "intersectsNode", "(", "node", ")", "}", "else", "{", "return", "rangesIntersect", "(", "range", ",", "crea...
return true if `node` is fully or partially selected by `range`
[ "return", "true", "if", "node", "is", "fully", "or", "partially", "selected", "by", "range" ]
b71282c935ba2412e1662b7e77f8b954e3033196
https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L35-L41
46,986
lakenen/wrap-range-text
index.js
getRangeTextNodes
function getRangeTextNodes(range) { var container = range.commonAncestorContainer , nodes = getTextNodes(container.parentNode || container) return nodes.filter(function (node) { return rangeIntersectsNode(range, node) && isNonEmptyTextNode(node) }) }
javascript
function getRangeTextNodes(range) { var container = range.commonAncestorContainer , nodes = getTextNodes(container.parentNode || container) return nodes.filter(function (node) { return rangeIntersectsNode(range, node) && isNonEmptyTextNode(node) }) }
[ "function", "getRangeTextNodes", "(", "range", ")", "{", "var", "container", "=", "range", ".", "commonAncestorContainer", ",", "nodes", "=", "getTextNodes", "(", "container", ".", "parentNode", "||", "container", ")", "return", "nodes", ".", "filter", "(", "f...
return all non-empty text nodes fully or partially selected by `range`
[ "return", "all", "non", "-", "empty", "text", "nodes", "fully", "or", "partially", "selected", "by", "range" ]
b71282c935ba2412e1662b7e77f8b954e3033196
https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L44-L51
46,987
lakenen/wrap-range-text
index.js
replaceNode
function replaceNode(replacementNode, node) { remove(replacementNode) node.parentNode.insertBefore(replacementNode, node) remove(node) }
javascript
function replaceNode(replacementNode, node) { remove(replacementNode) node.parentNode.insertBefore(replacementNode, node) remove(node) }
[ "function", "replaceNode", "(", "replacementNode", ",", "node", ")", "{", "remove", "(", "replacementNode", ")", "node", ".", "parentNode", ".", "insertBefore", "(", "replacementNode", ",", "node", ")", "remove", "(", "node", ")", "}" ]
replace `node` with `replacementNode`
[ "replace", "node", "with", "replacementNode" ]
b71282c935ba2412e1662b7e77f8b954e3033196
https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L66-L70
46,988
lakenen/wrap-range-text
index.js
unwrap
function unwrap(el) { var range = document.createRange() range.selectNodeContents(el) replaceNode(range.extractContents(), el) }
javascript
function unwrap(el) { var range = document.createRange() range.selectNodeContents(el) replaceNode(range.extractContents(), el) }
[ "function", "unwrap", "(", "el", ")", "{", "var", "range", "=", "document", ".", "createRange", "(", ")", "range", ".", "selectNodeContents", "(", "el", ")", "replaceNode", "(", "range", ".", "extractContents", "(", ")", ",", "el", ")", "}" ]
unwrap `el` by replacing itself with its contents
[ "unwrap", "el", "by", "replacing", "itself", "with", "its", "contents" ]
b71282c935ba2412e1662b7e77f8b954e3033196
https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L73-L77
46,989
lakenen/wrap-range-text
index.js
undo
function undo(nodes) { nodes.forEach(function (node) { var parent = node.parentNode unwrap(node) parent.normalize() }) }
javascript
function undo(nodes) { nodes.forEach(function (node) { var parent = node.parentNode unwrap(node) parent.normalize() }) }
[ "function", "undo", "(", "nodes", ")", "{", "nodes", ".", "forEach", "(", "function", "(", "node", ")", "{", "var", "parent", "=", "node", ".", "parentNode", "unwrap", "(", "node", ")", "parent", ".", "normalize", "(", ")", "}", ")", "}" ]
undo the effect of `wrapRangeText`, given a resulting array of wrapper `nodes`
[ "undo", "the", "effect", "of", "wrapRangeText", "given", "a", "resulting", "array", "of", "wrapper", "nodes" ]
b71282c935ba2412e1662b7e77f8b954e3033196
https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L80-L86
46,990
lakenen/wrap-range-text
index.js
createWrapperFunction
function createWrapperFunction(wrapperEl, range) { var startNode = range.startContainer , endNode = range.endContainer , startOffset = range.startOffset , endOffset = range.endOffset return function wrapNode(node) { var currentRange = document.createRange() , currentWrapper = wrapperEl.cloneNode() currentRange.selectNodeContents(node) if (node === startNode && startNode.nodeType === 3) { currentRange.setStart(node, startOffset) startNode = currentWrapper startOffset = 0 } if (node === endNode && endNode.nodeType === 3) { currentRange.setEnd(node, endOffset) endNode = currentWrapper endOffset = 1 } currentRange.surroundContents(currentWrapper) return currentWrapper } }
javascript
function createWrapperFunction(wrapperEl, range) { var startNode = range.startContainer , endNode = range.endContainer , startOffset = range.startOffset , endOffset = range.endOffset return function wrapNode(node) { var currentRange = document.createRange() , currentWrapper = wrapperEl.cloneNode() currentRange.selectNodeContents(node) if (node === startNode && startNode.nodeType === 3) { currentRange.setStart(node, startOffset) startNode = currentWrapper startOffset = 0 } if (node === endNode && endNode.nodeType === 3) { currentRange.setEnd(node, endOffset) endNode = currentWrapper endOffset = 1 } currentRange.surroundContents(currentWrapper) return currentWrapper } }
[ "function", "createWrapperFunction", "(", "wrapperEl", ",", "range", ")", "{", "var", "startNode", "=", "range", ".", "startContainer", ",", "endNode", "=", "range", ".", "endContainer", ",", "startOffset", "=", "range", ".", "startOffset", ",", "endOffset", "...
create a node wrapper function
[ "create", "a", "node", "wrapper", "function" ]
b71282c935ba2412e1662b7e77f8b954e3033196
https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L89-L115
46,991
constgen/cross-channel
src/types/message.js
Message
function Message(data, source){ source = source || {} this.data = data this.key = source.key this.sourceChannel = source.name }
javascript
function Message(data, source){ source = source || {} this.data = data this.key = source.key this.sourceChannel = source.name }
[ "function", "Message", "(", "data", ",", "source", ")", "{", "source", "=", "source", "||", "{", "}", "this", ".", "data", "=", "data", "this", ".", "key", "=", "source", ".", "key", "this", ".", "sourceChannel", "=", "source", ".", "name", "}" ]
Message entity constructor @param {*} data - any data to be transfered @param {Object} [source] - source sent from
[ "Message", "entity", "constructor" ]
0dc0f57827aca6496721d6e20bd1b9d87e9c8fbe
https://github.com/constgen/cross-channel/blob/0dc0f57827aca6496721d6e20bd1b9d87e9c8fbe/src/types/message.js#L10-L15
46,992
PersonifyJS/personify.js
util/watson.js
function(options, content, res) { return function (/*function*/ callback) { // create the post data to send to the User Modeling service var post_data = { 'contentItems' : [{ 'userid' : 'dummy', 'id' : 'dummyUuid', 'sourceid' : 'freetext', 'contenttype' : 'text/plain', 'language' : 'en', 'content': content }] }; // Create a request to POST to the User Modeling service var profile_req = https.request(options, function(result) { result.setEncoding('utf-8'); var response_string = ''; result.on('data', function(chunk) { response_string += chunk; }); result.on('end', function() { if (result.statusCode != 200) { var error = JSON.parse(response_string); // render error if the results are less than 100 words callback({'message': error.user_message}, null); } else callback(null,response_string); }); }); profile_req.on('error', function(e) { callback(e,null); }); profile_req.write(JSON.stringify(post_data)); profile_req.end(); } }
javascript
function(options, content, res) { return function (/*function*/ callback) { // create the post data to send to the User Modeling service var post_data = { 'contentItems' : [{ 'userid' : 'dummy', 'id' : 'dummyUuid', 'sourceid' : 'freetext', 'contenttype' : 'text/plain', 'language' : 'en', 'content': content }] }; // Create a request to POST to the User Modeling service var profile_req = https.request(options, function(result) { result.setEncoding('utf-8'); var response_string = ''; result.on('data', function(chunk) { response_string += chunk; }); result.on('end', function() { if (result.statusCode != 200) { var error = JSON.parse(response_string); // render error if the results are less than 100 words callback({'message': error.user_message}, null); } else callback(null,response_string); }); }); profile_req.on('error', function(e) { callback(e,null); }); profile_req.write(JSON.stringify(post_data)); profile_req.end(); } }
[ "function", "(", "options", ",", "content", ",", "res", ")", "{", "return", "function", "(", "/*function*/", "callback", ")", "{", "// create the post data to send to the User Modeling service", "var", "post_data", "=", "{", "'contentItems'", ":", "[", "{", "'userid...
creates a request function using the https options and the text in content the function that return receives a callback
[ "creates", "a", "request", "function", "using", "the", "https", "options", "and", "the", "text", "in", "content", "the", "function", "that", "return", "receives", "a", "callback" ]
2308690d7567fe1f22796e91956f74e729e95670
https://github.com/PersonifyJS/personify.js/blob/2308690d7567fe1f22796e91956f74e729e95670/util/watson.js#L74-L113
46,993
waigo/waigo
src/config/index.js
function(name) { try { debug(`Loading ${name} configuration`); return waigo.load(`config/${name}`); } catch (e) { debug(`Error loading config: ${name}`); debug(e); return null; } }
javascript
function(name) { try { debug(`Loading ${name} configuration`); return waigo.load(`config/${name}`); } catch (e) { debug(`Error loading config: ${name}`); debug(e); return null; } }
[ "function", "(", "name", ")", "{", "try", "{", "debug", "(", "`", "${", "name", "}", "`", ")", ";", "return", "waigo", ".", "load", "(", "`", "${", "name", "}", "`", ")", ";", "}", "catch", "(", "e", ")", "{", "debug", "(", "`", "${", "name...
Load config module. @param {String} name Config module name. @return {Function} `null` if module not found.
[ "Load", "config", "module", "." ]
b2f50cd66b8b19016e2c7de75733330c791c76ff
https://github.com/waigo/waigo/blob/b2f50cd66b8b19016e2c7de75733330c791c76ff/src/config/index.js#L16-L27
46,994
mkay581/build-tools
src/browserify.js
function (destPath, srcPaths, options) { let stream, b, finalPaths = []; return new Promise(function (resolve, reject) { _.each(srcPaths, function (path) { // deal with file globs if (glob.hasMagic(path)) { glob.sync(path).forEach((p) => { p = utils.scopePaths(p); finalPaths.push(p); }); } else { path = utils.scopePaths(path); finalPaths.push(path); } }); // add required parameters for watchify options.cache = {}; options.packageCache = {}; options.debug = options.watch; b = browserify(options); b.transform(envify({ _: 'purge', NODE_ENV: options.env }), {global: true}); // must add each path individual unfortunately. finalPaths.forEach(function (path) { b.add(path); }); options.ignore.forEach((file) => { b.ignore(file); }); options.exclude.forEach((file) => { b.exclude(file); }); // require global files _.each(options.requires, function (path, id) { // options.requires can be an array of strings or an object id = typeof id == "string" ? id : path; b.require(path, {expose: id}); }); if (options.watch) { b.plugin(watchify); // re-bundle when updated b.on('update', function () { console.log('file updated!'); b.bundle(); }); } b.on('bundle', function (stream) { console.log('browserifying bundle...'); writeBrowserifyBundleStreamToFile(stream, destPath) .then(function () { console.log('done browserifying bundle!'); resolve(); }) .catch(function (e) { console.log('browserifying failed'); console.log(e); reject(e); }); }); stream = b.bundle(); }.bind(this)); }
javascript
function (destPath, srcPaths, options) { let stream, b, finalPaths = []; return new Promise(function (resolve, reject) { _.each(srcPaths, function (path) { // deal with file globs if (glob.hasMagic(path)) { glob.sync(path).forEach((p) => { p = utils.scopePaths(p); finalPaths.push(p); }); } else { path = utils.scopePaths(path); finalPaths.push(path); } }); // add required parameters for watchify options.cache = {}; options.packageCache = {}; options.debug = options.watch; b = browserify(options); b.transform(envify({ _: 'purge', NODE_ENV: options.env }), {global: true}); // must add each path individual unfortunately. finalPaths.forEach(function (path) { b.add(path); }); options.ignore.forEach((file) => { b.ignore(file); }); options.exclude.forEach((file) => { b.exclude(file); }); // require global files _.each(options.requires, function (path, id) { // options.requires can be an array of strings or an object id = typeof id == "string" ? id : path; b.require(path, {expose: id}); }); if (options.watch) { b.plugin(watchify); // re-bundle when updated b.on('update', function () { console.log('file updated!'); b.bundle(); }); } b.on('bundle', function (stream) { console.log('browserifying bundle...'); writeBrowserifyBundleStreamToFile(stream, destPath) .then(function () { console.log('done browserifying bundle!'); resolve(); }) .catch(function (e) { console.log('browserifying failed'); console.log(e); reject(e); }); }); stream = b.bundle(); }.bind(this)); }
[ "function", "(", "destPath", ",", "srcPaths", ",", "options", ")", "{", "let", "stream", ",", "b", ",", "finalPaths", "=", "[", "]", ";", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "_", ".", "each", "(", "...
Browserifies a single file bundle. @param destPath @param srcPaths @param options @param {Object|Array} [options.requires] - Required files @returns {Promise}
[ "Browserifies", "a", "single", "file", "bundle", "." ]
005cb840b5db017a33597a8d44d941d156a7a000
https://github.com/mkay581/build-tools/blob/005cb840b5db017a33597a8d44d941d156a7a000/src/browserify.js#L18-L95
46,995
mkay581/build-tools
src/browserify.js
function (stream, destPath) { let data = ''; return new Promise(function (resolve, reject) { stream.on('error', reject); stream.on('data', function (d) { data += d.toString(); }); stream.on('end', function () { fs.outputFile(destPath, data, function (err) { if (!err) { resolve(); } else { reject(err); } }); }); }); }
javascript
function (stream, destPath) { let data = ''; return new Promise(function (resolve, reject) { stream.on('error', reject); stream.on('data', function (d) { data += d.toString(); }); stream.on('end', function () { fs.outputFile(destPath, data, function (err) { if (!err) { resolve(); } else { reject(err); } }); }); }); }
[ "function", "(", "stream", ",", "destPath", ")", "{", "let", "data", "=", "''", ";", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "stream", ".", "on", "(", "'error'", ",", "reject", ")", ";", "stream", ".", ...
Handles writing the browserify bundle stream to the destination file. @param {EventEmitter} stream - The bundle stream @param {string} destPath - The destination file @private
[ "Handles", "writing", "the", "browserify", "bundle", "stream", "to", "the", "destination", "file", "." ]
005cb840b5db017a33597a8d44d941d156a7a000
https://github.com/mkay581/build-tools/blob/005cb840b5db017a33597a8d44d941d156a7a000/src/browserify.js#L103-L120
46,996
iraycd/brickwork
brickwork.js
fillMatrix
function fillMatrix(id, t, l, w, h) { for (var y = t; y < t + h;) { for (var x = l; x < l + w;) { matrix[y + '-' + x] = id; ++x > maxX && (maxX = x); } ++y > maxY && (maxY = y); } }
javascript
function fillMatrix(id, t, l, w, h) { for (var y = t; y < t + h;) { for (var x = l; x < l + w;) { matrix[y + '-' + x] = id; ++x > maxX && (maxX = x); } ++y > maxY && (maxY = y); } }
[ "function", "fillMatrix", "(", "id", ",", "t", ",", "l", ",", "w", ",", "h", ")", "{", "for", "(", "var", "y", "=", "t", ";", "y", "<", "t", "+", "h", ";", ")", "{", "for", "(", "var", "x", "=", "l", ";", "x", "<", "l", "+", "w", ";",...
fill area with top, left, width, height;
[ "fill", "area", "with", "top", "left", "width", "height", ";" ]
d6805e7601b7ee43760aa37e68a127b1723fadfa
https://github.com/iraycd/brickwork/blob/d6805e7601b7ee43760aa37e68a127b1723fadfa/brickwork.js#L569-L577
46,997
kogarashisan/LiquidLava
dependencies/jison/lib/jison/json2jison.js
json2jison
function json2jison (grammar, options) { options = options || {}; var s = ""; s += genDecls(grammar, options); s += genBNF(grammar.bnf, options); return s; }
javascript
function json2jison (grammar, options) { options = options || {}; var s = ""; s += genDecls(grammar, options); s += genBNF(grammar.bnf, options); return s; }
[ "function", "json2jison", "(", "grammar", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "var", "s", "=", "\"\"", ";", "s", "+=", "genDecls", "(", "grammar", ",", "options", ")", ";", "s", "+=", "genBNF", "(", "grammar", ...
converts json grammar format to Jison grammar format
[ "converts", "json", "grammar", "format", "to", "Jison", "grammar", "format" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/dependencies/jison/lib/jison/json2jison.js#L3-L11
46,998
kogarashisan/LiquidLava
dependencies/jison/lib/jison/json2jison.js
genLex
function genLex (lex) { var s = []; if (lex.macros) { for (var macro in lex.macros) if (lex.macros.hasOwnProperty(macro)) { s.push(macro, ' ', lex.macros[macro], '\n'); } } if (lex.actionInclude) { s.push('\n%{\n', lex.actionInclude, '\n%}\n'); } s.push('\n%%\n'); if (lex.rules) { for (var rule;rule=lex.rules.shift();) { s.push(genLexRegex(rule[0]), ' ', genLexRule(rule[1]), '\n'); } } s.push('\n'); return s.join(''); }
javascript
function genLex (lex) { var s = []; if (lex.macros) { for (var macro in lex.macros) if (lex.macros.hasOwnProperty(macro)) { s.push(macro, ' ', lex.macros[macro], '\n'); } } if (lex.actionInclude) { s.push('\n%{\n', lex.actionInclude, '\n%}\n'); } s.push('\n%%\n'); if (lex.rules) { for (var rule;rule=lex.rules.shift();) { s.push(genLexRegex(rule[0]), ' ', genLexRule(rule[1]), '\n'); } } s.push('\n'); return s.join(''); }
[ "function", "genLex", "(", "lex", ")", "{", "var", "s", "=", "[", "]", ";", "if", "(", "lex", ".", "macros", ")", "{", "for", "(", "var", "macro", "in", "lex", ".", "macros", ")", "if", "(", "lex", ".", "macros", ".", "hasOwnProperty", "(", "ma...
Generate lex format from lex JSON
[ "Generate", "lex", "format", "from", "lex", "JSON" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/dependencies/jison/lib/jison/json2jison.js#L102-L122
46,999
tunnckoCore/fs-readdir
index.js
fsReaddirSync
function fsReaddirSync(root, files, fp) { if (typeof root !== 'string') { throw new TypeError('fsReaddir.sync: expect `root` to be string'); } fp = fp || ''; files = files || []; var dir = path.join(root, fp); if (fs.statSync(dir).isDirectory()) { fs.readdirSync(dir).forEach(function(name) { fsReaddirSync(root, files, path.join(dir, name)); }); } else { files.push(fp); } return files; }
javascript
function fsReaddirSync(root, files, fp) { if (typeof root !== 'string') { throw new TypeError('fsReaddir.sync: expect `root` to be string'); } fp = fp || ''; files = files || []; var dir = path.join(root, fp); if (fs.statSync(dir).isDirectory()) { fs.readdirSync(dir).forEach(function(name) { fsReaddirSync(root, files, path.join(dir, name)); }); } else { files.push(fp); } return files; }
[ "function", "fsReaddirSync", "(", "root", ",", "files", ",", "fp", ")", "{", "if", "(", "typeof", "root", "!==", "'string'", ")", "{", "throw", "new", "TypeError", "(", "'fsReaddir.sync: expect `root` to be string'", ")", ";", "}", "fp", "=", "fp", "||", "...
`fs-readdir-recursive` without filter feature @param {String} `root` @param {Array} `files` @param {String} `fp` @return {Array}
[ "fs", "-", "readdir", "-", "recursive", "without", "filter", "feature" ]
f864015898e3f0215f25eeac75d8315bcd55639a
https://github.com/tunnckoCore/fs-readdir/blob/f864015898e3f0215f25eeac75d8315bcd55639a/index.js#L132-L150