diff options
author | Marius David Wieschollek <passwords.public@mdns.eu> | 2020-12-02 02:09:25 +0300 |
---|---|---|
committer | Marius David Wieschollek <passwords.public@mdns.eu> | 2020-12-02 02:09:25 +0300 |
commit | 277f5a1571a1a839d4f000a8ef65e35cba5b05ce (patch) | |
tree | fca78bd10526c8b1dc62d51252dd4ca0e26ac6e0 /src/Collection/AbstractCollection.js | |
parent | 16ac1f3d221b49b09001bda1d5f1194c5a7cafdd (diff) |
Add model service and support for detail levels
Signed-off-by: Marius David Wieschollek <passwords.public@mdns.eu>
Diffstat (limited to 'src/Collection/AbstractCollection.js')
-rw-r--r-- | src/Collection/AbstractCollection.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/Collection/AbstractCollection.js b/src/Collection/AbstractCollection.js index 662abbc..41acbd5 100644 --- a/src/Collection/AbstractCollection.js +++ b/src/Collection/AbstractCollection.js @@ -15,8 +15,6 @@ export default class AbstractCollection { * @param {AbstractModel} elements */ constructor(converter, ...elements) { - this._index = 0; - /** @type AbstractConverter **/ this._converter = converter; @@ -84,6 +82,15 @@ export default class AbstractCollection { } /** + * + * @param {(AbstractModel|AbstractModel[])} elements + */ + replaceAll(...elements) { + /** @type AbstractModel[] **/ + this._elements = this._getParamArray(elements); + } + + /** * @param {(String|Object|AbstractModel)} element * @private */ @@ -144,18 +151,19 @@ export default class AbstractCollection { } [Symbol.iterator]() { + let index = 0; return { /** * @return {{value: AbstractModel, done: boolean}|{done: boolean}} */ next: () => { - if(this._index < this._elements.length) { + if(index < this._elements.length) { return { - value: this._elements[this._index++], + value: this._elements[index++], done : false }; } else { - this._index = 0; + index = 0; return {done: true}; } } |