_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_classes);
}
this._class_bindings_values[listener_args.name] = new_classes;
} | 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()
);
}
value = resultClasses.join(' ');
if (Lava.schema.view.VALIDATE_CLASS_NAMES) {
this.assertClassStringValid(value);
}
return value;
} | 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 + ':' + value.toString().trim());
}
}
value = result_styles.join(';');
if (Lava.schema.view.VALIDATE_STYLES) {
this.assertStyleValid(value);
}
return value;
} | 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 (name in this._property_bindings) {
properties_string += this._renderAttribute(name, this._property_bindings[name].getValue());
}
if (classes) {
properties_string += ' class="' + classes + '"';
}
if (style) {
properties_string += ' style="' + style + '"';
}
return "<" + this._tag_name + " id=\"" + this._id + "\" "
// + this._writeEvents()
+ properties_string; //+ ">"
} | 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_bindings[name][callback_name](callback_argument);
} | 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 (Element.getProperty(element, 'tag').toLowerCase() != this._tag_name) Lava.t("Captured tag name differs from the container's tag name");
Element.setProperty(element, 'id', this._id);
this._is_inDOM = true;
this._element = element;
for (name in this._static_properties) {
// note: escaping must be handled by framework
Element.setProperty(element, name, this._static_properties[name]);
}
for (name in this._property_bindings) {
Element.setProperty(element, name, this._property_bindings[name].getValue());
}
this.syncClasses();
this.syncStyles();
this._is_element_owner = false;
} | 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, "keyup", this._OldIE_refresh_callback);
Firestorm.Element.removeListener(input_element, "keydown", this._OldIE_refresh_callback);
this.Element$informRemove();
} | 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 = document.createElement("div");
* div.innerHTML = "<table>­<script></script><tr><td>hi</td></tr></table>";
* div.firstChild.firstChild.tagName //=> ""
*
* If our script markers are inside such a node, we need to find that
* node and use *it* as the marker.
**/
while (start_element.parentNode.tagName === "") {
start_element = start_element.parentNode;
}
/**
* When automatically adding a tbody, Internet Explorer inserts the
* tbody immediately before the first <tr>. Other browsers create it
* before the first node, no matter what.
*
* This means the the following code:
*
* div = document.createElement("div");
* div.innerHTML = "<table><script id='first'></script><tr><td>hi</td></tr><script id='last'></script></table>
*
* Generates the following DOM in IE:
*
* + div
* + table
* - script id='first'
* + tbody
* + tr
* + td
* - "hi"
* - script id='last'
*
* Which means that the two script tags, even though they were
* inserted at the same point in the hierarchy in the original
* HTML, now have different parents.
*
* This code reparents the first script tag by making it the tbody's
* first child.
**/
if (start_element.parentNode !== end_element.parentNode) {
end_element.parentNode.insertBefore(start_element, end_element.parentNode.firstChild);
}
this._start_element = start_element;
this._end_element = end_element;
} | 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.appender);
this.appendHTML = this['_append' + config.options.appender]
}
if ('prepender' in config.options) {
if (Lava.schema.DEBUG && !this['_append' + config.options.prepender]) Lava.t('[Emulated container] wrong prepender: ' + config.options.prepender);
this.prependHTML = this['_append' + config.options.prepender]
}
}
} | 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_callback;
}
} | 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.isInDOM()) {
this._insertFirstTemplate(previous_template);
this._fire('insertion_complete', previous_template);
}
for (; i < count; i++) {
delete this._remove_queue[current_templates[i].guid];
if (current_templates[i].isInDOM()) {
this._moveTemplate(current_templates[i], previous_template, current_templates);
} else {
this._insertTemplate(current_templates[i], previous_template, i);
this._fire('insertion_complete', current_templates[i]);
}
previous_template = current_templates[i];
}
}
for (guid in this._remove_queue) {
if (this._remove_queue[guid].isInDOM()) {
this._removeTemplate(this._remove_queue[guid]);
this._fire('removal_complete', this._remove_queue[guid]);
}
}
this._remove_queue = {};
} | 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 (this._remove_queue[guid].isInDOM()) {
this._remove_queue[guid].broadcastRemove();
this._fire('removal_complete', this._remove_queue[guid]);
}
}
this._current_templates = current_templates;
this._remove_queue = {};
return this._render();
} | 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_templates.splice(previous_index + 1, 0, template);
} | 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
// with nodes while they are still in DOM
template.broadcastRemove();
if (start_element == end_element) {
Firestorm.Element.destroy(start_element);
} else {
// remove everything between tags and tags themselves
Firestorm.DOM.clearOuterRange(start_element, end_element);
}
Firestorm.Array.exclude(this._current_templates, template);
} | 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._moveTemplate(template, previous_template, current_templates);
} else {
if (previous_template) {
this._insertTemplate(template, previous_template, index);
} else {
this._insertFirstTemplate(template);
}
animation = this._createAnimation(template, index);
}
if (animation) {
animation.resetDirection();
animation.safeStart();
}
} | 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', template);
}
delete this._templates_by_animation_guid[animation.guid];
delete this._animations_by_template_guid[template.guid];
} | 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;
}
Lava.view_manager.registerView(this);
this._config = config;
this._widget = widget;
this._template = template;
if (parent_view) {
this._parent_view = parent_view;
this._parent_with_container = parent_view.getContainer() ? parent_view : parent_view.getParentWithContainer();
this.depth = parent_view.depth + 1;
}
this._initMembers(properties);
for (name in config.assigns) {
if (config.assigns[name].once) {
argument = new Lava.scope.Argument(config.assigns[name], this, this._widget);
this.set(name, argument.getValue());
argument.destroy();
} else {
if (name in this._property_bindings_by_property) Lava.t("Error initializing assign: property binding already created");
this._property_bindings_by_property[name] = new Lava.scope.PropertyBinding(this, name, config.assigns[name]);
}
}
if ('container' in config) {
constructor = Lava.ClassManager.getConstructor(config.container['type'], 'Lava.view.container');
this._container = new constructor(this, config.container, widget);
}
this._postInit();
if ('roles' in config) Lava.view_manager.dispatchRoles(this, config.roles);
} | 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.trySetDirty();
}
}
} | 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);
}
return result;
} | 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.DEBUG && !view) Lava.t("Property not found: " + path_config.property_name);
result = view.getDataBinding(path_config.property_name);
} else {
if (Lava.schema.DEBUG && !('locator_type' in path_config)) Lava.t("Malformed scope path (1)");
if (Lava.schema.DEBUG && !tail) Lava.t("Malformed scope path (2)");
result = this.locateViewByPathConfig(path_config);
if (Lava.schema.DEBUG && !result) Lava.t("View not found. "
+ path_config.locator_type + ": " + path_config.locator + ", depth:" + path_config.depth);
}
if (tail) {
for (count = tail.length; i < count; i++) {
result = (typeof(tail[i]) == 'object')
? result.getSegment(this.getScopeByPathConfig(tail[i]))
: result.getDataBinding(tail[i]);
}
}
return result;
} | 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);
result = view.get(path_config.property_name);
} else {
if (Lava.schema.DEBUG && !('locator_type' in path_config)) Lava.t("Malformed scope path (1)");
if (Lava.schema.DEBUG && !tail) Lava.t("Malformed scope path (2)");
result = this.locateViewByPathConfig(path_config);
if (Lava.schema.DEBUG && !result) Lava.t("View not found. "
+ path_config.locator_type + ": " + path_config.locator + ", depth:" + path_config.depth);
}
if (tail) {
for (count = tail.length; i < count; i++) {
property_name = (typeof(tail[i]) == 'object') ? this.evalPathConfig(tail[i]) : tail[i];
if (result.isCollection && /^\d+$/.test(property_name)) {
result = result.getValueAt(+property_name);
} else if (result.isProperties) {
result = result.get(property_name);
} else {
result = result[property_name];
}
if (!result) {
break;
}
}
}
return result;
} | 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 = [];
this._current_templates = [];
this._setCount(0);
} | 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._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 | {
"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("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 | {
"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.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 | {
"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");
// 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 | {
"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) {
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 | {
"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[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 | {
"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) {
this.sugar_map[widget_config.sugar.tag_name] = {widget_title: widget_title};
}
} | 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_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 | {
"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_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 | {
"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'}
};
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 | {
"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);
}
}
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 | {
"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 (!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 | {
"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[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 | {
"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);
}
return result;
} | 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++) {
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 | {
"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.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 | {
"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) == -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 | {
"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 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 | {
"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 {
Firestorm.Element.addListener(window, event_name, this._event_listeners[event_name]);
}
} | 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_name]);
}
} | 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 light as possible
return {
index: this._scope_refresh_queues[level].push(target) - 1
}
} | 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 = 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 | {
"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[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 | {
"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 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 | {
"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(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 | {
"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._remove = null;
this._fetch = null;
this._update = null;
this._transforms = [];
} | 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 = 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 | {
"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 = 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 | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.