@converse/skeletor 4.0.1 → 4.0.2
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.
- package/CHANGES.md +14 -0
- package/dist/skeletor.d.ts +19 -16
- package/dist/skeletor.esm.js +4 -19
- package/dist/skeletor.esm.js.map +1 -1
- package/dist/skeletor.js +4 -19
- package/dist/skeletor.js.map +1 -1
- package/dist/skeletor.min.js +1 -1
- package/dist/skeletor.node.d.ts +19 -16
- package/dist/skeletor.node.js +4 -19
- package/dist/skeletor.node.mjs +4 -19
- package/package.json +3 -10
- package/src/collection.ts +21 -25
- package/src/types.ts +5 -6
package/dist/skeletor.js
CHANGED
|
@@ -11683,6 +11683,7 @@
|
|
|
11683
11683
|
* belonging to this particular author, and so on. Collections maintain
|
|
11684
11684
|
* indexes of their models, both in order, and for lookup by `id`.
|
|
11685
11685
|
*/
|
|
11686
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -- see the interface above
|
|
11686
11687
|
class Collection extends EventEmitterObject {
|
|
11687
11688
|
/**
|
|
11688
11689
|
* Create a new **Collection**, perhaps to contain a specific type of `model`.
|
|
@@ -11700,7 +11701,7 @@
|
|
|
11700
11701
|
options = options || {};
|
|
11701
11702
|
this.preinitialize.apply(this, arguments);
|
|
11702
11703
|
if (options.model)
|
|
11703
|
-
this.
|
|
11704
|
+
this.model = options.model;
|
|
11704
11705
|
if (options.comparator !== undefined)
|
|
11705
11706
|
this.comparator = options.comparator;
|
|
11706
11707
|
this._reset();
|
|
@@ -11715,12 +11716,6 @@
|
|
|
11715
11716
|
this.hydrated = getStorage(this) ? hydrate(this) : Promise.resolve();
|
|
11716
11717
|
}
|
|
11717
11718
|
}
|
|
11718
|
-
get comparator() {
|
|
11719
|
-
return this._comparator;
|
|
11720
|
-
}
|
|
11721
|
-
set comparator(c) {
|
|
11722
|
-
this._comparator = c;
|
|
11723
|
-
}
|
|
11724
11719
|
/**
|
|
11725
11720
|
* The canonical storage accessor. Set to a `PersistentStorage` instance
|
|
11726
11721
|
* to enable local persistence for this collection.
|
|
@@ -11756,16 +11751,6 @@
|
|
|
11756
11751
|
get autoSync() {
|
|
11757
11752
|
return false;
|
|
11758
11753
|
}
|
|
11759
|
-
/**
|
|
11760
|
-
* The default model for a collection is just a **Model**.
|
|
11761
|
-
* This should be overridden in most cases.
|
|
11762
|
-
*/
|
|
11763
|
-
get model() {
|
|
11764
|
-
return this._model ?? Model;
|
|
11765
|
-
}
|
|
11766
|
-
set model(model) {
|
|
11767
|
-
this._model = model;
|
|
11768
|
-
}
|
|
11769
11754
|
get length() {
|
|
11770
11755
|
return this.models.length;
|
|
11771
11756
|
}
|
|
@@ -12269,7 +12254,7 @@
|
|
|
12269
12254
|
* Define how to uniquely identify models in the collection.
|
|
12270
12255
|
*/
|
|
12271
12256
|
modelId(attrs) {
|
|
12272
|
-
return attrs[this.model.prototype?.idAttribute || 'id'];
|
|
12257
|
+
return attrs[(this.model ?? Model).prototype?.idAttribute || 'id'];
|
|
12273
12258
|
}
|
|
12274
12259
|
/** Get an iterator of all models in this collection. */
|
|
12275
12260
|
values() {
|
|
@@ -12292,7 +12277,7 @@
|
|
|
12292
12277
|
this._byId = {};
|
|
12293
12278
|
}
|
|
12294
12279
|
createModel(attrs, options) {
|
|
12295
|
-
const Klass = this.model;
|
|
12280
|
+
const Klass = this.model ?? Model;
|
|
12296
12281
|
return new Klass(attrs, options);
|
|
12297
12282
|
}
|
|
12298
12283
|
/**
|