miolo-model 3.0.0-beta.227 → 3.0.0-beta.229
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/package.json +1 -1
- package/src/MioloArray.mjs +60 -5
package/package.json
CHANGED
package/src/MioloArray.mjs
CHANGED
|
@@ -23,10 +23,6 @@ export default class MioloArray extends Array {
|
|
|
23
23
|
|
|
24
24
|
this.reset_cache()
|
|
25
25
|
|
|
26
|
-
if (typeof items === "number") {
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
|
|
30
26
|
// Check properties
|
|
31
27
|
if (!itemClass) {
|
|
32
28
|
console.error(`[${this.constructor.name}] MioloArray received no itemClass`)
|
|
@@ -35,6 +31,10 @@ export default class MioloArray extends Array {
|
|
|
35
31
|
/** @type {new (...args: any[]) => T} */
|
|
36
32
|
this.itemClass = itemClass
|
|
37
33
|
|
|
34
|
+
if (typeof items === "number") {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
|
|
38
38
|
items.forEach((r, index) => {
|
|
39
39
|
this[index] =
|
|
40
40
|
r !== undefined && r instanceof this.itemClass ? r : new this.itemClass(r || {}, ...extra)
|
|
@@ -178,7 +178,7 @@ export default class MioloArray extends Array {
|
|
|
178
178
|
/**
|
|
179
179
|
* Find the index of the first item in the array that has the given field and value.
|
|
180
180
|
* @param {string} field - The field to search for.
|
|
181
|
-
* @param {
|
|
181
|
+
* @param {any} value - The value to search for.
|
|
182
182
|
* @returns {number} The index of the first item that has the given field and value, or -1 if not found.
|
|
183
183
|
* @public
|
|
184
184
|
*/
|
|
@@ -311,4 +311,59 @@ export default class MioloArray extends Array {
|
|
|
311
311
|
// Object.assign(clone, this)
|
|
312
312
|
return clone
|
|
313
313
|
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @param {(value: T, index: number, array: Array<T>) => boolean} predicate
|
|
317
|
+
* @param {any} [thisArg]
|
|
318
|
+
* @returns {this}
|
|
319
|
+
*/
|
|
320
|
+
// @ts-expect-error
|
|
321
|
+
filter(predicate, thisArg) {
|
|
322
|
+
// @ts-expect-error
|
|
323
|
+
return super.filter(predicate, thisArg)
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* @template U
|
|
328
|
+
* @param {(value: T, index: number, array: Array<T>) => U} callbackfn
|
|
329
|
+
* @param {any} [thisArg]
|
|
330
|
+
* @returns {Array<U>}
|
|
331
|
+
*/
|
|
332
|
+
map(callbackfn, thisArg) {
|
|
333
|
+
return super.map(callbackfn, thisArg)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* @param {number} [start]
|
|
338
|
+
* @param {number} [end]
|
|
339
|
+
* @returns {this}
|
|
340
|
+
*/
|
|
341
|
+
// @ts-expect-error
|
|
342
|
+
slice(start, end) {
|
|
343
|
+
// @ts-expect-error
|
|
344
|
+
return super.slice(start, end)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @param {number} start
|
|
349
|
+
* @param {number} [deleteCount]
|
|
350
|
+
* @param {...T} items
|
|
351
|
+
* @returns {this}
|
|
352
|
+
*/
|
|
353
|
+
// @ts-expect-error
|
|
354
|
+
// biome-ignore lint/correctness/noUnusedFunctionParameters: its ok
|
|
355
|
+
splice(start, deleteCount, ...items) {
|
|
356
|
+
// @ts-expect-error
|
|
357
|
+
// biome-ignore lint/complexity/noArguments: its ok
|
|
358
|
+
return super.splice.apply(this, arguments)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @returns {this}
|
|
363
|
+
*/
|
|
364
|
+
// @ts-expect-error
|
|
365
|
+
reverse() {
|
|
366
|
+
// @ts-expect-error
|
|
367
|
+
return super.reverse()
|
|
368
|
+
}
|
|
314
369
|
}
|