@ember-data/store 4.0.0-beta.2 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,6 @@
2
2
  @module @ember-data/store
3
3
  */
4
4
  import { assert, warn } from '@ember/debug';
5
- import { assign } from '@ember/polyfills';
6
5
  import { DEBUG } from '@glimmer/env';
7
6
 
8
7
  import coerceId from '../system/coerce-id';
@@ -23,7 +22,6 @@ import type {
23
22
  import { DEBUG_CLIENT_ORIGINATED, DEBUG_IDENTIFIER_BUCKET } from '../ts-interfaces/identifier';
24
23
  import type { ConfidentDict } from '../ts-interfaces/utils';
25
24
  import isNonEmptyString from '../utils/is-non-empty-string';
26
- import { addSymbol } from '../utils/symbol';
27
25
  import isStableIdentifier, { markStableIdentifier, unmarkStableIdentifier } from './is-stable-identifier';
28
26
  import uuidv4 from './utils/uuid-v4';
29
27
 
@@ -372,7 +370,7 @@ export class IdentifierCache {
372
370
  // If the incoming type does not match the identifier type, we need to create an identifier for the incoming
373
371
  // data so we can merge the incoming data with the existing identifier, see #7325 and #7363
374
372
  if ('type' in data && data.type && identifier.type !== normalizeModelName(data.type)) {
375
- let incomingDataResource = assign({}, data);
373
+ let incomingDataResource = { ...data };
376
374
  // Need to strip the lid from the incomingData in order force a new identifier creation
377
375
  delete incomingDataResource.lid;
378
376
  existingIdentifier = this.getOrCreateRecordIdentifier(incomingDataResource);
@@ -511,8 +509,8 @@ function makeStableRecordIdentifier(
511
509
  return `${clientOriginated ? '[CLIENT_ORIGINATED] ' : ''}${type}:${id} (${lid})`;
512
510
  },
513
511
  };
514
- addSymbol(wrapper, DEBUG_CLIENT_ORIGINATED, clientOriginated);
515
- addSymbol(wrapper, DEBUG_IDENTIFIER_BUCKET, bucket);
512
+ wrapper[DEBUG_CLIENT_ORIGINATED] = clientOriginated;
513
+ wrapper[DEBUG_IDENTIFIER_BUCKET] = bucket;
516
514
  wrapper = freeze(wrapper);
517
515
  markStableIdentifier(wrapper);
518
516
  DEBUG_MAP.set(wrapper, recordIdentifier);
@@ -2,13 +2,6 @@
2
2
  @module @ember-data/store
3
3
  */
4
4
 
5
- // support IE11
6
- declare global {
7
- interface Window {
8
- msCrypto: Crypto;
9
- }
10
- }
11
-
12
5
  const CRYPTO = (() => {
13
6
  const hasWindow = typeof window !== 'undefined';
14
7
  const isFastBoot = typeof FastBoot !== 'undefined';
@@ -27,12 +20,6 @@ const CRYPTO = (() => {
27
20
  };
28
21
  } else if (hasWindow && typeof window.crypto !== 'undefined') {
29
22
  return window.crypto;
30
- } else if (
31
- hasWindow &&
32
- typeof window.msCrypto !== 'undefined' &&
33
- typeof window.msCrypto.getRandomValues === 'function'
34
- ) {
35
- return window.msCrypto;
36
23
  } else {
37
24
  throw new Error('ember-data: Cannot find a valid way to generate local identifiers');
38
25
  }
@@ -25,7 +25,6 @@ export { default as RootState } from './system/model/states';
25
25
  export { default as InternalModel } from './system/model/internal-model';
26
26
 
27
27
  export { PromiseArray, PromiseObject } from './system/promise-proxies';
28
- export { addSymbol, symbol } from './utils/symbol';
29
28
 
30
29
  export { RecordArray, AdapterPopulatedRecordArray } from './system/record-arrays';
31
30
 
@@ -5,7 +5,6 @@ import { getOwner } from '@ember/application';
5
5
  import { A } from '@ember/array';
6
6
  import { assert, deprecate, inspect, warn } from '@ember/debug';
7
7
  import { computed, defineProperty, get, set } from '@ember/object';
8
- import { assign } from '@ember/polyfills';
9
8
  import { _backburner as emberBackburner } from '@ember/runloop';
10
9
  import type { Backburner } from '@ember/runloop/-private/backburner';
11
10
  import Service from '@ember/service';
@@ -68,7 +67,6 @@ import type { FindOptions } from '../ts-interfaces/store';
68
67
  import type { Dict } from '../ts-interfaces/utils';
69
68
  import constructResource from '../utils/construct-resource';
70
69
  import promiseRecord from '../utils/promise-record';
71
- import { addSymbol } from '../utils/symbol';
72
70
  import edBackburner from './backburner';
73
71
  import coerceId, { ensureStringId } from './coerce-id';
74
72
  import { errorsArrayToHash } from './errors-utils';
@@ -646,7 +644,7 @@ abstract class CoreStore extends Service {
646
644
  return emberBackburner.join(() => {
647
645
  return this._backburner.join(() => {
648
646
  let normalizedModelName = normalizeModelName(modelName);
649
- let properties = assign({}, inputProperties);
647
+ let properties = { ...inputProperties };
650
648
 
651
649
  // If the passed properties do not include a primary key,
652
650
  // give the adapter an opportunity to generate one. Typically,
@@ -1280,7 +1278,7 @@ abstract class CoreStore extends Service {
1280
1278
  return Promise.resolve(internalModel);
1281
1279
  }
1282
1280
 
1283
- _findByInternalModel(internalModel, options: { preload?: any } = {}) {
1281
+ _findByInternalModel(internalModel: InternalModel, options: FindOptions = {}) {
1284
1282
  if (options.preload) {
1285
1283
  this._backburner.join(() => {
1286
1284
  internalModel.preloadData(options.preload);
@@ -1295,7 +1293,7 @@ abstract class CoreStore extends Service {
1295
1293
  );
1296
1294
  }
1297
1295
 
1298
- _findEmptyInternalModel(internalModel, options) {
1296
+ _findEmptyInternalModel(internalModel: InternalModel, options: FindOptions) {
1299
1297
  if (internalModel.currentState.isEmpty) {
1300
1298
  return this._scheduleFetch(internalModel, options);
1301
1299
  }
@@ -1307,9 +1305,9 @@ abstract class CoreStore extends Service {
1307
1305
  }
1308
1306
  } else {
1309
1307
  if (internalModel.currentState.isLoading) {
1310
- let pending = this._fetchManager.getPendingFetch(internalModel.identifier);
1311
- if (pending) {
1312
- return pending.then(() => Promise.resolve(internalModel));
1308
+ let pendingRequest = this._fetchManager.getPendingFetch(internalModel.identifier, options);
1309
+ if (pendingRequest) {
1310
+ return pendingRequest.then(() => Promise.resolve(internalModel));
1313
1311
  }
1314
1312
  return this._scheduleFetch(internalModel, options);
1315
1313
  }
@@ -1601,18 +1599,14 @@ abstract class CoreStore extends Service {
1601
1599
  groups = [snapshots];
1602
1600
  }
1603
1601
 
1604
- // we use var here because babel transpiles let
1605
- // in a manner that causes a mega-bad perf scenario here
1606
- // when targets no longer include IE11 we can drop this.
1607
- /* eslint-disable no-var */
1608
- for (var i = 0, l = groups.length; i < l; i++) {
1609
- var group = groups[i];
1610
- var totalInGroup = groups[i].length;
1611
- var ids = new Array(totalInGroup);
1612
- var groupedInternalModels = new Array(totalInGroup);
1602
+ for (let i = 0, l = groups.length; i < l; i++) {
1603
+ let group = groups[i];
1604
+ let totalInGroup = groups[i].length;
1605
+ let ids = new Array(totalInGroup);
1606
+ let groupedInternalModels = new Array(totalInGroup);
1613
1607
 
1614
- for (var j = 0; j < totalInGroup; j++) {
1615
- var internalModel = group[j]._internalModel;
1608
+ for (let j = 0; j < totalInGroup; j++) {
1609
+ let internalModel = group[j]._internalModel;
1616
1610
 
1617
1611
  groupedInternalModels[j] = internalModel;
1618
1612
  ids[j] = internalModel.id;
@@ -1629,7 +1623,7 @@ abstract class CoreStore extends Service {
1629
1623
  });
1630
1624
  })(groupedInternalModels);
1631
1625
  } else if (ids.length === 1) {
1632
- var pair = seeking[groupedInternalModels[0].id];
1626
+ let pair = seeking[groupedInternalModels[0].id];
1633
1627
  _fetchRecord(pair);
1634
1628
  } else {
1635
1629
  assert("You cannot return an empty array from adapter's method groupRecordsForFindMany");
@@ -2055,7 +2049,7 @@ abstract class CoreStore extends Service {
2055
2049
  if (internalModel) {
2056
2050
  // short circuit if we are already loading
2057
2051
  if (REQUEST_SERVICE) {
2058
- let pendingRequest = this._fetchManager.getPendingFetch(internalModel.identifier);
2052
+ let pendingRequest = this._fetchManager.getPendingFetch(internalModel.identifier, options);
2059
2053
  if (pendingRequest) {
2060
2054
  return pendingRequest.then(() => internalModel.getRecord());
2061
2055
  }
@@ -2087,6 +2081,10 @@ abstract class CoreStore extends Service {
2087
2081
  return resolve(null);
2088
2082
  }
2089
2083
 
2084
+ if (!internalModel) {
2085
+ assert(`No InternalModel found for ${resource.lid}`, internalModel);
2086
+ }
2087
+
2090
2088
  return this._findByInternalModel(internalModel, options);
2091
2089
  }
2092
2090
 
@@ -2714,7 +2712,7 @@ abstract class CoreStore extends Service {
2714
2712
  operation = 'deleteRecord';
2715
2713
  }
2716
2714
 
2717
- addSymbol(options, SaveOp, operation);
2715
+ options[SaveOp] = operation;
2718
2716
 
2719
2717
  let fetchManagerPromise = this._fetchManager.scheduleSave(internalModel.identifier, options);
2720
2718
  let promise = fetchManagerPromise.then(
@@ -2,7 +2,6 @@ import { getOwner, setOwner } from '@ember/application';
2
2
  import { assert, deprecate } from '@ember/debug';
3
3
  import EmberError from '@ember/error';
4
4
  import { get } from '@ember/object';
5
- import { assign } from '@ember/polyfills';
6
5
  import { isPresent } from '@ember/utils';
7
6
  import { DEBUG } from '@glimmer/env';
8
7
 
@@ -40,7 +39,7 @@ class Store extends CoreStore {
40
39
  _internalModel: internalModel,
41
40
  container: null,
42
41
  };
43
- assign(createOptions, createRecordArgs);
42
+ Object.assign(createOptions, createRecordArgs);
44
43
 
45
44
  // ensure that `getOwner(this)` works inside a model instance
46
45
  setOwner(createOptions, getOwner(this));
@@ -12,7 +12,6 @@ import type { CollectionResourceDocument, SingleResourceDocument } from '../ts-i
12
12
  import type { FindRecordQuery, Request, SaveRecordMutation } from '../ts-interfaces/fetch-manager';
13
13
  import type { ExistingRecordIdentifier, RecordIdentifier, StableRecordIdentifier } from '../ts-interfaces/identifier';
14
14
  import type { Dict } from '../ts-interfaces/utils';
15
- import { symbol } from '../utils/symbol';
16
15
  import coerceId from './coerce-id';
17
16
  import type CoreStore from './core-store';
18
17
  import { errorsArrayToHash } from './errors-utils';
@@ -30,7 +29,7 @@ function payloadIsNotBlank(adapterPayload): boolean {
30
29
  }
31
30
  }
32
31
 
33
- export const SaveOp: unique symbol = symbol('SaveOp');
32
+ export const SaveOp: unique symbol = Symbol('SaveOp');
34
33
 
35
34
  interface PendingFetchItem {
36
35
  identifier: ExistingRecordIdentifier;
@@ -502,10 +501,10 @@ export default class FetchManager {
502
501
  }
503
502
  }
504
503
 
505
- getPendingFetch(identifier: StableRecordIdentifier) {
506
- let pendingRequests = this.requestCache
507
- .getPendingRequestsForRecord(identifier)
508
- .filter((req) => req.type === 'query');
504
+ getPendingFetch(identifier: StableRecordIdentifier, options) {
505
+ let pendingRequests = this.requestCache.getPendingRequestsForRecord(identifier).filter((req) => {
506
+ return req.type === 'query' && isSameRequest(options, req.request.data[0].options);
507
+ });
509
508
 
510
509
  if (pendingRequests.length > 0) {
511
510
  return pendingRequests[0][RequestPromise];
@@ -533,3 +532,8 @@ function assertIsString(id: string | null): asserts id is string {
533
532
  }
534
533
  }
535
534
  }
535
+
536
+ // this function helps resolve whether we have a pending request that we should use instead
537
+ function isSameRequest(options: Dict<unknown> = {}, reqOptions: Dict<unknown> = {}) {
538
+ return options.include === reqOptions.include;
539
+ }
@@ -3,7 +3,6 @@ import { A, default as EmberArray } from '@ember/array';
3
3
  import { assert, inspect } from '@ember/debug';
4
4
  import EmberError from '@ember/error';
5
5
  import { get, set } from '@ember/object';
6
- import { assign } from '@ember/polyfills';
7
6
  import { _backburner as emberBackburner, cancel, run } from '@ember/runloop';
8
7
  import { DEBUG } from '@glimmer/env';
9
8
 
@@ -354,7 +353,7 @@ export default class InternalModel {
354
353
  }
355
354
 
356
355
  let additionalCreateOptions = this._recordData._initRecordCreateOptions(properties);
357
- assign(createOptions, additionalCreateOptions);
356
+ Object.assign(createOptions, additionalCreateOptions);
358
357
 
359
358
  // ensure that `getOwner(this)` works inside a model instance
360
359
  setOwner(createOptions, getOwner(store));
@@ -1456,15 +1455,11 @@ export function extractRecordDataFromRecord(recordOrPromiseRecord) {
1456
1455
  }
1457
1456
 
1458
1457
  function anyUnloaded(store: CoreStore, relationship: ManyRelationship) {
1459
- // Can't use `find` because of IE11 and these arrays are potentially massive
1460
1458
  let state = relationship.currentState;
1461
- let unloaded = false;
1462
- for (let i = 0; i < state.length; i++) {
1463
- let im = store._internalModelForResource(state[i]);
1464
- if (im._isDematerializing || !im.currentState.isLoaded) {
1465
- unloaded = true;
1466
- break;
1467
- }
1468
- }
1469
- return unloaded;
1459
+ const unloaded = state.find((s) => {
1460
+ let im = store._internalModelForResource(s);
1461
+ return im._isDematerializing || !im.currentState.isLoaded;
1462
+ });
1463
+
1464
+ return unloaded || false;
1470
1465
  }
@@ -5,7 +5,6 @@
5
5
  import { A } from '@ember/array';
6
6
  import { assert } from '@ember/debug';
7
7
  import { get, set } from '@ember/object';
8
- import { assign } from '@ember/polyfills';
9
8
  import { _backburner as emberBackburner } from '@ember/runloop';
10
9
 
11
10
  import { REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT } from '@ember-data/canary-features';
@@ -281,8 +280,8 @@ class RecordArrayManager {
281
280
  manager: this,
282
281
  isLoaded: true,
283
282
  isUpdating: false,
284
- meta: assign({}, payload.meta),
285
- links: assign({}, payload.links),
283
+ meta: { ...payload.meta },
284
+ links: { ...payload.links },
286
285
  });
287
286
 
288
287
  this._associateWithRecordArray(identifiers, array);
@@ -1,6 +1,5 @@
1
1
  import { A } from '@ember/array';
2
2
  import { get } from '@ember/object';
3
- import { assign } from '@ember/polyfills';
4
3
  import { once } from '@ember/runloop';
5
4
  import { DEBUG } from '@glimmer/env';
6
5
 
@@ -86,8 +85,8 @@ let AdapterPopulatedRecordArray = RecordArray.extend({
86
85
  this.setProperties({
87
86
  isLoaded: true,
88
87
  isUpdating: false,
89
- meta: assign({}, payload.meta),
90
- links: assign({}, payload.links),
88
+ meta: { ...payload.meta },
89
+ links: { ...payload.links },
91
90
  });
92
91
 
93
92
  this.manager._associateWithRecordArray(identifiersOrInternalModels, this);
@@ -7,10 +7,9 @@ import type {
7
7
  } from '../ts-interfaces/fetch-manager';
8
8
  import { RequestStateEnum } from '../ts-interfaces/fetch-manager';
9
9
  import type { RecordIdentifier } from '../ts-interfaces/identifier';
10
- import { addSymbol, symbol } from '../utils/symbol';
11
10
 
12
- const Touching: unique symbol = symbol('touching');
13
- export const RequestPromise: unique symbol = symbol('promise');
11
+ const Touching: unique symbol = Symbol('touching');
12
+ export const RequestPromise: unique symbol = Symbol('promise');
14
13
 
15
14
  interface InternalRequest extends RequestState {
16
15
  [Touching]: RecordIdentifier[];
@@ -41,8 +40,8 @@ export default class RequestCache {
41
40
  request: queryRequest,
42
41
  type,
43
42
  } as InternalRequest;
44
- addSymbol(request, Touching, [query.recordIdentifier]);
45
- addSymbol(request, RequestPromise, promise);
43
+ request[Touching] = [query.recordIdentifier];
44
+ request[RequestPromise] = promise;
46
45
  this._pending[lid].push(request);
47
46
  this._triggerSubscriptions(request);
48
47
  promise.then(
@@ -54,7 +53,7 @@ export default class RequestCache {
54
53
  type,
55
54
  response: { data: result },
56
55
  } as InternalRequest;
57
- addSymbol(finalizedRequest, Touching, request[Touching]);
56
+ finalizedRequest[Touching] = request[Touching];
58
57
  this._addDone(finalizedRequest);
59
58
  this._triggerSubscriptions(finalizedRequest);
60
59
  },
@@ -66,7 +65,7 @@ export default class RequestCache {
66
65
  type,
67
66
  response: { data: error && error.error },
68
67
  } as InternalRequest;
69
- addSymbol(finalizedRequest, Touching, request[Touching]);
68
+ finalizedRequest[Touching] = request[Touching];
70
69
  this._addDone(finalizedRequest);
71
70
  this._triggerSubscriptions(finalizedRequest);
72
71
  }
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import { assert } from '@ember/debug';
5
5
  import { get } from '@ember/object';
6
- import { assign } from '@ember/polyfills';
7
6
 
8
7
  import { CUSTOM_MODEL_CLASS } from '@ember-data/canary-features';
9
8
  import { HAS_RECORD_DATA_PACKAGE } from '@ember-data/private-build-infra';
@@ -234,7 +233,7 @@ export default class Snapshot implements Snapshot {
234
233
  @public
235
234
  */
236
235
  attributes(): Dict<unknown> {
237
- return assign({}, this._attributes);
236
+ return { ...this._attributes };
238
237
  }
239
238
 
240
239
  /**
@@ -1,5 +1,4 @@
1
1
  import { assert, deprecate, warn } from '@ember/debug';
2
- import { assign } from '@ember/polyfills';
3
2
  import { DEBUG } from '@glimmer/env';
4
3
 
5
4
  import { Promise } from 'rsvp';
@@ -274,18 +273,12 @@ function fixRelationshipData(relationshipData, relationshipKind, { id, modelName
274
273
  if (relationshipKind === 'hasMany') {
275
274
  payload = relationshipData || [];
276
275
  if (relationshipData) {
277
- // IE11 does not support array.find
278
276
  // these arrays could be massive so this is better than filter
279
277
  // Note: this is potentially problematic if type/id are not in the
280
278
  // same state of normalization.
281
- let found = false;
282
- for (let i = 0; i < relationshipData.length; i++) {
283
- let v = relationshipData[i];
284
- if (v.type === parentRelationshipData.type && v.id === parentRelationshipData.id) {
285
- found = true;
286
- break;
287
- }
288
- }
279
+ let found = relationshipData.find((v) => {
280
+ return v.type === parentRelationshipData.type && v.id === parentRelationshipData.id;
281
+ });
289
282
  if (!found) {
290
283
  payload.push(parentRelationshipData);
291
284
  }
@@ -294,7 +287,7 @@ function fixRelationshipData(relationshipData, relationshipKind, { id, modelName
294
287
  }
295
288
  } else {
296
289
  payload = relationshipData || {};
297
- assign(payload, parentRelationshipData);
290
+ Object.assign(payload, parentRelationshipData);
298
291
  }
299
292
 
300
293
  return payload;
@@ -1,7 +1,11 @@
1
+ import type { Dict } from '@ember-data/store/-private/ts-interfaces/utils';
2
+
1
3
  import type { RecordIdentifier } from './identifier';
2
4
 
3
5
  export interface Operation {
4
6
  op: string;
7
+ options: Dict<unknown> | undefined;
8
+ recordIdentifier: RecordIdentifier;
5
9
  }
6
10
 
7
11
  export interface FindRecordQuery extends Operation {
@@ -1,15 +1,14 @@
1
1
  /**
2
2
  @module @ember-data/store
3
3
  */
4
- import { symbol } from '../utils/symbol';
5
4
  import type { ExistingResourceObject, ResourceIdentifierObject } from './ember-data-json-api';
6
5
 
7
6
  export type ResourceData = ResourceIdentifierObject | ExistingResourceObject;
8
7
  export type IdentifierBucket = 'record';
9
8
 
10
9
  // provided for additional debuggability
11
- export const DEBUG_CLIENT_ORIGINATED: unique symbol = symbol('record-originated-on-client');
12
- export const DEBUG_IDENTIFIER_BUCKET: unique symbol = symbol('identifier-bucket');
10
+ export const DEBUG_CLIENT_ORIGINATED: unique symbol = Symbol('record-originated-on-client');
11
+ export const DEBUG_IDENTIFIER_BUCKET: unique symbol = Symbol('identifier-bucket');
13
12
 
14
13
  export interface Identifier {
15
14
  lid: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ember-data/store",
3
- "version": "4.0.0-beta.2",
3
+ "version": "4.0.1",
4
4
  "description": "The default blueprint for ember-cli addons.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -17,22 +17,22 @@
17
17
  "start": "ember serve"
18
18
  },
19
19
  "dependencies": {
20
- "@ember-data/canary-features": "4.0.0-beta.2",
21
- "@ember-data/private-build-infra": "4.0.0-beta.2",
20
+ "@ember-data/canary-features": "4.0.1",
21
+ "@ember-data/private-build-infra": "4.0.1",
22
22
  "@ember/string": "^3.0.0",
23
23
  "@glimmer/tracking": "^1.0.4",
24
+ "ember-auto-import": "^2.2.4",
24
25
  "ember-cli-babel": "^7.26.6",
25
26
  "ember-cli-path-utils": "^1.0.0",
26
27
  "ember-cli-typescript": "^4.1.0"
27
28
  },
28
29
  "devDependencies": {
29
- "@ember-data/unpublished-test-infra": "4.0.0-beta.2",
30
+ "@ember-data/unpublished-test-infra": "4.0.1",
30
31
  "@ember/optional-features": "^2.0.0",
31
- "@ember/test-helpers": "^2.2.5",
32
+ "@ember/test-helpers": "^2.6.0",
32
33
  "@types/ember": "^3.16.5",
33
34
  "@types/rsvp": "^4.0.3",
34
35
  "broccoli-asset-rev": "^3.0.0",
35
- "ember-auto-import": "^2.0.0",
36
36
  "ember-cli": "~3.26.1",
37
37
  "ember-cli-dependency-checker": "^3.2.0",
38
38
  "ember-cli-htmlbars": "^5.1.2",
@@ -43,9 +43,9 @@
43
43
  "ember-export-application-global": "^2.0.1",
44
44
  "ember-load-initializers": "^2.1.1",
45
45
  "ember-maybe-import-regenerator": "^0.1.6",
46
- "ember-qunit": "^5.1.4",
46
+ "ember-qunit": "^5.1.5",
47
47
  "ember-resolver": "^8.0.0",
48
- "ember-source": "~3.27.1",
48
+ "ember-source": "~4.0.0",
49
49
  "ember-source-channel-url": "^3.0.0",
50
50
  "ember-try": "^1.4.0",
51
51
  "loader.js": "^4.7.0",
@@ -1,33 +0,0 @@
1
- /**
2
- @module @ember-data/store
3
- */
4
-
5
- /**
6
- * This symbol provides a Symbol replacement for browsers that do not have it
7
- * (eg. IE 11).
8
- *
9
- * The replacement is different from the native Symbol in some ways. It is a
10
- * function that produces an output:
11
- * - iterable;
12
- * - that is a string, not a symbol.
13
- *
14
- * @internal
15
- */
16
- export const symbol =
17
- typeof Symbol !== 'undefined'
18
- ? Symbol
19
- : (key: string) => `__${key}${Math.floor(Math.random() * Date.now())}__` as any;
20
-
21
- export function addSymbol(obj: object, symbol: Symbol | string, value: any): void {
22
- if (typeof symbol === 'string') {
23
- Object.defineProperty(obj, symbol, {
24
- value,
25
- configurable: false,
26
- enumerable: false,
27
- writable: false,
28
- });
29
- } else {
30
- // Typescript doesn't allow Symbol as an index type
31
- obj[symbol as unknown as string] = value;
32
- }
33
- }