From 6f4d32dc3e1f2c9f5864e337f950dddb34b14771 Mon Sep 17 00:00:00 2001 From: Manuel Wiedenmann Date: Thu, 26 Oct 2023 16:38:28 +0200 Subject: [PATCH] Remove DS import in utils We now depend on `@ember-data/model/-private` for `ManyArray` and `PromiseManyArray` and do the ember-data feature detection by checking if `Model` from `@ember-data/model` is present. --- addon/utils/utils.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/addon/utils/utils.js b/addon/utils/utils.js index 9cc7baf7..de38c83b 100644 --- a/addon/utils/utils.js +++ b/addon/utils/utils.js @@ -4,6 +4,8 @@ import { isHTMLSafe } from '@ember/template'; import EmberObject from '@ember/object'; import { typeOf } from '@ember/utils'; import { A as emberArray } from '@ember/array'; + +// ember-data feature detection import require from 'require'; function requireModule(module, exportName = 'default') { @@ -12,9 +14,24 @@ function requireModule(module, exportName = 'default') { } } -const DS = requireModule('ember-data'); const Model = requireModule('@ember-data/model'); +const { ManyArray, PromiseManyArray } = requireModule( + '@ember-data/model/-private' +); + +export function isDsModel(o) { + return !!(Model && o && o instanceof Model); +} + +export function isDSManyArray(o) { + return !!( + Model && + o && + (o instanceof PromiseManyArray || o instanceof ManyArray) + ); +} +// ember internals export { getDependentKeys, isDescriptor } from '../-private/ember-internals'; export function unwrapString(s) { @@ -43,18 +60,6 @@ export function isPromise(p) { return !!(p && canInvoke(p, 'then')); } -export function isDsModel(o) { - return !!(Model && o && o instanceof Model); -} - -export function isDSManyArray(o) { - return !!( - DS && - o && - (o instanceof DS.PromiseManyArray || o instanceof DS.ManyArray) - ); -} - export function isEmberObject(o) { return !!(o && o instanceof EmberObject); }