_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q63100
test
function(trapName) { var trap = this.handler[trapName]; if (trap === undefined) { // the trap was not defined, // perform the default forwarding behavior return undefined; } if (typeof trap !== "function") { throw new TypeError(trapName + " trap is not callable: "+trap); } return trap; }
javascript
{ "resource": "" }
q63101
test
function(name) { var handler = this; if (!handler.has(name)) return undefined; return { get: function() { return handler.get(this, name); }, set: function(val) { if (handler.set(this, name, val)) { return val; } else { throw new TypeError("failed assignment to "+name); } }, enumerable: true, configurable: true }; }
javascript
{ "resource": "" }
q63102
test
function() { var trap = this.getTrap("freeze"); if (trap === undefined) { // default forwarding behavior return Reflect.freeze(this.target); } var success = trap.call(this.handler, this.target); success = !!success; // coerce to Boolean if (success) { if (!Object_isFrozen(this.target)) { throw new TypeError("can't report non-frozen object as frozen: "+ this.target); } } return success; }
javascript
{ "resource": "" }
q63103
test
function() { var trap = this.getTrap("seal"); if (trap === undefined) { // default forwarding behavior return Reflect.seal(this.target); } var success = trap.call(this.handler, this.target); success = !!success; // coerce to Boolean if (success) { if (!Object_isSealed(this.target)) { throw new TypeError("can't report non-sealed object as sealed: "+ this.target); } } return success; }
javascript
{ "resource": "" }
q63104
test
function() { var trap = this.getTrap("preventExtensions"); if (trap === undefined) { // default forwarding behavior return Reflect.preventExtensions(this.target); } var success = trap.call(this.handler, this.target); success = !!success; // coerce to Boolean if (success) { if (Object_isExtensible(this.target)) { throw new TypeError("can't report extensible object as non-extensible: "+ this.target); } } return success; }
javascript
{ "resource": "" }
q63105
test
function(name) { "use strict"; var trap = this.getTrap("deleteProperty"); if (trap === undefined) { // default forwarding behavior return Reflect.deleteProperty(this.target, name); } name = String(name); var res = trap.call(this.handler, this.target, name); res = !!res; // coerce to Boolean if (res === true) { if (isSealed(name, this.target)) { throw new TypeError("property '"+name+"' is non-configurable "+ "and can't be deleted"); } } return res; }
javascript
{ "resource": "" }
q63106
test
function() { var trap = this.getTrap("iterate"); if (trap === undefined) { // default forwarding behavior return Reflect.iterate(this.target); } var trapResult = trap.call(this.handler, this.target); if (Object(trapResult) !== trapResult) { throw new TypeError("iterate trap should return an iterator object, "+ "got: "+ trapResult); } return trapResult; }
javascript
{ "resource": "" }
q63107
test
function() { var trap = this.getTrap("keys"); if (trap === undefined) { // default forwarding behavior return Reflect.keys(this.target); } var trapResult = trap.call(this.handler, this.target); // propNames is used as a set of strings var propNames = Object.create(null); var numProps = +trapResult.length; var result = new Array(numProps); for (var i = 0; i < numProps; i++) { var s = String(trapResult[i]); if (propNames[s]) { throw new TypeError("keys trap cannot list a "+ "duplicate property '"+s+"'"); } if (!Object.isExtensible(this.target) && !isFixed(s, this.target)) { // non-extensible proxies don't tolerate new own property names throw new TypeError("keys trap cannot list a new "+ "property '"+s+"' on a non-extensible object"); } propNames[s] = true; result[i] = s; } var ownEnumerableProps = Object.keys(this.target); var target = this.target; ownEnumerableProps.forEach(function (ownEnumerableProp) { if (!propNames[ownEnumerableProp]) { if (isSealed(ownEnumerableProp, target)) { throw new TypeError("keys trap failed to include "+ "non-configurable enumerable property '"+ ownEnumerableProp+"'"); } if (!Object.isExtensible(target) && isFixed(ownEnumerableProp, target)) { // if handler is allowed not to report ownEnumerableProp as an own // property, we cannot guarantee that it will never report it as // an own property later. Once a property has been reported as // non-existent on a non-extensible object, it should forever be // reported as non-existent throw new TypeError("cannot report existing own property '"+ ownEnumerableProp+"' as non-existent on a "+ "non-extensible object"); } } }); return result; }
javascript
{ "resource": "" }
q63108
test
function() { var trap = this.getTrap("ownKeys"); if (trap === undefined) { // default forwarding behavior return Reflect.ownKeys(this.target); } var trapResult = trap.call(this.handler, this.target); if (trapResult === null || typeof trapResult !== "object") { throw new TypeError("ownKeys should return an iterator object, got " + trapResult); } return trapResult; }
javascript
{ "resource": "" }
q63109
makeUnwrapping0ArgMethod
test
function makeUnwrapping0ArgMethod(primitive) { return function builtin() { var vHandler = safeWeakMapGet(directProxies, this); if (vHandler !== undefined) { return builtin.call(vHandler.target); } else { return primitive.call(this); } } }
javascript
{ "resource": "" }
q63110
load
test
function load(obj) { var name, root; root = typeof global !== "undefined" && global !== null ? global : this; for(name in obj) { if(obj.hasOwnProperty(name)) { root[name] = obj[name]; } } }
javascript
{ "resource": "" }
q63111
test
function(record, options) { var json = {}; if (options && options.includeId) { var id = get(record, 'id'); if (id) { json[get(this, 'primaryKey')] = id; } } record.eachAttribute(function(key, attribute) { this.serializeAttribute(record, json, key, attribute); }, this); record.eachRelationship(function(key, relationship) { if (relationship.kind === 'belongsTo') { this.serializeBelongsTo(record, json, relationship); } else if (relationship.kind === 'hasMany') { this.serializeHasMany(record, json, relationship); } }, this); return json; }
javascript
{ "resource": "" }
q63112
test
function(record, json, key, attribute) { var attrs = get(this, 'attrs'); var value = get(record, key), type = attribute.type; if (type) { var transform = this.transformFor(type); value = transform.serialize(value); } // if provided, use the mapping provided by `attrs` in // the serializer key = attrs && attrs[key] || (this.keyForAttribute ? this.keyForAttribute(key) : key); json[key] = value; }
javascript
{ "resource": "" }
q63113
test
function(record, json, relationship) { var key = relationship.key; var belongsTo = get(record, key); key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo") : key; if (isNone(belongsTo)) { json[key] = belongsTo; } else { json[key] = get(belongsTo, 'id'); } if (relationship.options.polymorphic) { this.serializePolymorphicType(record, json, relationship); } }
javascript
{ "resource": "" }
q63114
test
function(record, json, relationship) { var key = relationship.key; var relationshipType = DS.RelationshipChange.determineRelationshipType(record.constructor, relationship); if (relationshipType === 'manyToNone' || relationshipType === 'manyToMany') { json[key] = get(record, key).mapBy('id'); // TODO support for polymorphic manyToNone and manyToMany relationships } }
javascript
{ "resource": "" }
q63115
test
function(store, type, payload, id, requestType) { this.extractMeta(store, type, payload); var specificExtract = "extract" + requestType.charAt(0).toUpperCase() + requestType.substr(1); return this[specificExtract](store, type, payload, id, requestType); }
javascript
{ "resource": "" }
q63116
test
function(store, type, payload) { if (payload && payload.meta) { store.metaForType(type, payload.meta); delete payload.meta; } }
javascript
{ "resource": "" }
q63117
test
function() { var promiseLabel = "DS: RecordArray#save " + get(this, 'type'); var promise = Ember.RSVP.all(this.invoke("save"), promiseLabel).then(function(array) { return Ember.A(array); }, null, "DS: RecordArray#save apply Ember.NativeArray"); return DS.PromiseArray.create({ promise: promise }); }
javascript
{ "resource": "" }
q63118
test
function(index, removed, added) { // Map the array of record objects into an array of client ids. added = map(added, function(record) { Ember.assert("You cannot add '" + record.constructor.typeKey + "' records to this relationship (only '" + this.type.typeKey + "' allowed)", !this.type || record instanceof this.type); return record; }, this); this._super(index, removed, added); }
javascript
{ "resource": "" }
q63119
test
function(hash) { var owner = get(this, 'owner'), store = get(owner, 'store'), type = get(this, 'type'), record; Ember.assert("You cannot add '" + type.typeKey + "' records to this polymorphic relationship.", !get(this, 'isPolymorphic')); record = store.createRecord.call(store, type, hash); this.pushObject(record); return record; }
javascript
{ "resource": "" }
q63120
test
function(type) { var adapter = this.adapterFor(type); if (adapter && adapter.generateIdForRecord) { return adapter.generateIdForRecord(this); } return null; }
javascript
{ "resource": "" }
q63121
test
function(type, id) { type = this.modelFor(type); var record = this.recordForId(type, id); var promise = this.fetchRecord(record) || resolve(record, "DS: Store#findById " + type + " with id: " + id); return promiseObject(promise); }
javascript
{ "resource": "" }
q63122
test
function(type, ids) { var store = this; var promiseLabel = "DS: Store#findByIds " + type; return promiseArray(Ember.RSVP.all(map(ids, function(id) { return store.findById(type, id); })).then(Ember.A, null, "DS: Store#findByIds of " + type + " complete")); }
javascript
{ "resource": "" }
q63123
test
function(record) { var type = record.constructor, adapter = this.adapterFor(type), id = get(record, 'id'); Ember.assert("You cannot reload a record without an ID", id); Ember.assert("You tried to reload a record but you have no adapter (for " + type + ")", adapter); Ember.assert("You tried to reload a record but your adapter does not implement `find`", adapter.find); return _find(adapter, this, type, id); }
javascript
{ "resource": "" }
q63124
test
function(records, owner, resolver) { if (!records.length) { return; } // Group By Type var recordsByTypeMap = Ember.MapWithDefault.create({ defaultValue: function() { return Ember.A(); } }); forEach(records, function(record) { recordsByTypeMap.get(record.constructor).push(record); }); forEach(recordsByTypeMap, function(type, records) { var ids = records.mapProperty('id'), adapter = this.adapterFor(type); Ember.assert("You tried to load many records but you have no adapter (for " + type + ")", adapter); Ember.assert("You tried to load many records but your adapter does not implement `findMany`", adapter.findMany); resolver.resolve(_findMany(adapter, this, type, ids, owner)); }, this); }
javascript
{ "resource": "" }
q63125
test
function(type, id) { id = coerceId(id); type = this.modelFor(type); return !!this.typeMapFor(type).idToRecord[id]; }
javascript
{ "resource": "" }
q63126
test
function(type, id) { type = this.modelFor(type); id = coerceId(id); var record = this.typeMapFor(type).idToRecord[id]; if (!record) { record = this.buildRecord(type, id); } return record; }
javascript
{ "resource": "" }
q63127
test
function(type, query) { type = this.modelFor(type); var array = this.recordArrayManager .createAdapterPopulatedRecordArray(type, query); var adapter = this.adapterFor(type), promiseLabel = "DS: Store#findQuery " + type, resolver = Ember.RSVP.defer(promiseLabel); Ember.assert("You tried to load a query but you have no adapter (for " + type + ")", adapter); Ember.assert("You tried to load a query but your adapter does not implement `findQuery`", adapter.findQuery); resolver.resolve(_findQuery(adapter, this, type, query, array)); return promiseArray(resolver.promise); }
javascript
{ "resource": "" }
q63128
test
function(type) { type = this.modelFor(type); var typeMap = this.typeMapFor(type), findAllCache = typeMap.findAllCache; if (findAllCache) { return findAllCache; } var array = this.recordArrayManager.createRecordArray(type); typeMap.findAllCache = array; return array; }
javascript
{ "resource": "" }
q63129
test
function(type) { type = this.modelFor(type); var typeMap = this.typeMapFor(type), records = typeMap.records, record; while(record = records.pop()) { record.unloadRecord(); } typeMap.findAllCache = null; }
javascript
{ "resource": "" }
q63130
test
function(type, query, filter) { var promise; // allow an optional server query if (arguments.length === 3) { promise = this.findQuery(type, query); } else if (arguments.length === 2) { filter = query; } type = this.modelFor(type); var array = this.recordArrayManager .createFilteredRecordArray(type, filter); promise = promise || resolve(array); return promiseArray(promise.then(function() { return array; }, null, "DS: Store#filter of " + type)); }
javascript
{ "resource": "" }
q63131
test
function() { var pending = this._pendingSave.slice(); this._pendingSave = []; forEach(pending, function(tuple) { var record = tuple[0], resolver = tuple[1], adapter = this.adapterFor(record.constructor), operation; if (get(record, 'isNew')) { operation = 'createRecord'; } else if (get(record, 'isDeleted')) { operation = 'deleteRecord'; } else { operation = 'updateRecord'; } resolver.resolve(_commit(adapter, this, operation, record)); }, this); }
javascript
{ "resource": "" }
q63132
test
function(record, data) { if (data) { // normalize relationship IDs into records data = normalizeRelationships(this, record.constructor, data, record); this.updateId(record, data); } record.adapterDidCommit(data); }
javascript
{ "resource": "" }
q63133
test
function(record, data) { var oldId = get(record, 'id'), id = coerceId(data.id); Ember.assert("An adapter cannot assign a new id to a record that already has an id. " + record + " had id: " + oldId + " and you tried to update it with " + id + ". This likely happened because your server returned data in response to a find or update that had a different id than the one you sent.", oldId === null || id === oldId); this.typeMapFor(record.constructor).idToRecord[id] = record; set(record, 'id', id); }
javascript
{ "resource": "" }
q63134
test
function(type) { var typeMaps = get(this, 'typeMaps'), guid = Ember.guidFor(type), typeMap; typeMap = typeMaps[guid]; if (typeMap) { return typeMap; } typeMap = { idToRecord: {}, records: [], metadata: {} }; typeMaps[guid] = typeMap; return typeMap; }
javascript
{ "resource": "" }
q63135
test
function(type, data, _partial) { // _partial is an internal param used by `update`. // If passed, it means that the data should be // merged into the existing data, not replace it. Ember.assert("You must include an `id` in a hash passed to `push`", data.id != null); type = this.modelFor(type); // normalize relationship IDs into records data = normalizeRelationships(this, type, data); this._load(type, data, _partial); return this.recordForId(type, data.id); }
javascript
{ "resource": "" }
q63136
test
function (type, payload) { var serializer; if (!payload) { payload = type; serializer = defaultSerializer(this.container); Ember.assert("You cannot use `store#pushPayload` without a type unless your default serializer defines `pushPayload`", serializer.pushPayload); } else { serializer = this.serializerFor(type); } serializer.pushPayload(this, payload); }
javascript
{ "resource": "" }
q63137
test
function(type, metadata) { type = this.modelFor(type); Ember.merge(this.typeMapFor(type).metadata, metadata); }
javascript
{ "resource": "" }
q63138
test
function(type, id, data) { var typeMap = this.typeMapFor(type), idToRecord = typeMap.idToRecord; Ember.assert('The id ' + id + ' has already been used with another record of type ' + type.toString() + '.', !id || !idToRecord[id]); // lookupFactory should really return an object that creates // instances with the injections applied var record = type._create({ id: id, store: this, container: this.container }); if (data) { record.setupData(data); } // if we're creating an item, this process will be done // later, once the object has been persisted. if (id) { idToRecord[id] = record; } typeMap.records.push(record); return record; }
javascript
{ "resource": "" }
q63139
addUnsavedRecords
test
function addUnsavedRecords(record, key, data) { if(record) { data.pushObjects(record.get(key).filterBy('isNew')); } }
javascript
{ "resource": "" }
q63140
deepClone
test
function deepClone(object) { var clone = {}, value; for (var prop in object) { value = object[prop]; if (value && typeof value === 'object') { clone[prop] = deepClone(value); } else { clone[prop] = value; } } return clone; }
javascript
{ "resource": "" }
q63141
test
function(attribute, messages) { var wasEmpty = get(this, 'isEmpty'); messages = this._findOrCreateMessages(attribute, messages); get(this, 'content').addObjects(messages); this.notifyPropertyChange(attribute); this.enumerableContentDidChange(); if (wasEmpty && !get(this, 'isEmpty')) { this.trigger('becameInvalid'); } }
javascript
{ "resource": "" }
q63142
test
function(attribute) { if (get(this, 'isEmpty')) { return; } var content = get(this, 'content').rejectBy('attribute', attribute); get(this, 'content').setObjects(content); this.notifyPropertyChange(attribute); this.enumerableContentDidChange(); if (get(this, 'isEmpty')) { this.trigger('becameValid'); } }
javascript
{ "resource": "" }
q63143
test
function(data) { set(this, 'isError', false); if (data) { this._data = data; } else { Ember.mixin(this._data, this._inFlightAttributes); } this._inFlightAttributes = {}; this.send('didCommit'); this.updateRecordArraysLater(); if (!data) { return; } this.suspendRelationshipObservers(function() { this.notifyPropertyChange('data'); }); }
javascript
{ "resource": "" }
q63144
test
function() { this._attributes = {}; if (get(this, 'isError')) { this._inFlightAttributes = {}; set(this, 'isError', false); } if (!get(this, 'isValid')) { this._inFlightAttributes = {}; } this.send('rolledBack'); this.suspendRelationshipObservers(function() { this.notifyPropertyChange('data'); }); }
javascript
{ "resource": "" }
q63145
test
function(callback, binding) { var observers = get(this.constructor, 'relationshipNames').belongsTo; var self = this; try { this._suspendedRelationships = true; Ember._suspendObservers(self, observers, null, 'belongsToDidChange', function() { Ember._suspendBeforeObservers(self, observers, null, 'belongsToWillChange', function() { callback.call(binding || self); }); }); } finally { this._suspendedRelationships = false; } }
javascript
{ "resource": "" }
q63146
test
function() { var promiseLabel = "DS: Model#save " + this; var resolver = Ember.RSVP.defer(promiseLabel); this.get('store').scheduleSave(this, resolver); this._inFlightAttributes = this._attributes; this._attributes = {}; return DS.PromiseObject.create({ promise: resolver.promise }); }
javascript
{ "resource": "" }
q63147
test
function() { set(this, 'isReloading', true); var record = this; var promiseLabel = "DS: Model#reload of " + this; var promise = new Ember.RSVP.Promise(function(resolve){ record.send('reloadRecord', resolve); }, promiseLabel).then(function() { record.set('isReloading', false); record.set('isError', false); return record; }, function(reason) { record.set('isError', true); throw reason; }, "DS: Model#reload complete, update flags"); return DS.PromiseObject.create({ promise: promise }); }
javascript
{ "resource": "" }
q63148
test
function(attributeName, value) { // If a value is passed in, update the internal attributes and clear // the attribute cache so it picks up the new value. Otherwise, // collapse the current value into the internal attributes because // the adapter has acknowledged it. if (value !== undefined) { this._data[attributeName] = value; this.notifyPropertyChange(attributeName); } else { this._data[attributeName] = this._inFlightAttributes[attributeName]; } this.updateRecordArraysLater(); }
javascript
{ "resource": "" }
q63149
test
function(callback, binding) { get(this, 'attributes').forEach(function(name, meta) { callback.call(binding, name, meta); }, binding); }
javascript
{ "resource": "" }
q63150
test
function(callback, binding) { get(this, 'transformedAttributes').forEach(function(name, type) { callback.call(binding, name, type); }); }
javascript
{ "resource": "" }
q63151
test
function(proto, key, value) { // Check if the value being set is a computed property. if (value instanceof Ember.Descriptor) { // If it is, get the metadata for the relationship. This is // populated by the `DS.belongsTo` helper when it is creating // the computed property. var meta = value.meta(); if (meta.isRelationship && meta.kind === 'belongsTo') { Ember.addObserver(proto, key, null, 'belongsToDidChange'); Ember.addBeforeObserver(proto, key, null, 'belongsToWillChange'); } meta.parentType = proto.constructor; } }
javascript
{ "resource": "" }
q63152
test
function(callback, binding) { get(this, 'relationshipsByName').forEach(function(name, relationship) { callback.call(binding, name, relationship); }); }
javascript
{ "resource": "" }
q63153
test
function() { forEach(this.changedRecords, function(record) { if (get(record, 'isDeleted')) { this._recordWasDeleted(record); } else { this._recordWasChanged(record); } }, this); this.changedRecords = []; }
javascript
{ "resource": "" }
q63154
test
function(array, filter, type, record) { var shouldBeInArray; if (!filter) { shouldBeInArray = true; } else { shouldBeInArray = filter(record); } var recordArrays = this.recordArraysForRecord(record); if (shouldBeInArray) { recordArrays.add(array); array.addRecord(record); } else if (!shouldBeInArray) { recordArrays.remove(array); array.removeRecord(record); } }
javascript
{ "resource": "" }
q63155
test
function(array, type, filter) { var typeMap = this.store.typeMapFor(type), records = typeMap.records, record; for (var i=0, l=records.length; i<l; i++) { record = records[i]; if (!get(record, 'isDeleted') && !get(record, 'isEmpty')) { this.updateRecordArray(array, filter, type, record); } } }
javascript
{ "resource": "" }
q63156
test
function(type, records) { var manyArray = DS.ManyArray.create({ type: type, content: records, store: this.store }); forEach(records, function(record) { var arrays = this.recordArraysForRecord(record); arrays.add(manyArray); }, this); return manyArray; }
javascript
{ "resource": "" }
q63157
test
function(type) { var array = DS.RecordArray.create({ type: type, content: Ember.A(), store: this.store, isLoaded: true }); this.registerFilteredRecordArray(array, type); return array; }
javascript
{ "resource": "" }
q63158
test
function(type, filter) { var array = DS.FilteredRecordArray.create({ type: type, content: Ember.A(), store: this.store, manager: this, filterFunction: filter }); this.registerFilteredRecordArray(array, type, filter); return array; }
javascript
{ "resource": "" }
q63159
test
function(type, query) { return DS.AdapterPopulatedRecordArray.create({ type: type, query: query, content: Ember.A(), store: this.store }); }
javascript
{ "resource": "" }
q63160
test
function(array, type, filter) { var recordArrays = this.filteredRecordArrays.get(type); recordArrays.push(array); this.updateFilter(array, type, filter); }
javascript
{ "resource": "" }
q63161
test
function(record, array) { var loadingRecordArrays = record._loadingRecordArrays || []; loadingRecordArrays.push(array); record._loadingRecordArrays = loadingRecordArrays; }
javascript
{ "resource": "" }
q63162
test
function(record, options) { return get(record, 'store').serializerFor(record.constructor.typeKey).serialize(record, options); }
javascript
{ "resource": "" }
q63163
test
function(store, type, ids) { var promises = map.call(ids, function(id) { return this.find(store, type, id); }, this); return Ember.RSVP.all(promises); }
javascript
{ "resource": "" }
q63164
test
function(type) { if (type.FIXTURES) { var fixtures = Ember.A(type.FIXTURES); return fixtures.map(function(fixture){ var fixtureIdType = typeof fixture.id; if(fixtureIdType !== "number" && fixtureIdType !== "string"){ throw new Error(fmt('the id property must be defined as a number or string for fixture %@', [fixture])); } fixture.id = fixture.id + ''; return fixture; }); } return null; }
javascript
{ "resource": "" }
q63165
test
function(store, type, record) { return store.serializerFor(type).serialize(record, { includeId: true }); }
javascript
{ "resource": "" }
q63166
test
function(type, hash, prop) { this.normalizeId(hash); this.normalizeAttributes(type, hash); this.normalizeRelationships(type, hash); this.normalizeUsingDeclaredMapping(type, hash); if (this.normalizeHash && this.normalizeHash[prop]) { this.normalizeHash[prop](hash); } return this._super(type, hash, prop); }
javascript
{ "resource": "" }
q63167
test
function(store, primaryType, payload, recordId, requestType) { payload = this.normalizePayload(primaryType, payload); var primaryTypeName = primaryType.typeKey, primaryRecord; for (var prop in payload) { var typeName = this.typeForRoot(prop), isPrimary = typeName === primaryTypeName; // legacy support for singular resources if (isPrimary && Ember.typeOf(payload[prop]) !== "array" ) { primaryRecord = this.normalize(primaryType, payload[prop], prop); continue; } var type = store.modelFor(typeName); /*jshint loopfunc:true*/ forEach.call(payload[prop], function(hash) { var typeName = this.typeForRoot(prop), type = store.modelFor(typeName), typeSerializer = store.serializerFor(type); hash = typeSerializer.normalize(type, hash, prop); var isFirstCreatedRecord = isPrimary && !recordId && !primaryRecord, isUpdatedRecord = isPrimary && coerceId(hash.id) === recordId; // find the primary record. // // It's either: // * the record with the same ID as the original request // * in the case of a newly created record that didn't have an ID, the first // record in the Array if (isFirstCreatedRecord || isUpdatedRecord) { primaryRecord = hash; } else { store.push(typeName, hash); } }, this); } return primaryRecord; }
javascript
{ "resource": "" }
q63168
test
function(store, primaryType, payload) { payload = this.normalizePayload(primaryType, payload); var primaryTypeName = primaryType.typeKey, primaryArray; for (var prop in payload) { var typeKey = prop, forcedSecondary = false; if (prop.charAt(0) === '_') { forcedSecondary = true; typeKey = prop.substr(1); } var typeName = this.typeForRoot(typeKey), type = store.modelFor(typeName), typeSerializer = store.serializerFor(type), isPrimary = (!forcedSecondary && (typeName === primaryTypeName)); /*jshint loopfunc:true*/ var normalizedArray = map.call(payload[prop], function(hash) { return typeSerializer.normalize(type, hash, prop); }, this); if (isPrimary) { primaryArray = normalizedArray; } else { store.pushMany(typeName, normalizedArray); } } return primaryArray; }
javascript
{ "resource": "" }
q63169
test
function(store, payload) { payload = this.normalizePayload(null, payload); for (var prop in payload) { var typeName = this.typeForRoot(prop), type = store.modelFor(typeName); /*jshint loopfunc:true*/ var normalizedArray = map.call(Ember.makeArray(payload[prop]), function(hash) { return this.normalize(type, hash, prop); }, this); store.pushMany(typeName, normalizedArray); } }
javascript
{ "resource": "" }
q63170
test
function(hash, type, record, options) { hash[type.typeKey] = this.serialize(record, options); }
javascript
{ "resource": "" }
q63171
test
function(record, json, relationship) { var key = relationship.key, belongsTo = get(record, key); key = this.keyForAttribute ? this.keyForAttribute(key) : key; json[key + "Type"] = belongsTo.constructor.typeKey; }
javascript
{ "resource": "" }
q63172
test
function(store, type, sinceToken) { var query; if (sinceToken) { query = { since: sinceToken }; } return this.ajax(this.buildURL(type.typeKey), 'GET', { data: query }); }
javascript
{ "resource": "" }
q63173
test
function(store, type, ids) { return this.ajax(this.buildURL(type.typeKey), 'GET', { data: { ids: ids } }); }
javascript
{ "resource": "" }
q63174
test
function(store, type, record) { var data = {}; var serializer = store.serializerFor(type.typeKey); serializer.serializeIntoHash(data, type, record, { includeId: true }); return this.ajax(this.buildURL(type.typeKey), "POST", { data: data }); }
javascript
{ "resource": "" }
q63175
test
function(store, type, record) { var data = {}; var serializer = store.serializerFor(type.typeKey); serializer.serializeIntoHash(data, type, record); var id = get(record, 'id'); return this.ajax(this.buildURL(type.typeKey, id), "PUT", { data: data }); }
javascript
{ "resource": "" }
q63176
test
function(store, type, record) { var id = get(record, 'id'); return this.ajax(this.buildURL(type.typeKey, id), "DELETE"); }
javascript
{ "resource": "" }
q63177
test
function(type, id) { var url = [], host = get(this, 'host'), prefix = this.urlPrefix(); if (type) { url.push(this.pathForType(type)); } if (id) { url.push(id); } if (prefix) { url.unshift(prefix); } url = url.join('/'); if (!host && url) { url = '/' + url; } return url; }
javascript
{ "resource": "" }
q63178
test
function(url, type, hash) { var adapter = this; return new Ember.RSVP.Promise(function(resolve, reject) { hash = adapter.ajaxOptions(url, type, hash); hash.success = function(json) { Ember.run(null, resolve, json); }; hash.error = function(jqXHR, textStatus, errorThrown) { Ember.run(null, reject, adapter.ajaxError(jqXHR)); }; Ember.$.ajax(hash); }, "DS: RestAdapter#ajax " + type + " to " + url); }
javascript
{ "resource": "" }
q63179
Inflector
test
function Inflector(ruleSet) { ruleSet = ruleSet || {}; ruleSet.uncountable = ruleSet.uncountable || {}; ruleSet.irregularPairs = ruleSet.irregularPairs || {}; var rules = this.rules = { plurals: ruleSet.plurals || [], singular: ruleSet.singular || [], irregular: {}, irregularInverse: {}, uncountable: {} }; loadUncountable(rules, ruleSet.uncountable); loadIrregular(rules, ruleSet.irregularPairs); }
javascript
{ "resource": "" }
q63180
test
function(key, kind) { key = Ember.String.decamelize(key); if (kind === "belongsTo") { return key + "_id"; } else if (kind === "hasMany") { return Ember.String.singularize(key) + "_ids"; } else { return key; } }
javascript
{ "resource": "" }
q63181
test
function(data, type, record, options) { var root = Ember.String.decamelize(type.typeKey); data[root] = this.serialize(record, options); }
javascript
{ "resource": "" }
q63182
test
function(record, json, relationship) { var key = relationship.key, belongsTo = get(record, key); key = this.keyForAttribute(key); json[key + "_type"] = Ember.String.capitalize(belongsTo.constructor.typeKey); }
javascript
{ "resource": "" }
q63183
test
function(root) { var camelized = Ember.String.camelize(root); return Ember.String.singularize(camelized); }
javascript
{ "resource": "" }
q63184
test
function(data){ if (data.links) { var links = data.links; for (var link in links) { var camelizedLink = Ember.String.camelize(link); if (camelizedLink !== link) { links[camelizedLink] = links[link]; delete links[link]; } } } }
javascript
{ "resource": "" }
q63185
test
function(type, hash) { var payloadKey, payload; if (this.keyForRelationship) { type.eachRelationship(function(key, relationship) { if (relationship.options.polymorphic) { payloadKey = this.keyForAttribute(key); payload = hash[payloadKey]; if (payload && payload.type) { payload.type = this.typeForRoot(payload.type); } else if (payload && relationship.kind === "hasMany") { var self = this; forEach(payload, function(single) { single.type = self.typeForRoot(single.type); }); } } else { payloadKey = this.keyForRelationship(key, relationship.kind); payload = hash[payloadKey]; } hash[key] = payload; if (key !== payloadKey) { delete hash[payloadKey]; } }, this); } }
javascript
{ "resource": "" }
q63186
test
function(record, json, relationship) { var key = relationship.key, attrs = get(this, 'attrs'), embed = attrs && attrs[key] && attrs[key].embedded === 'always'; if (embed) { json[this.keyForAttribute(key)] = get(record, key).map(function(relation) { var data = relation.serialize(), primaryKey = get(this, 'primaryKey'); data[primaryKey] = get(relation, primaryKey); return data; }, this); } }
javascript
{ "resource": "" }
q63187
test
function(store, primaryType, payload, recordId, requestType) { var root = this.keyForAttribute(primaryType.typeKey), partial = payload[root]; updatePayloadWithEmbedded(store, this, primaryType, partial, payload); return this._super(store, primaryType, payload, recordId, requestType); }
javascript
{ "resource": "" }
q63188
test
function(store, type, payload) { var root = this.keyForAttribute(type.typeKey), partials = payload[Ember.String.pluralize(root)]; forEach(partials, function(partial) { updatePayloadWithEmbedded(store, this, type, partial, payload); }, this); return this._super(store, type, payload); }
javascript
{ "resource": "" }
q63189
test
function(type) { var decamelized = Ember.String.decamelize(type); return Ember.String.pluralize(decamelized); }
javascript
{ "resource": "" }
q63190
test
function(jqXHR) { var error = this._super(jqXHR); if (jqXHR && jqXHR.status === 422) { var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)["errors"], errors = {}; forEach(Ember.keys(jsonErrors), function(key) { errors[Ember.String.camelize(key)] = jsonErrors[key]; }); return new DS.InvalidError(errors); } else { return error; } }
javascript
{ "resource": "" }
q63191
parseKeyValue
test
function parseKeyValue(/**string*/keyValue) { var obj = {}, key_value, key; forEach((keyValue || "").split('&'), function(keyValue){ if ( keyValue ) { key_value = keyValue.split('='); key = tryDecodeURIComponent(key_value[0]); if ( isDefined(key) ) { var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true; if (!obj[key]) { obj[key] = val; } else if(isArray(obj[key])) { obj[key].push(val); } else { obj[key] = [obj[key],val]; } } } }); return obj; }
javascript
{ "resource": "" }
q63192
test
function(key, value, writeAttr, attrName) { //special case for class attribute addition + removal //so that class changes can tap into the animation //hooks provided by the $animate service if(key == 'class') { value = value || ''; var current = this.$$element.attr('class') || ''; this.$removeClass(tokenDifference(current, value).join(' ')); this.$addClass(tokenDifference(value, current).join(' ')); } else { var booleanKey = getBooleanAttrName(this.$$element[0], key), normalizedVal, nodeName; if (booleanKey) { this.$$element.prop(key, value); attrName = booleanKey; } this[key] = value; // translate normalized key to actual key if (attrName) { this.$attr[key] = attrName; } else { attrName = this.$attr[key]; if (!attrName) { this.$attr[key] = attrName = snake_case(key, '-'); } } nodeName = nodeName_(this.$$element); // sanitize a[href] and img[src] values if ((nodeName === 'A' && key === 'href') || (nodeName === 'IMG' && key === 'src')) { // NOTE: $$urlUtils.resolve() doesn't support IE < 8 so we don't sanitize for that case. if (!msie || msie >= 8 ) { normalizedVal = $$urlUtils.resolve(value); if (normalizedVal !== '') { if ((key === 'href' && !normalizedVal.match(aHrefSanitizationWhitelist)) || (key === 'src' && !normalizedVal.match(imgSrcSanitizationWhitelist))) { this[key] = value = 'unsafe:' + normalizedVal; } } } } if (writeAttr !== false) { if (value === null || value === undefined) { this.$$element.removeAttr(attrName); } else { this.$$element.attr(attrName, value); } } } // fire observers var $$observers = this.$$observers; $$observers && forEach($$observers[key], function(fn) { try { fn(value); } catch (e) { $exceptionHandler(e); } }); function tokenDifference(str1, str2) { var values = [], tokens1 = str1.split(/\s+/), tokens2 = str2.split(/\s+/); outer: for(var i=0;i<tokens1.length;i++) { var token = tokens1[i]; for(var j=0;j<tokens2.length;j++) { if(token == tokens2[j]) continue outer; } values.push(token); } return values; }; }
javascript
{ "resource": "" }
q63193
compileNodes
test
function compileNodes(nodeList, transcludeFn, $rootElement, maxPriority, ignoreDirective) { var linkFns = [], nodeLinkFn, childLinkFn, directives, attrs, linkFnFound; for(var i = 0; i < nodeList.length; i++) { attrs = new Attributes(); // we must always refer to nodeList[i] since the nodes can be replaced underneath us. directives = collectDirectives(nodeList[i], [], attrs, i == 0 ? maxPriority : undefined, ignoreDirective); nodeLinkFn = (directives.length) ? applyDirectivesToNode(directives, nodeList[i], attrs, transcludeFn, $rootElement) : null; childLinkFn = (nodeLinkFn && nodeLinkFn.terminal || !nodeList[i].childNodes || !nodeList[i].childNodes.length) ? null : compileNodes(nodeList[i].childNodes, nodeLinkFn ? nodeLinkFn.transclude : transcludeFn); linkFns.push(nodeLinkFn); linkFns.push(childLinkFn); linkFnFound = (linkFnFound || nodeLinkFn || childLinkFn); } // return a linking function if we have found anything, null otherwise return linkFnFound ? compositeLinkFn : null; function compositeLinkFn(scope, nodeList, $rootElement, boundTranscludeFn) { var nodeLinkFn, childLinkFn, node, childScope, childTranscludeFn, i, ii, n; // copy nodeList so that linking doesn't break due to live list updates. var stableNodeList = []; for (i = 0, ii = nodeList.length; i < ii; i++) { stableNodeList.push(nodeList[i]); } for(i = 0, n = 0, ii = linkFns.length; i < ii; n++) { node = stableNodeList[n]; nodeLinkFn = linkFns[i++]; childLinkFn = linkFns[i++]; if (nodeLinkFn) { if (nodeLinkFn.scope) { childScope = scope.$new(isObject(nodeLinkFn.scope)); jqLite(node).data('$scope', childScope); } else { childScope = scope; } childTranscludeFn = nodeLinkFn.transclude; if (childTranscludeFn || (!boundTranscludeFn && transcludeFn)) { nodeLinkFn(childLinkFn, childScope, node, $rootElement, (function(transcludeFn) { return function(cloneFn) { var transcludeScope = scope.$new(); transcludeScope.$$transcluded = true; return transcludeFn(transcludeScope, cloneFn). on('$destroy', bind(transcludeScope, transcludeScope.$destroy)); }; })(childTranscludeFn || transcludeFn) ); } else { nodeLinkFn(childLinkFn, childScope, node, undefined, boundTranscludeFn); } } else if (childLinkFn) { childLinkFn(scope, node.childNodes, undefined, boundTranscludeFn); } } } }
javascript
{ "resource": "" }
q63194
groupElementsLinkFnWrapper
test
function groupElementsLinkFnWrapper(linkFn, attrStart, attrEnd) { return function(scope, element, attrs, controllers) { element = groupScan(element[0], attrStart, attrEnd); return linkFn(scope, element, attrs, controllers); } }
javascript
{ "resource": "" }
q63195
replaceWith
test
function replaceWith($rootElement, elementsToRemove, newNode) { var firstElementToRemove = elementsToRemove[0], removeCount = elementsToRemove.length, parent = firstElementToRemove.parentNode, i, ii; if ($rootElement) { for(i = 0, ii = $rootElement.length; i < ii; i++) { if ($rootElement[i] == firstElementToRemove) { $rootElement[i++] = newNode; for (var j = i, j2 = j + removeCount - 1, jj = $rootElement.length; j < jj; j++, j2++) { if (j2 < jj) { $rootElement[j] = $rootElement[j2]; } else { delete $rootElement[j]; } } $rootElement.length -= removeCount - 1; break; } } } if (parent) { parent.replaceChild(newNode, firstElementToRemove); } var fragment = document.createDocumentFragment(); fragment.appendChild(firstElementToRemove); newNode[jqLite.expando] = firstElementToRemove[jqLite.expando]; for (var k = 1, kk = elementsToRemove.length; k < kk; k++) { var element = elementsToRemove[k]; jqLite(element).remove(); // must do this way to clean up expando fragment.appendChild(element); delete elementsToRemove[k]; } elementsToRemove[0] = newNode; elementsToRemove.length = 1 }
javascript
{ "resource": "" }
q63196
arrayDeclaration
test
function arrayDeclaration () { var elementFns = []; var allConstant = true; if (peekToken().text != ']') { do { var elementFn = expression(); elementFns.push(elementFn); if (!elementFn.constant) { allConstant = false; } } while (expect(',')); } consume(']'); return extend(function(self, locals){ var array = []; for ( var i = 0; i < elementFns.length; i++) { array.push(elementFns[i](self, locals)); } return array; }, { literal:true, constant:allConstant }); }
javascript
{ "resource": "" }
q63197
isSameOrigin
test
function isSameOrigin(requestUrl) { var parsed = (typeof requestUrl === 'string') ? resolve(requestUrl, true) : requestUrl; return (parsed.protocol === originUrl.protocol && parsed.host === originUrl.host); }
javascript
{ "resource": "" }
q63198
traverse
test
function traverse(node, opt_onEnter, opt_onLeave) { if (opt_onEnter) opt_onEnter(node); var childNodes = _collectChildNodes(node); childNodes.forEach(function(childNode) { traverse(childNode, opt_onEnter, opt_onLeave); }); if (opt_onLeave) opt_onLeave(node); }
javascript
{ "resource": "" }
q63199
Client
test
function Client() { logger('new Client'); this.type = 'client'; this.id = uuid(); this.browser = (WebSocket.Server === undefined); Base.call(this); }
javascript
{ "resource": "" }