_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q27600
serializeUserData
train
function serializeUserData(object) { try { return JSON.parse(JSON.stringify(object.userData)); } catch (error) { console.warn( "THREE.GLTFExporter: userData of '" + object.name + "' " + "won't be serialized because of JSON.stringify error - " + ...
javascript
{ "resource": "" }
q27601
processBuffer
train
function processBuffer(buffer) { if (!outputJSON.buffers) { outputJSON.buffers = [{ byteLength: 0 }]; } // All buffers are merged before export. buffers.push(buffer); return 0; }
javascript
{ "resource": "" }
q27602
processBufferView
train
function processBufferView(attribute, componentType, start, count, target) { if (!outputJSON.bufferViews) { outputJSON.bufferViews = []; } // Create a new dataview and dump the attribute's array into it var componentSize; if (componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE) { ...
javascript
{ "resource": "" }
q27603
processBufferViewImage
train
function processBufferViewImage(blob) { if (!outputJSON.bufferViews) { outputJSON.bufferViews = []; } return new Promise(function(resolve) { var reader = new window.FileReader(); reader.readAsArrayBuffer(blob); reader.onloadend = function() { var buffer = get...
javascript
{ "resource": "" }
q27604
processAccessor
train
function processAccessor(attribute, geometry, start, count) { var types = { 1: 'SCALAR', 2: 'VEC2', 3: 'VEC3', 4: 'VEC4', 16: 'MAT4' }; var componentType; // Detect the component type of the attribute array (float, uint or ushort) if (attribute.arr...
javascript
{ "resource": "" }
q27605
processAnimation
train
function processAnimation(clip, root) { if (!outputJSON.animations) { outputJSON.animations = []; } var channels = []; var samplers = []; for (var i = 0; i < clip.tracks.length; ++i) { var track = clip.tracks[i]; var trackBinding = THREE.PropertyBinding.parseTrack...
javascript
{ "resource": "" }
q27606
processNode
train
function processNode(object) { if (object.isLight) { console.warn( 'GLTFExporter: Unsupported node type:', object.constructor.name ); return null; } if (!outputJSON.nodes) { outputJSON.nodes = []; } var gltfNode = {}; if (options...
javascript
{ "resource": "" }
q27607
processObjects
train
function processObjects(objects) { var scene = new THREE.Scene(); scene.name = 'AuxScene'; for (var i = 0; i < objects.length; i++) { // We push directly to children instead of calling `add` to prevent // modify the .parent and break its original scene and hierarchy scene.chil...
javascript
{ "resource": "" }
q27608
train
function () { let scope = context.getScope(); while (scope) { const node = scope.block && scope.block.parent && scope.block.parent.parent; if (node && utils.isES5Component(node)) { return node; } scope = scope.upper; } return null; }
javascript
{ "resource": "" }
q27609
train
function () { let scope = context.getScope(); while (scope && scope.type !== 'class') { scope = scope.upper; } const node = scope && scope.block; if (!node || !utils.isES6Component(node)) { return null; } return node; }
javascript
{ "resource": "" }
q27610
markVariableAsUsed
train
function markVariableAsUsed(context, name) { let scope = context.getScope(); let variables; let i; let len; let found = false; // Special Node.js scope means we need to start one level deeper if (scope.type === 'global') { while (scope.childScopes.length) { scope = scope.childScopes[0]; } ...
javascript
{ "resource": "" }
q27611
findVariable
train
function findVariable(variables, name) { let i; let len; for (i = 0, len = variables.length; i < len; i++) { // eslint-disable-line no-plusplus if (variables[i].name === name) { return true; } } return false; }
javascript
{ "resource": "" }
q27612
variablesInScope
train
function variablesInScope(context) { let scope = context.getScope(); let variables = scope.variables; while (scope.type !== 'global') { scope = scope.upper; variables = scope.variables.concat(variables); } if (scope.childScopes.length) { variables = scope.childScopes[0].variables.concat(variables...
javascript
{ "resource": "" }
q27613
getClosestPackage
train
function getClosestPackage(modulePath) { let root; let pkg; // Catch findRoot or require errors try { root = findRoot(modulePath); pkg = require(path.join(root, "package.json")); } catch (e) { return null; } // If the package.json does not have a name property, try again from // one level ...
javascript
{ "resource": "" }
q27614
Row
train
function Row(props) { const { rowClass, columns, widgets, onRemove, layout, rowIndex, editable, frameComponent, editableColumnClass, droppableColumnClass, addWidgetComponentText, addWidgetComponent, onAdd, onMove, onEdit, } = props; const items = column...
javascript
{ "resource": "" }
q27615
waitOn
train
function waitOn(opts, cb) { if (cb !== undefined) { return waitOnImpl(opts, cb); } else { return new Promise(function (resolve, reject) { waitOnImpl(opts, function(err) { if (err) { reject(err); } else { resolve(); } }) }); } }
javascript
{ "resource": "" }
q27616
GenerateDefaultValues
train
function GenerateDefaultValues(neode, model, properties) { const output = GenerateDefaultValuesAsync(neode, model, properties); return Promise.resolve(output); }
javascript
{ "resource": "" }
q27617
splitProperties
train
function splitProperties(mode, model, properties) { var merge_on = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; var inline = {}; var set = {}; var on_create = {}; var on_match = {}; // Calculate Set Properties model.properties().forEach(function (property) { ...
javascript
{ "resource": "" }
q27618
addRelationshipToStatement
train
function addRelationshipToStatement(neode, builder, alias, rel_alias, target_alias, relationship, value, aliases, mode) { if (aliases.length > MAX_CREATE_DEPTH) { return; } // Extract Node var node_alias = relationship.nodeAlias(); var node_value = value[node_alias]; delete value[node_...
javascript
{ "resource": "" }
q27619
addNodeRelationshipToStatement
train
function addNodeRelationshipToStatement(neode, builder, alias, rel_alias, target_alias, relationship, value, aliases, mode) { if (aliases.length > MAX_CREATE_DEPTH) { return; } // If Node is passed, attempt to create a relationship to that specific node if (value instanceof _Node2.default) { ...
javascript
{ "resource": "" }
q27620
_valueToJson
train
function _valueToJson(property, value) { if (_neo4jDriver.v1.isInt(value)) { return value.toNumber(); } else if (_neo4jDriver.v1.temporal.isDate(value) || _neo4jDriver.v1.temporal.isDateTime(value) || _neo4jDriver.v1.temporal.isTime(value) || _neo4jDriver.v1.temporal.isLocalDateTime(value) || _neo4jDriv...
javascript
{ "resource": "" }
q27621
CleanValue
train
function CleanValue(config, value) { // Convert temporal to a native date? if (temporal.indexOf(config.type.toLowerCase()) > -1 && typeof value == 'number') { value = new Date(value); } // Clean Values switch (config.type.toLowerCase()) { case 'float': value = parseFloat...
javascript
{ "resource": "" }
q27622
addCascadeDeleteNode
train
function addCascadeDeleteNode(neode, builder, from_alias, relationship, aliases, to_depth) { if ( aliases.length > to_depth ) return; const rel_alias = from_alias + relationship.name() + '_rel'; const node_alias = from_alias + relationship.name() + '_node'; const target = neode.model( relationship.targ...
javascript
{ "resource": "" }
q27623
DeleteNode
train
function DeleteNode(neode, identity, model) { var to_depth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : MAX_EAGER_DEPTH; var alias = 'this'; var to_delete = []; var aliases = [alias]; var depth = 1; var builder = new _Builder2.default(neode).match(alias, model).whereId...
javascript
{ "resource": "" }
q27624
eagerPattern
train
function eagerPattern(neode, depth, alias, rel) { var builder = new _Builder2.default(); var name = rel.name(); var type = rel.type(); var relationship = rel.relationship(); var direction = rel.direction(); var target = rel.target(); var relationship_variable = alias + '_' + name + '_rel'; ...
javascript
{ "resource": "" }
q27625
eagerNode
train
function eagerNode(neode, depth, alias, model) { var indent = ' '.repeat(depth * 2); var pattern = '\n' + indent + ' ' + alias + ' { '; // Properties pattern += '\n' + indent + indent + '.*'; // ID pattern += '\n' + indent + indent + ',' + EAGER_ID + ': id(' + alias + ')'; // Labels ...
javascript
{ "resource": "" }
q27626
eagerRelationship
train
function eagerRelationship(neode, depth, alias, node_alias, node_variable, node_model) { var indent = ' '.repeat(depth * 2); var pattern = '\n' + indent + ' ' + alias + ' { '; // Properties pattern += '\n' + indent + indent + '.*'; // ID pattern += '\n' + indent + indent + ',' + EAGER_ID + ':...
javascript
{ "resource": "" }
q27627
normalizeUnit
train
function normalizeUnit(unit) { unit = toStr(unit); if (unitShorthandMap[unit]) return unitShorthandMap[unit]; return unit.toLowerCase().replace(regEndS, ''); }
javascript
{ "resource": "" }
q27628
isAvailable
train
function isAvailable(port) { return new Promise((resolve, reject) => { const server = net.createServer(); server.unref(); server.on('error', reject); const options = {}; options.port = port; server.listen(options, () => { const { port } = server....
javascript
{ "resource": "" }
q27629
loadFiles
train
function loadFiles(paths, callbackFn, args) { // listify paths paths = paths.push ? paths : [paths]; var numWaiting = paths.length, x = numWaiting, pathsNotFound = [], fn, i; // define callback function fn = function(path, result, defaultPrevented) { // handle error if (resul...
javascript
{ "resource": "" }
q27630
log
train
function log(msg) { var d = new Date(), ts; ts = d.toLocaleTimeString().split(' '); ts = ts[0] + '.' + d.getMilliseconds() + ' ' + ts[1]; console.log('[' + ts + '] ' + msg); }
javascript
{ "resource": "" }
q27631
placeholder
train
function placeholder (input, property) { return ( input === undefined || input === '' || input === null ) ? property : input; }
javascript
{ "resource": "" }
q27632
capitalize
train
function capitalize (value, options) { options = options || {} var onlyFirstLetter = options.onlyFirstLetter != null ? options.onlyFirstLetter : false if (!value && value !== 0) return '' if(onlyFirstLetter === true) { return value.charAt(0).toUpperCase() + value.slice(1) } else { value = value.toStri...
javascript
{ "resource": "" }
q27633
limitBy
train
function limitBy (arr, n, offset) { offset = offset ? parseInt(offset, 10) : 0 n = util.toNumber(n) return typeof n === 'number' ? arr.slice(offset, offset + n) : arr }
javascript
{ "resource": "" }
q27634
ordinal
train
function ordinal (value, options) { options = options || {} var output = '' var includeNumber = options.includeNumber != null ? options.includeNumber : false if(includeNumber === true) output += value var j = value % 10, k = value % 100 if (j == 1 && k != 11) output += 'st' else if (j == 2 && k != ...
javascript
{ "resource": "" }
q27635
truncate
train
function truncate (value, length) { length = length || 15 if( !value || typeof value !== 'string' ) return '' if( value.length <= length) return value return value.substring(0, length) + '...' }
javascript
{ "resource": "" }
q27636
find
train
function find(arr, search) { var array = filterBy.apply(this, arguments); array.splice(1); return array; }
javascript
{ "resource": "" }
q27637
pluralize
train
function pluralize (value, word, options) { options = options || {} var output = '' var includeNumber = options.includeNumber != null ? options.includeNumber : false if(includeNumber === true) output += value + ' ' if(!value && value !== 0 || !word) return output if(Array.isArray(word)) { output += word...
javascript
{ "resource": "" }
q27638
train
function(name, source) { var s = source; var newEvents = s.events; if (newEvents) { newEvents.forEach(function(e) { if (s[e]) { this.eventMap[e] = s[e].bind(s); } }, this); this.eventSources[name] = s; this.eventSourceList.push(s); ...
javascript
{ "resource": "" }
q27639
train
function(target, events) { for (var i = 0, l = events.length, e; (i < l) && (e = events[i]); i++) { this.addEvent(target, e); } }
javascript
{ "resource": "" }
q27640
train
function(target, events) { for (var i = 0, l = events.length, e; (i < l) && (e = events[i]); i++) { this.removeEvent(target, e); } }
javascript
{ "resource": "" }
q27641
train
function(inEvent) { var t = inEvent._target; if (t) { t.dispatchEvent(inEvent); // clone the event for the gesture system to process // clone after dispatch to pick up gesture prevention code var clone = this.cloneEvent(inEvent); clone.target = t; this.fillGes...
javascript
{ "resource": "" }
q27642
train
function(inEvent) { var lts = this.lastTouches; var x = inEvent.clientX, y = inEvent.clientY; for (var i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) { // simulated mouse events will be swallowed near a primary touchend var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y); ...
javascript
{ "resource": "" }
q27643
train
function(touch) { var dx = Math.abs(x - touch.x), dy = Math.abs(y - touch.y); return (dx <= DEDUP_DIST && dy <= DEDUP_DIST); }
javascript
{ "resource": "" }
q27644
findScope
train
function findScope(model, prop) { while (model[parentScopeName] && !Object.prototype.hasOwnProperty.call(model, prop)) { model = model[parentScopeName]; } return model; }
javascript
{ "resource": "" }
q27645
train
function(value) { var parts = []; for (var key in value) { parts.push(convertStylePropertyName(key) + ': ' + value[key]); } return parts.join('; '); }
javascript
{ "resource": "" }
q27646
train
function(template) { var indexIdent = template.polymerExpressionIndexIdent_; if (!indexIdent) return; return function(templateInstance, index) { templateInstance.model[indexIdent] = index; }; }
javascript
{ "resource": "" }
q27647
jURL
train
function jURL(url, base /* , encoding */) { if (base !== undefined && !(base instanceof jURL)) base = new jURL(String(base)); this._url = url; clear.call(this); var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, ''); // encoding = encoding || 'utf-8' parse.call(this, input, null, b...
javascript
{ "resource": "" }
q27648
train
function() { // only flush if the page is visibile if (document.visibilityState === 'hidden') { if (scope.flushPoll) { clearInterval(scope.flushPoll); } } else { scope.flushPoll = setInterval(flush, FLUSH_POLL_INTERVAL); } }
javascript
{ "resource": "" }
q27649
Loader
train
function Loader(regex) { this.cache = Object.create(null); this.map = Object.create(null); this.requests = 0; this.regex = regex; }
javascript
{ "resource": "" }
q27650
train
function(text, root, callback) { var matches = this.extractUrls(text, root); // every call to process returns all the text this loader has ever received var done = callback.bind(null, this.map); this.fetch(matches, done); }
javascript
{ "resource": "" }
q27651
train
function(matches, callback) { var inflight = matches.length; // return early if there is no fetching to be done if (!inflight) { return callback(); } // wait for all subrequests to return var done = function() { if (--inflight === 0) { callback(); ...
javascript
{ "resource": "" }
q27652
train
function(style, url, callback) { var text = style.textContent; var done = function(text) { style.textContent = text; callback(style); }; this.resolve(text, url, done); }
javascript
{ "resource": "" }
q27653
train
function(text, base, map) { var matches = this.loader.extractUrls(text, base); var match, url, intermediate; for (var i = 0; i < matches.length; i++) { match = matches[i]; url = match.url; // resolve any css text to be relative to the importer, keep absolute url intermediate = urlRes...
javascript
{ "resource": "" }
q27654
extend
train
function extend(prototype, api) { if (prototype && api) { // use only own properties of 'api' Object.getOwnPropertyNames(api).forEach(function(n) { // acquire property descriptor var pd = Object.getOwnPropertyDescriptor(api, n); if (pd) { // clone property via descripto...
javascript
{ "resource": "" }
q27655
copyProperty
train
function copyProperty(inName, inSource, inTarget) { var pd = getPropertyDescriptor(inSource, inName); Object.defineProperty(inTarget, inName, pd); }
javascript
{ "resource": "" }
q27656
getPropertyDescriptor
train
function getPropertyDescriptor(inObject, inName) { if (inObject) { var pd = Object.getOwnPropertyDescriptor(inObject, inName); return pd || getPropertyDescriptor(Object.getPrototypeOf(inObject), inName); } }
javascript
{ "resource": "" }
q27657
$super
train
function $super(arrayOfArgs) { // since we are thunking a method call, performance is important here: // memoize all lookups, once memoized the fast path calls no other // functions // // find the caller (cannot be `strict` because of 'caller') var caller = $super.caller; ...
javascript
{ "resource": "" }
q27658
train
function(anew, old, className) { if (old) { old.classList.remove(className); } if (anew) { anew.classList.add(className); } }
javascript
{ "resource": "" }
q27659
train
function() { var events = this.eventDelegates; log.events && (Object.keys(events).length > 0) && console.log('[%s] addHostListeners:', this.localName, events); // NOTE: host events look like bindings but really are not; // (1) we don't want the attribute to be set and (2) we want to support ...
javascript
{ "resource": "" }
q27660
train
function(obj, method, args) { if (obj) { log.events && console.group('[%s] dispatch [%s]', obj.localName, method); var fn = typeof method === 'function' ? method : obj[method]; if (fn) { fn[args ? 'apply' : 'call'](obj, args); } log.events && console.groupEnd(); ...
javascript
{ "resource": "" }
q27661
train
function() { // if we have no publish lookup table, we have no attributes to take // TODO(sjmiles): ad hoc if (this._publishLC) { for (var i=0, a$=this.attributes, l=a$.length, a; (a=a$[i]) && i<l; i++) { this.attributeToProperty(a.name, a.value); } } }
javascript
{ "resource": "" }
q27662
train
function(name, value) { // try to match this attribute to a property (attributes are // all lower-case, so this is case-insensitive search) var name = this.propertyForAttribute(name); if (name) { // filter out 'mustached' values, these are to be // replaced with bound-data ...
javascript
{ "resource": "" }
q27663
train
function(value, inferredType) { if (inferredType === 'boolean') { return value ? '' : undefined; } else if (inferredType !== 'object' && inferredType !== 'function' && value !== undefined) { return value; } }
javascript
{ "resource": "" }
q27664
train
function(name) { var inferredType = typeof this[name]; // try to intelligently serialize property value var serializedValue = this.serializeValue(this[name], inferredType); // boolean properties must reflect as boolean attributes if (serializedValue !== undefined) { this.setA...
javascript
{ "resource": "" }
q27665
resolveBindingValue
train
function resolveBindingValue(oldValue, value) { if (value === undefined && oldValue === null) { return value; } return (value === null || value === undefined) ? oldValue : value; }
javascript
{ "resource": "" }
q27666
train
function() { var n$ = this._observeNames; if (n$ && n$.length) { var o = this._propertyObserver = new CompoundObserver(true); this.registerObserver(o); // TODO(sorvell): may not be kosher to access the value here (this[n]); // previously we looked at the descriptor on the pro...
javascript
{ "resource": "" }
q27667
train
function(name, observable, resolveFn) { var privateName = name + '_'; var privateObservable = name + 'Observable_'; // Present for properties which are computed and published and have a // bound value. var privateComputedBoundValue = name + 'ComputedBoundObservable_'; this[privateOb...
javascript
{ "resource": "" }
q27668
train
function(template) { // ensure template is decorated (lets' things like <tr template ...> work) HTMLTemplateElement.decorate(template); // ensure a default bindingDelegate var syntax = this.syntax || (!template.bindingDelegate && this.element.syntax); var dom = template.createIns...
javascript
{ "resource": "" }
q27669
train
function() { if (!this._unbound) { log.unbind && console.log('[%s] asyncUnbindAll', this.localName); this._unbindAllJob = this.job(this._unbindAllJob, this.unbindAll, 0); } }
javascript
{ "resource": "" }
q27670
train
function(job, callback, wait) { if (typeof job === 'string') { var n = '___' + job; this[n] = Polymer.job.call(this, this[n], callback, wait); } else { // TODO(sjmiles): suggest we deprecate this call signature return Polymer.job.call(this, job, callback, wait); } }
javascript
{ "resource": "" }
q27671
train
function() { if (this.templateInstance && this.templateInstance.model) { console.warn('Attributes on ' + this.localName + ' were data bound ' + 'prior to Polymer upgrading the element. This may result in ' + 'incorrect binding types.'); } this.created(); this.prep...
javascript
{ "resource": "" }
q27672
train
function() { if (this._elementPrepared) { console.warn('Element already prepared', this.localName); return; } this._elementPrepared = true; // storage for shadowRoots info this.shadowRoots = {}; // install property observers this.createPropertyObserver(); ...
javascript
{ "resource": "" }
q27673
train
function(name, oldValue) { // TODO(sjmiles): adhoc filter if (name !== 'class' && name !== 'style') { this.attributeToProperty(name, this.getAttribute(name)); } if (this.attributeChanged) { this.attributeChanged.apply(this, arguments); } }
javascript
{ "resource": "" }
q27674
train
function(p) { if (p && p.element) { this.parseDeclarations(p.__proto__); p.parseDeclaration.call(this, p.element); } }
javascript
{ "resource": "" }
q27675
train
function(template) { if (template) { // make a shadow root var root = this.createShadowRoot(); // stamp template // which includes parsing and applying MDV bindings before being // inserted (to avoid {{}} in attribute values) // e.g. to prevent <img src="images/{{ic...
javascript
{ "resource": "" }
q27676
train
function(node, listener) { var observer = new MutationObserver(function(mutations) { listener.call(this, observer, mutations); observer.disconnect(); }.bind(this)); observer.observe(node, {childList: true, subtree: true}); }
javascript
{ "resource": "" }
q27677
train
function(callback) { var template = this.fetchTemplate(); var content = template && this.templateContent(); if (content) { this.convertSheetsToStyles(content); var styles = this.findLoadableStyles(content); if (styles.length) { var templateUrl = template.ownerDocument...
javascript
{ "resource": "" }
q27678
train
function() { this.sheets = this.findNodes(SHEET_SELECTOR); this.sheets.forEach(function(s) { if (s.parentNode) { s.parentNode.removeChild(s); } }); }
javascript
{ "resource": "" }
q27679
train
function(name, extendee) { // build side-chained lists to optimize iterations this.optimizePropertyMaps(this.prototype); this.createPropertyAccessors(this.prototype); // install mdv delegate on template this.installBindingDelegate(this.fetchTemplate()); // install external stylesheet...
javascript
{ "resource": "" }
q27680
train
function(extnds) { var prototype = this.findBasePrototype(extnds); if (!prototype) { // create a prototype based on tag-name extension var prototype = HTMLElement.getPrototypeForTag(extnds); // insert base api in inheritance chain (if needed) prototype = this.ensureBaseApi(pr...
javascript
{ "resource": "" }
q27681
train
function(prototype) { if (prototype.PolymerBase) { return prototype; } var extended = Object.create(prototype); // we need a unique copy of base api for each base prototype // therefore we 'extend' here instead of simply chaining api.publish(api.instance, extended); // ...
javascript
{ "resource": "" }
q27682
train
function(name, extendee) { var info = { prototype: this.prototype } // native element must be specified in extends var typeExtension = this.findTypeExtension(extendee); if (typeExtension) { info.extends = typeExtension; } // register the prototype with HTMLElem...
javascript
{ "resource": "" }
q27683
train
function(element, check, go) { var shouldAdd = element.__queue && !element.__queue.check; if (shouldAdd) { queueForElement(element).push(element); element.__queue.check = check; element.__queue.go = go; } return (this.indexOf(element) !== 0); }
javascript
{ "resource": "" }
q27684
train
function(element) { var readied = this.remove(element); if (readied) { element.__queue.flushable = true; this.addToFlushQueue(readied); this.check(); } }
javascript
{ "resource": "" }
q27685
train
function() { var e$ = []; for (var i=0, l=elements.length, e; (i<l) && (e=elements[i]); i++) { if (e.__queue && !e.__queue.flushable) { e$.push(e); } } return e$; }
javascript
{ "resource": "" }
q27686
forceReady
train
function forceReady(timeout) { if (timeout === undefined) { queue.ready(); return; } var handle = setTimeout(function() { queue.ready(); }, timeout); Polymer.whenReady(function() { clearTimeout(handle); }); }
javascript
{ "resource": "" }
q27687
_import
train
function _import(urls, callback) { if (urls && urls.length) { var frag = document.createDocumentFragment(); for (var i=0, l=urls.length, url, link; (i<l) && (url=urls[i]); i++) { link = document.createElement('link'); link.rel = 'import'; link.href = url; frag.appendChild(l...
javascript
{ "resource": "" }
q27688
slice
train
function slice(what, start) { for (var j = 0, i = start || 0, arr = []; i < what.length; i++) { arr[j++] = what[i]; } return arr; }
javascript
{ "resource": "" }
q27689
train
function (newValue) { // and no inheritance is involved if (this === self) { // notify the method but ... var value = oldValue; updateValue(newValue); // ... do not update the get value ...
javascript
{ "resource": "" }
q27690
deepClone
train
function deepClone(item) { let clone = item; if (isArray(item)) { clone = new Array(item.length); item.forEach((child, key) => { clone[key] = deepClone(child); }); } else if (item && typeOf(item) === 'object') { clone = {}; keys(item).forEach(key => { clone[key] = deepClone(item[ke...
javascript
{ "resource": "" }
q27691
loadOptions
train
function loadOptions() { chrome.storage.sync.get('options', function(data) { var options = data.options; document.querySelector('[data-settings=tomster]').checked = options && options.showTomster; }); }
javascript
{ "resource": "" }
q27692
storeOptions
train
function storeOptions() { var showTomster = this.checked; chrome.storage.sync.set({ options: { showTomster: showTomster } }, function optionsSaved() { console.log("saved!"); }); }
javascript
{ "resource": "" }
q27693
customizeProperties
train
function customizeProperties(mixinDetails, propertyInfo) { let newMixinDetails = []; let neededProperties = {}; let groups = propertyInfo.groups || []; let skipProperties = propertyInfo.skipProperties || []; let skipMixins = propertyInfo.skipMixins || []; if (groups.length) { mixinDetails[0].expand = f...
javascript
{ "resource": "" }
q27694
generateVersionsTooltip
train
function generateVersionsTooltip(versions) { return versions.map(function(lib) { return lib.name + " " + lib.version; }).join("\n"); }
javascript
{ "resource": "" }
q27695
setActionTitle
train
function setActionTitle(tabId) { chrome.pageAction.setTitle({ tabId: tabId, title: generateVersionsTooltip(activeTabs[tabId]) }); }
javascript
{ "resource": "" }
q27696
relative
train
function relative(aRoot, aPath) { if (aRoot === "") { aRoot = "."; } aRoot = aRoot.replace(/\/$/, ''); // It is possible for the path to be above the root. In this case, simply // checking whether the root is a prefix of the path won't work. Instead, we // need to remove components from ...
javascript
{ "resource": "" }
q27697
recursiveSearch
train
function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) { // This function terminates when one of the following is true: // // 1. We find the exact element we are looking for. // // 2. We did not find the exact element, but we can return the index of // the next-close...
javascript
{ "resource": "" }
q27698
randomIntInRange
train
function randomIntInRange(low, high) { return Math.round(low + (Math.random() * (high - low))); }
javascript
{ "resource": "" }
q27699
findMetaTag
train
function findMetaTag(attribute, regExp = /.*/) { let metas = document.querySelectorAll(`meta[${attribute}]`); for (let i = 0; i < metas.length; i++) { let match = metas[i].getAttribute(attribute).match(regExp); if (match) { return metas[i]; } } return null; }
javascript
{ "resource": "" }