_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q34500
train
function(classes_string) { var classes = []; if (Lava.schema.view.VALIDATE_CLASS_NAMES) { this.assertClassStringValid(classes_string); } if (classes_string != '') { classes = classes_string.split(/\s+/); } return classes; }
javascript
{ "resource": "" }
q34501
train
function(argument, event_args, listener_args) { var new_classes = this._toClassNames(argument.getValue().toString().trim()); if (this._is_inDOM) { Firestorm.Element.removeClasses(this.getDOMElement(), this._class_bindings_values[listener_args.name]); Firestorm.Element.addClasses(this.getDOMElement(), new_c...
javascript
{ "resource": "" }
q34502
train
function() { var resultClasses = this._static_classes.clone(), name, value; for (name in this._class_bindings) { // do not need to check or convert, cause join() will convert everything to string, and nulls to empty string resultClasses.push( this._class_bindings[name].getValue() ); } va...
javascript
{ "resource": "" }
q34503
train
function() { var result_styles = [], name, value; for (name in this._static_styles) { result_styles.push(name + ':' + this._static_styles[name]); } for (name in this._style_bindings) { value = this._style_bindings[name].getValue(); if (value != null) { result_styles.push(name + ':' + va...
javascript
{ "resource": "" }
q34504
train
function(name, value) { var result = ''; if (value === true) { result = ' ' + name + '="' + name + '"'; } else if (value != null && value !== false) { result = ' ' + name + '="' + this.escapeAttributeValue(value + '') + '"'; } return result; }
javascript
{ "resource": "" }
q34505
train
function() { var classes = this._renderClasses(), style = this._renderStyles(), properties_string = '', name; // see informInDOM_Normal // this._element = null; for (name in this._static_properties) { properties_string += this._renderAttribute(name, this._static_properties[name]); } for (n...
javascript
{ "resource": "" }
q34506
train
function(html) { if (Lava.schema.DEBUG && this._is_void) Lava.t('Trying to wrap content in void tag'); // _element is cleared in _renderOpeningTag return this._renderOpeningTag() + ">" + html + "</" + this._tag_name + ">"; }
javascript
{ "resource": "" }
q34507
train
function(html) { if (!this._is_inDOM) Lava.t("setHTML: element is not in DOM"); if (this._is_void) Lava.t('setHTML on void tag'); Firestorm.Element.setProperty(this.getDOMElement(), 'html', html); }
javascript
{ "resource": "" }
q34508
train
function(callback_name, callback_argument) { var name; for (name in this._property_bindings) this._property_bindings[name][callback_name](callback_argument); for (name in this._style_bindings) this._style_bindings[name][callback_name](callback_argument); for (name in this._class_bindings) this._class_bindin...
javascript
{ "resource": "" }
q34509
train
function(element) { var Element = Firestorm.Element, name; if (this._is_inDOM) Lava.t("Can not set duplicate id attribute on elements"); // there must not be ID attribute if (Element.getProperty(element, 'id')) Lava.t("Target element already has an ID, and could be owned by another container"); if (Eleme...
javascript
{ "resource": "" }
q34510
train
function() { var input_element = this.getDOMElement(); Firestorm.Element.removeListener(input_element, "onpropertychange", this._OldIE_property_change_callback); Firestorm.Element.removeListener(input_element, "selectionchange", this._OldIE_refresh_callback); Firestorm.Element.removeListener(input_element, "ke...
javascript
{ "resource": "" }
q34511
train
function(view, config, widget) { this._view = view; //this._config = config; this._widget = widget; this._start_script_id = 'c' + view.guid + 's'; this._end_script_id = 'c' + view.guid + 'e'; }
javascript
{ "resource": "" }
q34512
train
function() { var start_element = document.getElementById(this._start_script_id), end_element = document.getElementById(this._end_script_id); /** * In some cases, Internet Explorer can create an anonymous node in * the hierarchy with no tagName. You can create this scenario via: * * div = docume...
javascript
{ "resource": "" }
q34513
train
function(html) { if (!this._is_inDOM) Lava.t("setHTML: container is not in DOM"); Firestorm.DOM.clearInnerRange(this.getStartElement(), this.getEndElement()); Firestorm.DOM.insertHTMLBefore(this.getEndElement(), html); }
javascript
{ "resource": "" }
q34514
train
function(view, config, widget) { this._view = view; //this._config = config; this._widget = widget; if (('options' in config)) { if ('appender' in config.options) { if (Lava.schema.DEBUG && !this['_append' + config.options.appender]) Lava.t('[Emulated container] wrong appender: ' + config.options.appe...
javascript
{ "resource": "" }
q34515
train
function(config, view, container) { this._config = config; this._view = view; this._container = container; if (config.get_start_element_callback) { this._getStartElement = config.get_start_element_callback; } if (config.get_end_element_callback) { this._getEndElement = config.get_end_element_cal...
javascript
{ "resource": "" }
q34516
train
function(templates) { for (var i = 0, count = templates.length; i < count; i++) { this._remove_queue[templates[i].guid] = templates[i]; } }
javascript
{ "resource": "" }
q34517
train
function(current_templates) { var i = 1, count = current_templates.length, guid, previous_template = current_templates[0]; if (previous_template) { // if list is not empty delete this._remove_queue[previous_template.guid]; // handle first template separately from others if (!previous_template....
javascript
{ "resource": "" }
q34518
train
function(template) { this._view.getContainer().prependHTML(template.render()); template.broadcastInDOM(); this._current_templates.unshift(template); }
javascript
{ "resource": "" }
q34519
train
function(current_templates) { var i = 0, count = current_templates.length, guid; // from templates, which are prepared for removal, filter out those, which should be in DOM for (; i < count; i++) { delete this._remove_queue[current_templates[i].guid]; } for (guid in this._remove_queue) { if ...
javascript
{ "resource": "" }
q34520
train
function() { var buffer = '', i = 0, count = this._current_templates.length; for (; i < count; i++) { buffer += this._current_templates[i].render(); } return buffer; }
javascript
{ "resource": "" }
q34521
train
function(template, previous_template, index) { Firestorm.DOM.insertHTMLAfter(this._getEndElement(previous_template), template.render()); template.broadcastInDOM(); var previous_index = this._current_templates.indexOf(previous_template); if (Lava.schema.DEBUG && previous_index == -1) Lava.t(); this._current_...
javascript
{ "resource": "" }
q34522
train
function(template) { // save, cause we can not retrieve container's DOM elements after broadcastRemove var start_element = this._getStartElement(template), end_element = this._getEndElement(template); // first, we must inform the template, that it's going to be removed: to allow it's child views to interact ...
javascript
{ "resource": "" }
q34523
train
function(function_name) { for (var i = 0, count = this._current_templates.length; i < count; i++) { this._current_templates[i][function_name](); } }
javascript
{ "resource": "" }
q34524
train
function(template, previous_template, index, current_templates) { var animation = this._animations_by_template_guid[template.guid]; if (Lava.schema.DEBUG && animation && !template.isInDOM()) Lava.t(); if (template.isInDOM()) { // first template does not require moving previous_template && this._moveTemp...
javascript
{ "resource": "" }
q34525
train
function(template) { var animation = this._animations_by_template_guid[template.guid]; if (!animation && template.isInDOM()) { animation = this._createAnimation(template); } if (animation) { animation.reverseDirection(); animation.safeStart(); } }
javascript
{ "resource": "" }
q34526
train
function(animation) { var template = this._templates_by_animation_guid[animation.guid]; if (animation.isReversed()) { this._onRemovalComplete(animation, template); this._fire('removal_complete', template); } else { this._onInsertionComplete(animation, template); this._fire('insertion_complete', t...
javascript
{ "resource": "" }
q34527
train
function(config, widget, parent_view, template, properties) { var name, argument, constructor; this.guid = Lava.guid++; if (Lava.schema.DEBUG && config.id && !Lava.isValidId(config.id)) Lava.t(); if ('id' in config) { this.id = config.id; } if ('label' in config) { this.label = config.label; ...
javascript
{ "resource": "" }
q34528
train
function(depth) { var root = this; while (depth > 0) { root = root.getParentView(); if (!root) Lava.t("Error evaluating depth: parent view does not exist"); depth--; } return root; }
javascript
{ "resource": "" }
q34529
train
function() { if (this._is_inDOM) { if (this._container) { this._is_dirty = true; if (!this._is_queued_for_refresh) { Lava.view_manager.scheduleViewRefresh(this); this._is_queued_for_refresh = true; } } else if (this._parent_with_container) { this._parent_with_container.trySetDi...
javascript
{ "resource": "" }
q34530
train
function() { var buffer = this._renderContent(), result; if (this._container) { result = this._container.wrap(buffer); } else { result = buffer; } return result; }
javascript
{ "resource": "" }
q34531
train
function(id) { if (Lava.schema.DEBUG && !id) Lava.t(); return Lava.view_manager.getViewById(id); }
javascript
{ "resource": "" }
q34532
train
function(guid) { if (Lava.schema.DEBUG && !guid) Lava.t(); return Lava.view_manager.getViewByGuid(guid); }
javascript
{ "resource": "" }
q34533
train
function(path_config) { var result = this['locateViewBy' + path_config.locator_type](path_config.locator); if (Lava.schema.DEBUG && !result) Lava.t("View not found. " + path_config.locator_type + ':' + path_config.locator); if ('depth' in path_config) { result = result.getViewByDepth(path_config.depth); ...
javascript
{ "resource": "" }
q34534
train
function(name) { var view = this; while (view && !view.isset(name)) { view = view.getParentView(); } return view; }
javascript
{ "resource": "" }
q34535
train
function(path_config) { var view, i = 0, count, result, tail = path_config.tail; if ('property_name' in path_config) { view = ('locator_type' in path_config) ? this.locateViewByPathConfig(path_config) : this; view = view.locateViewWithProperty(path_config.property_name); if (Lava.schema.DE...
javascript
{ "resource": "" }
q34536
train
function(path_config) { var view, i = 0, count, result, tail = path_config.tail, property_name; if ('property_name' in path_config) { view = ('locator_type' in path_config) ? this.locateViewByPathConfig(path_config) : this; view = view.locateViewWithProperty(path_config.property_name); ...
javascript
{ "resource": "" }
q34537
train
function(property_name) { if (!(property_name in this._property_bindings_by_property)) { this._property_bindings_by_property[property_name] = new Lava.scope.PropertyBinding(this, property_name); } return this._property_bindings_by_property[property_name]; }
javascript
{ "resource": "" }
q34538
train
function() { var i = 0, removed_templates = []; for (; i < this._current_count; i++) { removed_templates.push(this._current_hash[this._current_uids[i]]); } removed_templates.length && this._removeTemplates(removed_templates); this._current_count = 0; this._current_hash = {}; this._current_uids...
javascript
{ "resource": "" }
q34539
train
function(removed_templates) { for (var i = 0, removed_count = removed_templates.length; i < removed_count; i++) { removed_templates[i].destroy(); } }
javascript
{ "resource": "" }
q34540
train
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...
javascript
{ "resource": "" }
q34541
train
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
{ "resource": "" }
q34542
train
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
{ "resource": "" }
q34543
train
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
{ "resource": "" }
q34544
train
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...
javascript
{ "resource": "" }
q34545
train
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.r...
javascript
{ "resource": "" }
q34546
train
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
{ "resource": "" }
q34547
train
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"); // Other...
javascript
{ "resource": "" }
q34548
train
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
{ "resource": "" }
q34549
train
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
{ "resource": "" }
q34550
train
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
{ "resource": "" }
q34551
Contour
train
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) { tim...
javascript
{ "resource": "" }
q34552
mutable
train
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
{ "resource": "" }
q34553
functionsCloneAdapter
train
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
{ "resource": "" }
q34554
update
train
function update() { el.style.transform = 'scale3d(' + s1(x) + ', ' + s2(y) + ', 1)'; requestAnimationFrame(update); }
javascript
{ "resource": "" }
q34555
functionsExtendAdapter
train
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
{ "resource": "" }
q34556
train
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
{ "resource": "" }
q34557
train
function(msg) { if (typeof(window) == 'undefined') throw new Error(msg); // Node environment if (window.console) { window.console.error(msg); } }
javascript
{ "resource": "" }
q34558
train
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
{ "resource": "" }
q34559
train
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[con...
javascript
{ "resource": "" }
q34560
train
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) { thi...
javascript
{ "resource": "" }
q34561
train
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_cl...
javascript
{ "resource": "" }
q34562
train
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_e...
javascript
{ "resource": "" }
q34563
train
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'} }; conf...
javascript
{ "resource": "" }
q34564
train
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); } }...
javascript
{ "resource": "" }
q34565
train
function () { this.popover_manager && this.popover_manager.destroy(); this.view_manager && this.view_manager.destroy(); this.app.destroy(); this.view_manager.destroy(); }
javascript
{ "resource": "" }
q34566
train
function(value) { var result = ''; if (value) { result = value.toString(); result = result[0].toUpperCase() + result.substr(1); } return result; }
javascript
{ "resource": "" }
q34567
train
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
{ "resource": "" }
q34568
train
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 (...
javascript
{ "resource": "" }
q34569
train
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[n...
javascript
{ "resource": "" }
q34570
train
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
{ "resource": "" }
q34571
train
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); } retu...
javascript
{ "resource": "" }
q34572
train
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++) { segm...
javascript
{ "resource": "" }
q34573
train
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
{ "resource": "" }
q34574
train
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
{ "resource": "" }
q34575
train
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.resourc...
javascript
{ "resource": "" }
q34576
train
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) == -...
javascript
{ "resource": "" }
q34577
train
function() { this._enable = (Firestorm.Environment.requestAnimationFrame && Lava.schema.system.ALLOW_REQUEST_ANIMATION_FRAME) ? this._enable_AnimationFrame : this._enable_Interval; }
javascript
{ "resource": "" }
q34578
train
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 th...
javascript
{ "resource": "" }
q34579
train
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 { Firesto...
javascript
{ "resource": "" }
q34580
train
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_...
javascript
{ "resource": "" }
q34581
train
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 lig...
javascript
{ "resource": "" }
q34582
train
function(refresh_ticket, level) { if (Lava.schema.DEBUG && refresh_ticket == null) Lava.t(); this._scope_refresh_queues[level][refresh_ticket.index] = null; }
javascript
{ "resource": "" }
q34583
train
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 ...
javascript
{ "resource": "" }
q34584
train
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[curre...
javascript
{ "resource": "" }
q34585
train
function(scope) { var index = this._debug_all_scopes.indexOf(scope); if (index == -1) Lava.t(); this._debug_all_scopes.splice(index, 1); }
javascript
{ "resource": "" }
q34586
train
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
{ "resource": "" }
q34587
train
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
{ "resource": "" }
q34588
mapPrototypes
train
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 pro...
javascript
{ "resource": "" }
q34589
extendPrototype
train
function extendPrototype(vendor, proto, func) { proto.prototype[func] = function() { var args = slice.call(arguments) || []; args.unshift(this); return vendor[func].apply(this, args); }; }
javascript
{ "resource": "" }
q34590
reduceObject
train
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
{ "resource": "" }
q34591
commonjsMain
train
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
{ "resource": "" }
q34592
prompt
train
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(...
javascript
{ "resource": "" }
q34593
train
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
{ "resource": "" }
q34594
utility
train
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
{ "resource": "" }
q34595
Repository
train
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...
javascript
{ "resource": "" }
q34596
matrixToOperations
train
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 ...
javascript
{ "resource": "" }
q34597
normalizeTolerance
train
function normalizeTolerance (t) { return t === Object(t) ? t : { down: t, up: t } }
javascript
{ "resource": "" }
q34598
sortByLabel
train
function sortByLabel(a, b) { if (a.sortval > b.sortval) return -1; else if (a.sortval == b.sortval) return 0; else return 1; }
javascript
{ "resource": "" }
q34599
train
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 ...
javascript
{ "resource": "" }