mutts 1.0.2 → 1.0.4

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.
Files changed (104) hide show
  1. package/README.md +14 -6
  2. package/dist/chunks/{_tslib-C-cuVLvZ.js → _tslib-BgjropY9.js} +9 -1
  3. package/dist/chunks/_tslib-BgjropY9.js.map +1 -0
  4. package/dist/chunks/{_tslib-CMEnd0VE.esm.js → _tslib-Mzh1rNsX.esm.js} +9 -2
  5. package/dist/chunks/_tslib-Mzh1rNsX.esm.js.map +1 -0
  6. package/dist/chunks/{decorator-D4DU97Zg.js → decorator-DLvrD0UF.js} +42 -19
  7. package/dist/chunks/decorator-DLvrD0UF.js.map +1 -0
  8. package/dist/chunks/{decorator-GnHw1Az7.esm.js → decorator-DqiszP7i.esm.js} +42 -19
  9. package/dist/chunks/decorator-DqiszP7i.esm.js.map +1 -0
  10. package/dist/chunks/index-79Kk8D6e.esm.js +4857 -0
  11. package/dist/chunks/index-79Kk8D6e.esm.js.map +1 -0
  12. package/dist/chunks/index-GRBSx0mB.js +4908 -0
  13. package/dist/chunks/index-GRBSx0mB.js.map +1 -0
  14. package/dist/decorator.esm.js +1 -1
  15. package/dist/decorator.js +1 -1
  16. package/dist/destroyable.d.ts +1 -1
  17. package/dist/destroyable.esm.js +1 -1
  18. package/dist/destroyable.esm.js.map +1 -1
  19. package/dist/destroyable.js +1 -1
  20. package/dist/destroyable.js.map +1 -1
  21. package/dist/devtools/devtools.html +9 -0
  22. package/dist/devtools/devtools.js +5 -0
  23. package/dist/devtools/devtools.js.map +1 -0
  24. package/dist/devtools/manifest.json +8 -0
  25. package/dist/devtools/panel.css +72 -0
  26. package/dist/devtools/panel.html +31 -0
  27. package/dist/devtools/panel.js +13048 -0
  28. package/dist/devtools/panel.js.map +1 -0
  29. package/dist/eventful.esm.js +1 -1
  30. package/dist/eventful.js +1 -1
  31. package/dist/index.d.ts +18 -63
  32. package/dist/index.esm.js +4 -4
  33. package/dist/index.js +37 -11
  34. package/dist/index.js.map +1 -1
  35. package/dist/indexable.d.ts +187 -1
  36. package/dist/indexable.esm.js +197 -3
  37. package/dist/indexable.esm.js.map +1 -1
  38. package/dist/indexable.js +198 -2
  39. package/dist/indexable.js.map +1 -1
  40. package/dist/mutts.umd.js +1 -1
  41. package/dist/mutts.umd.js.map +1 -1
  42. package/dist/mutts.umd.min.js +1 -1
  43. package/dist/mutts.umd.min.js.map +1 -1
  44. package/dist/promiseChain.esm.js.map +1 -1
  45. package/dist/promiseChain.js.map +1 -1
  46. package/dist/reactive.d.ts +602 -97
  47. package/dist/reactive.esm.js +3 -3
  48. package/dist/reactive.js +32 -10
  49. package/dist/reactive.js.map +1 -1
  50. package/dist/std-decorators.esm.js +1 -1
  51. package/dist/std-decorators.js +1 -1
  52. package/docs/ai/api-reference.md +133 -0
  53. package/docs/ai/manual.md +105 -0
  54. package/docs/iterableWeak.md +646 -0
  55. package/docs/reactive/advanced.md +1280 -0
  56. package/docs/reactive/collections.md +767 -0
  57. package/docs/reactive/core.md +973 -0
  58. package/docs/reactive.md +21 -9545
  59. package/package.json +18 -5
  60. package/src/decorator.ts +266 -0
  61. package/src/destroyable.ts +199 -0
  62. package/src/eventful.ts +77 -0
  63. package/src/index.d.ts +9 -0
  64. package/src/index.ts +9 -0
  65. package/src/indexable.ts +484 -0
  66. package/src/introspection.ts +59 -0
  67. package/src/iterableWeak.ts +233 -0
  68. package/src/mixins.ts +123 -0
  69. package/src/promiseChain.ts +110 -0
  70. package/src/reactive/array.ts +414 -0
  71. package/src/reactive/change.ts +134 -0
  72. package/src/reactive/debug.ts +517 -0
  73. package/src/reactive/deep-touch.ts +268 -0
  74. package/src/reactive/deep-watch-state.ts +82 -0
  75. package/src/reactive/deep-watch.ts +168 -0
  76. package/src/reactive/effect-context.ts +94 -0
  77. package/src/reactive/effects.ts +1345 -0
  78. package/src/reactive/index.ts +76 -0
  79. package/src/reactive/interface.ts +223 -0
  80. package/src/reactive/map.ts +171 -0
  81. package/src/reactive/mapped.ts +130 -0
  82. package/src/reactive/memoize.ts +107 -0
  83. package/src/reactive/non-reactive-state.ts +49 -0
  84. package/src/reactive/non-reactive.ts +43 -0
  85. package/src/reactive/project.project.md +93 -0
  86. package/src/reactive/project.ts +335 -0
  87. package/src/reactive/proxy-state.ts +27 -0
  88. package/src/reactive/proxy.ts +289 -0
  89. package/src/reactive/record.ts +196 -0
  90. package/src/reactive/register.ts +421 -0
  91. package/src/reactive/set.ts +144 -0
  92. package/src/reactive/tracking.ts +101 -0
  93. package/src/reactive/types.ts +358 -0
  94. package/src/reactive/zone.ts +208 -0
  95. package/src/std-decorators.ts +217 -0
  96. package/src/utils.ts +117 -0
  97. package/dist/chunks/_tslib-C-cuVLvZ.js.map +0 -1
  98. package/dist/chunks/_tslib-CMEnd0VE.esm.js.map +0 -1
  99. package/dist/chunks/decorator-D4DU97Zg.js.map +0 -1
  100. package/dist/chunks/decorator-GnHw1Az7.esm.js.map +0 -1
  101. package/dist/chunks/index-DBScoeCX.esm.js +0 -1960
  102. package/dist/chunks/index-DBScoeCX.esm.js.map +0 -1
  103. package/dist/chunks/index-DOTmXL89.js +0 -1983
  104. package/dist/chunks/index-DOTmXL89.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { _ as __classPrivateFieldGet } from './chunks/_tslib-CMEnd0VE.esm.js';
1
+ import { _ as __classPrivateFieldGet } from './chunks/_tslib-Mzh1rNsX.esm.js';
2
2
 
3
3
  var _Eventful_events, _Eventful_hooks;
4
4
  /**
package/dist/eventful.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var _tslib = require('./chunks/_tslib-C-cuVLvZ.js');
3
+ var _tslib = require('./chunks/_tslib-BgjropY9.js');
4
4
 
5
5
  var _Eventful_events, _Eventful_hooks;
6
6
  /**
package/dist/index.d.ts CHANGED
@@ -1,64 +1,19 @@
1
- export { Decorator, DecoratorDescription, DecoratorError, DecoratorFactory, GenericClassDecorator, LegacyClassDecorator, LegacyPropertyDecorator, ModernAccessorDecorator, ModernClassDecorator, ModernGetterDecorator, ModernMethodDecorator, ModernSetterDecorator, decorator, legacyDecorator, modernDecorator } from './decorator.js';
2
- export { ContextManager, Destroyable, DestructionError, allocated, allocatedValues, callOnGC, destructor } from './destroyable.js';
3
- export { Eventful, EventsBase } from './eventful.js';
4
- export { Indexable, getAt, setAt } from './indexable.js';
5
- export { Evolution, Reactive, ReactiveBase, ReactiveError, ScopedCallback, activeEffect, addBatchCleanup, atomic, cleanedBy, computed, effect, getState, immutables, invalidateComputed, isNonReactive, isReactive, profileInfo, reactive, reactiveOptions, trackEffect, unreactive, untracked, unwrap, watch } from './reactive.js';
6
- export { cache, cached, debounce, deprecated, describe, isCached, throttle } from './std-decorators.js';
1
+ export * from './decorator.js'
2
+ export * from './destroyable.js'
3
+ export * from './eventful.js'
4
+ export * from './indexable.js'
5
+ export * from './iterableWeak.js'
6
+ export * from './mixins.js'
7
+ export * from './reactive.js'
8
+ export * from './std-decorators.js'
9
+ export * from './utils.js'
7
10
 
8
- /**
9
- * A mixin function that takes a base class and returns a new class with mixed-in functionality
10
- * @template Mixed - The functionality to be mixed in
11
- */
12
- type MixinFunction<Mixed> = <Base>(base: new (...args: any[]) => Base) => new (...args: any[]) => Base & Mixed;
13
- /**
14
- * A mixin class that can be used both as a base class and as a mixin function
15
- * @template Mixed - The functionality to be mixed in
16
- */
17
- type MixinClass<Mixed> = new (...args: any[]) => Mixed;
18
- /**
19
- * Creates a mixin that can be used both as a class (extends) and as a function (mixin)
20
- *
21
- * This function supports:
22
- * - Using mixins as base classes: `class MyClass extends MyMixin`
23
- * - Using mixins as functions: `class MyClass extends MyMixin(SomeBase)`
24
- * - Composing mixins: `const Composed = MixinA(MixinB)`
25
- * - Type-safe property inference for all patterns
26
- *
27
- * @param mixinFunction - The function that creates the mixin
28
- * @param unwrapFunction - Optional function to unwrap reactive objects for method calls
29
- * @returns A mixin that can be used both as a class and as a function
30
- */
31
- declare function mixin<MixinFn extends (base: any) => new (...args: any[]) => any>(mixinFunction: MixinFn, unwrapFunction?: (obj: any) => any): (new (...args: any[]) => InstanceType<ReturnType<MixinFn>>) & (<Base>(base: abstract new (...args: any[]) => Base) => new (...args: any[]) => InstanceType<ReturnType<MixinFn>> & Base);
32
-
33
- type ElementTypes<T extends readonly unknown[]> = {
34
- [K in keyof T]: T[K] extends readonly (infer U)[] ? U : T[K];
35
- };
36
- /**
37
- * Combines multiple arrays into an array of tuples, stopping at the shortest array length
38
- * @param args - Arrays to zip together
39
- * @returns Array of tuples containing elements from each input array
40
- */
41
- declare function zip<T extends (readonly unknown[])[]>(...args: T): ElementTypes<T>[];
42
- /**
43
- * Checks if a function is a constructor (class or constructor function)
44
- * @param fn - The function to check
45
- * @returns True if the function is a constructor
46
- */
47
- declare function isConstructor(fn: Function): boolean;
48
- /**
49
- * Renames a function with a new name
50
- * @param fct - The function to rename
51
- * @param name - The new name for the function
52
- * @returns The function with the new name
53
- */
54
- declare function renamed<F extends Function>(fct: F, name: string): F;
55
- declare function ReflectGet(obj: any, prop: any, receiver: any): any;
56
- declare function ReflectSet(obj: any, prop: any, value: any, receiver: any): any;
57
- declare function isOwnAccessor(obj: any, prop: any): boolean;
58
- /**
59
- * Check if an object is an object (not null, not primitive)
60
- */
61
- declare function isObject(obj: any): obj is object;
62
-
63
- export { ReflectGet, ReflectSet, isConstructor, isObject, isOwnAccessor, mixin, renamed, zip };
64
- export type { MixinClass, MixinFunction };
11
+ // Augment Array.isArray to properly handle readonly arrays in type narrowing
12
+ interface ArrayConstructor {
13
+ /**
14
+ * Determines whether an object is an array.
15
+ * @param arg Any value to test.
16
+ * @returns True if the value is an array (mutable or readonly), false otherwise.
17
+ */
18
+ isArray(arg: any): arg is any[] | readonly any[]
19
+ }
package/dist/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
- export { D as DecoratorError, R as ReflectGet, a as ReflectSet, d as decorator, i as isConstructor, c as isObject, b as isOwnAccessor, l as legacyDecorator, m as modernDecorator, r as renamed, z as zip } from './chunks/decorator-GnHw1Az7.esm.js';
1
+ export { D as DecoratorError, R as ReflectGet, b as ReflectSet, a as arrayEquals, d as decorator, i as isConstructor, c as isOwnAccessor, l as legacyDecorator, m as modernDecorator, r as renamed, z as zip } from './chunks/decorator-DqiszP7i.esm.js';
2
2
  export { Destroyable, DestructionError, allocated, allocatedValues, callOnGC, destructor } from './destroyable.esm.js';
3
3
  export { Eventful } from './eventful.esm.js';
4
- export { Indexable, getAt, setAt } from './indexable.esm.js';
5
- export { R as Reactive, h as ReactiveBase, j as ReactiveError, a as activeEffect, b as addBatchCleanup, c as atomic, l as cleanedBy, n as computed, e as effect, g as getState, i as immutables, q as invalidateComputed, d as isNonReactive, f as isReactive, m as mixin, p as profileInfo, r as reactive, o as reactiveOptions, t as trackEffect, s as unreactive, u as untracked, k as unwrap, w as watch } from './chunks/index-DBScoeCX.esm.js';
4
+ export { ArrayReadForward, Indexable, forwardArray, getAt, setAt } from './indexable.esm.js';
5
+ export { I as IterableWeakMap, a as IterableWeakSet, M as ReactiveBase, V as ReactiveError, R as ReadOnlyError, S as Register, j as addBatchCleanup, k as atomic, l as batch, n as biDi, c as buildReactivityGraph, y as cleanedBy, z as cleanup, h as deepWatch, o as defer, A as derived, q as effect, e as enableDevTools, u as getActiveEffect, g as getState, G as immutables, i as isDevtoolsEnabled, H as isNonReactive, L as isReactive, W as isZoneEnabled, D as mapped, F as memoize, m as mixin, P as organize, Q as organized, p as profileInfo, K as project, N as reactive, U as reactiveOptions, E as reduced, T as register, r as registerEffectForDebug, J as registerNativeReactivity, d as registerObjectForDebug, v as root, s as setEffectName, f as setObjectName, X as setZoneEnabled, t as touched, b as touched1, w as trackEffect, B as unreactive, x as untracked, O as unwrap, C as watch } from './chunks/index-79Kk8D6e.esm.js';
6
6
  export { cache, cached, debounce, deprecated, describe, isCached, throttle } from './std-decorators.esm.js';
7
- import './chunks/_tslib-CMEnd0VE.esm.js';
7
+ import './chunks/_tslib-Mzh1rNsX.esm.js';
8
8
  //# sourceMappingURL=index.esm.js.map
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var decorator = require('./chunks/decorator-D4DU97Zg.js');
3
+ var decorator = require('./chunks/decorator-DLvrD0UF.js');
4
4
  var destroyable = require('./destroyable.js');
5
5
  var eventful = require('./eventful.js');
6
6
  var indexable = require('./indexable.js');
7
- var reactive = require('./chunks/index-DOTmXL89.js');
7
+ var reactive = require('./chunks/index-GRBSx0mB.js');
8
8
  var stdDecorators = require('./std-decorators.js');
9
- require('./chunks/_tslib-C-cuVLvZ.js');
9
+ require('./chunks/_tslib-BgjropY9.js');
10
10
 
11
11
 
12
12
 
13
13
  exports.DecoratorError = decorator.DecoratorError;
14
14
  exports.ReflectGet = decorator.ReflectGet;
15
15
  exports.ReflectSet = decorator.ReflectSet;
16
+ exports.arrayEquals = decorator.arrayEquals;
16
17
  exports.decorator = decorator.decorator;
17
18
  exports.isConstructor = decorator.isConstructor;
18
- exports.isObject = decorator.isObject;
19
19
  exports.isOwnAccessor = decorator.isOwnAccessor;
20
20
  exports.legacyDecorator = decorator.legacyDecorator;
21
21
  exports.modernDecorator = decorator.modernDecorator;
@@ -28,30 +28,56 @@ exports.allocatedValues = destroyable.allocatedValues;
28
28
  exports.callOnGC = destroyable.callOnGC;
29
29
  exports.destructor = destroyable.destructor;
30
30
  exports.Eventful = eventful.Eventful;
31
+ exports.ArrayReadForward = indexable.ArrayReadForward;
31
32
  exports.Indexable = indexable.Indexable;
33
+ exports.forwardArray = indexable.forwardArray;
32
34
  exports.getAt = indexable.getAt;
33
35
  exports.setAt = indexable.setAt;
34
- exports.Reactive = reactive.Reactive;
36
+ exports.IterableWeakMap = reactive.IterableWeakMap;
37
+ exports.IterableWeakSet = reactive.IterableWeakSet;
35
38
  exports.ReactiveBase = reactive.ReactiveBase;
36
39
  exports.ReactiveError = reactive.ReactiveError;
37
- Object.defineProperty(exports, "activeEffect", {
38
- enumerable: true,
39
- get: function () { return reactive.activeEffect; }
40
- });
40
+ exports.ReadOnlyError = reactive.ReadOnlyError;
41
+ exports.Register = reactive.Register;
41
42
  exports.addBatchCleanup = reactive.addBatchCleanup;
42
43
  exports.atomic = reactive.atomic;
44
+ exports.batch = reactive.batch;
45
+ exports.biDi = reactive.biDi;
46
+ exports.buildReactivityGraph = reactive.buildReactivityGraph;
43
47
  exports.cleanedBy = reactive.cleanedBy;
44
- exports.computed = reactive.computed;
48
+ exports.cleanup = reactive.cleanup;
49
+ exports.deepWatch = reactive.deepWatch;
50
+ exports.defer = reactive.defer;
51
+ exports.derived = reactive.derived;
45
52
  exports.effect = reactive.effect;
53
+ exports.enableDevTools = reactive.enableDevTools;
54
+ exports.getActiveEffect = reactive.getActiveEffect;
46
55
  exports.getState = reactive.getState;
47
56
  exports.immutables = reactive.immutables;
48
- exports.invalidateComputed = reactive.invalidateComputed;
57
+ exports.isDevtoolsEnabled = reactive.isDevtoolsEnabled;
49
58
  exports.isNonReactive = reactive.isNonReactive;
50
59
  exports.isReactive = reactive.isReactive;
60
+ exports.isZoneEnabled = reactive.isZoneEnabled;
61
+ exports.mapped = reactive.mapped;
62
+ exports.memoize = reactive.memoize;
51
63
  exports.mixin = reactive.mixin;
64
+ exports.organize = reactive.organize;
65
+ exports.organized = reactive.organized;
52
66
  exports.profileInfo = reactive.profileInfo;
67
+ exports.project = reactive.project;
53
68
  exports.reactive = reactive.reactive;
54
69
  exports.reactiveOptions = reactive.options;
70
+ exports.reduced = reactive.reduced;
71
+ exports.register = reactive.register;
72
+ exports.registerEffectForDebug = reactive.registerEffectForDebug;
73
+ exports.registerNativeReactivity = reactive.registerNativeReactivity;
74
+ exports.registerObjectForDebug = reactive.registerObjectForDebug;
75
+ exports.root = reactive.root;
76
+ exports.setEffectName = reactive.setEffectName;
77
+ exports.setObjectName = reactive.setObjectName;
78
+ exports.setZoneEnabled = reactive.setZoneEnabled;
79
+ exports.touched = reactive.touched;
80
+ exports.touched1 = reactive.touched1;
55
81
  exports.trackEffect = reactive.trackEffect;
56
82
  exports.unreactive = reactive.unreactive;
57
83
  exports.untracked = reactive.untracked;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -53,5 +53,191 @@ declare function Indexable<Items>(): abstract new (...args: any[]) => AbstractGe
53
53
  type AtReturnType<T> = T extends {
54
54
  [getAt](index: number): infer R;
55
55
  } ? R : never;
56
+ /**
57
+ * Symbol for accessing the forwarded array in ArrayReadForward
58
+ */
59
+ declare const forwardArray: unique symbol;
60
+ /**
61
+ * A read-only array forwarder that implements all reading/iterating methods of Array
62
+ * but does not implement modification methods.
63
+ *
64
+ * The constructor takes a callback that returns an array, and all methods forward
65
+ * their behavior to the result of that callback.
66
+ */
67
+ declare class ArrayReadForward<T> {
68
+ protected get [forwardArray](): readonly T[];
69
+ /**
70
+ * Get the length of the array
71
+ */
72
+ get length(): number;
73
+ /**
74
+ * Get an element at a specific index
75
+ */
76
+ [index: number]: T | undefined;
77
+ /**
78
+ * Iterator protocol support
79
+ */
80
+ [Symbol.iterator](): Iterator<T>;
81
+ /**
82
+ * Creates a new array with the results of calling a provided function on every element
83
+ */
84
+ map<U>(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[];
85
+ /**
86
+ * Creates a new array with all elements that pass the test implemented by the provided function
87
+ */
88
+ filter<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[];
89
+ filter(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[];
90
+ /**
91
+ * Executes a reducer function on each element of the array, resulting in a single output value
92
+ */
93
+ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
94
+ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
95
+ reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
96
+ /**
97
+ * Executes a reducer function on each element of the array (right-to-left), resulting in a single output value
98
+ */
99
+ reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
100
+ reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
101
+ reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
102
+ /**
103
+ * Executes a provided function once for each array element
104
+ */
105
+ forEach(callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void;
106
+ /**
107
+ * Returns the value of the first element in the array that satisfies the provided testing function
108
+ */
109
+ find<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S | undefined;
110
+ find(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T | undefined;
111
+ /**
112
+ * Returns the index of the first element in the array that satisfies the provided testing function
113
+ */
114
+ findIndex(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): number;
115
+ /**
116
+ * Returns the value of the last element in the array that satisfies the provided testing function
117
+ */
118
+ findLast<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S | undefined;
119
+ findLast(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T | undefined;
120
+ /**
121
+ * Returns the index of the last element in the array that satisfies the provided testing function
122
+ */
123
+ findLastIndex(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): number;
124
+ /**
125
+ * Determines whether an array includes a certain value among its entries
126
+ */
127
+ includes(searchElement: T, fromIndex?: number): boolean;
128
+ /**
129
+ * Returns the first index at which a given element can be found in the array
130
+ */
131
+ indexOf(searchElement: T, fromIndex?: number): number;
132
+ /**
133
+ * Returns the last index at which a given element can be found in the array
134
+ */
135
+ lastIndexOf(searchElement: T, fromIndex?: number): number;
136
+ /**
137
+ * Returns a shallow copy of a portion of an array into a new array object
138
+ */
139
+ slice(start?: number, end?: number): T[];
140
+ /**
141
+ * Returns a new array comprised of this array joined with other array(s) and/or value(s)
142
+ */
143
+ concat(...items: ConcatArray<T>[]): T[];
144
+ concat(...items: (T | ConcatArray<T>)[]): T[];
145
+ /**
146
+ * Tests whether all elements in the array pass the test implemented by the provided function
147
+ */
148
+ every(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
149
+ /**
150
+ * Tests whether at least one element in the array passes the test implemented by the provided function
151
+ */
152
+ some(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
153
+ /**
154
+ * Joins all elements of an array into a string
155
+ */
156
+ join(separator?: string): string;
157
+ /**
158
+ * Returns a new array iterator that contains the keys for each index in the array
159
+ */
160
+ keys(): IterableIterator<number>;
161
+ /**
162
+ * Returns a new array iterator that contains the values for each index in the array
163
+ */
164
+ values(): IterableIterator<T>;
165
+ /**
166
+ * Returns a new array iterator that contains the key/value pairs for each index in the array
167
+ */
168
+ entries(): IterableIterator<[number, T]>;
169
+ /**
170
+ * Returns a string representation of the array
171
+ */
172
+ toString(): string;
173
+ /**
174
+ * Returns a localized string representing the array
175
+ */
176
+ toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions): string;
177
+ /**
178
+ * Returns the element at the specified index, or undefined if the index is out of bounds
179
+ */
180
+ at(index: number): T | undefined;
181
+ /**
182
+ * Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth
183
+ */
184
+ flat(depth?: number): T[];
185
+ /**
186
+ * Returns a new array formed by applying a given callback function to each element of the array,
187
+ * and then flattening the result by one level
188
+ */
189
+ flatMap<U, This = undefined>(callback: (this: This, value: T, index: number, array: readonly T[]) => U | ReadonlyArray<U>, thisArg?: This): U[];
190
+ /**
191
+ * Returns a new array with elements in reversed order (ES2023)
192
+ */
193
+ toReversed(): T[];
194
+ /**
195
+ * Returns a new array with elements sorted (ES2023)
196
+ */
197
+ toSorted(compareFn?: ((a: T, b: T) => number) | undefined): T[];
198
+ /**
199
+ * Returns a new array with some elements removed and/or replaced at a given index (ES2023)
200
+ */
201
+ toSpliced(start: number, deleteCount?: number, ...items: T[]): T[];
202
+ /**
203
+ * Returns a new array with the element at the given index replaced with the given value (ES2023)
204
+ */
205
+ with(index: number, value: T): T[];
206
+ get [Symbol.unscopables](): {
207
+ readonly [x: number]: boolean;
208
+ readonly length?: boolean;
209
+ toString?: boolean;
210
+ toLocaleString?: boolean;
211
+ concat?: boolean;
212
+ join?: boolean;
213
+ slice?: boolean;
214
+ indexOf?: boolean;
215
+ lastIndexOf?: boolean;
216
+ every?: boolean;
217
+ some?: boolean;
218
+ forEach?: boolean;
219
+ map?: boolean;
220
+ filter?: boolean;
221
+ reduce?: boolean;
222
+ reduceRight?: boolean;
223
+ find?: boolean;
224
+ findIndex?: boolean;
225
+ entries?: boolean;
226
+ keys?: boolean;
227
+ values?: boolean;
228
+ includes?: boolean;
229
+ flatMap?: boolean;
230
+ flat?: boolean;
231
+ at?: boolean;
232
+ findLast?: boolean;
233
+ findLastIndex?: boolean;
234
+ toReversed?: boolean;
235
+ toSorted?: boolean;
236
+ toSpliced?: boolean;
237
+ with?: boolean;
238
+ [Symbol.iterator]?: boolean;
239
+ readonly [Symbol.unscopables]?: boolean;
240
+ };
241
+ }
56
242
 
57
- export { Indexable, getAt, setAt };
243
+ export { ArrayReadForward, Indexable, forwardArray, getAt, setAt };
@@ -68,9 +68,8 @@ function Indexable(base, accessor) {
68
68
  }
69
69
  const numProp = Number(prop);
70
70
  if (!Number.isNaN(numProp)) {
71
- if (!accessor.set) {
71
+ if (!accessor.set)
72
72
  throw new Error('Indexable class has read-only numeric index access');
73
- }
74
73
  accessor.set.call(receiver, numProp, value);
75
74
  return true;
76
75
  }
@@ -86,6 +85,201 @@ function Indexable(base, accessor) {
86
85
  }));
87
86
  return Indexable;
88
87
  }
88
+ /**
89
+ * Symbol for accessing the forwarded array in ArrayReadForward
90
+ */
91
+ const forwardArray = Symbol('forwardArray');
92
+ /**
93
+ * A read-only array forwarder that implements all reading/iterating methods of Array
94
+ * but does not implement modification methods.
95
+ *
96
+ * The constructor takes a callback that returns an array, and all methods forward
97
+ * their behavior to the result of that callback.
98
+ */
99
+ class ArrayReadForward {
100
+ get [forwardArray]() {
101
+ throw new Error('ArrayReadForward is not implemented');
102
+ }
103
+ /**
104
+ * Get the length of the array
105
+ */
106
+ get length() {
107
+ return this[forwardArray].length;
108
+ }
109
+ /**
110
+ * Iterator protocol support
111
+ */
112
+ [Symbol.iterator]() {
113
+ return this[forwardArray][Symbol.iterator]();
114
+ }
115
+ // Reading/Iterating methods
116
+ /**
117
+ * Creates a new array with the results of calling a provided function on every element
118
+ */
119
+ map(callbackfn, thisArg) {
120
+ return this[forwardArray].map(callbackfn, thisArg);
121
+ }
122
+ filter(predicate, thisArg) {
123
+ return this[forwardArray].filter(predicate, thisArg);
124
+ }
125
+ reduce(callbackfn, initialValue) {
126
+ return initialValue !== undefined
127
+ ? this[forwardArray].reduce(callbackfn, initialValue)
128
+ : this[forwardArray].reduce(callbackfn);
129
+ }
130
+ reduceRight(callbackfn, initialValue) {
131
+ return initialValue !== undefined
132
+ ? this[forwardArray].reduceRight(callbackfn, initialValue)
133
+ : this[forwardArray].reduceRight(callbackfn);
134
+ }
135
+ /**
136
+ * Executes a provided function once for each array element
137
+ */
138
+ forEach(callbackfn, thisArg) {
139
+ this[forwardArray].forEach(callbackfn, thisArg);
140
+ }
141
+ find(predicate, thisArg) {
142
+ return this[forwardArray].find(predicate, thisArg);
143
+ }
144
+ /**
145
+ * Returns the index of the first element in the array that satisfies the provided testing function
146
+ */
147
+ findIndex(predicate, thisArg) {
148
+ return this[forwardArray].findIndex(predicate, thisArg);
149
+ }
150
+ findLast(predicate, thisArg) {
151
+ return this[forwardArray].findLast(predicate, thisArg);
152
+ }
153
+ /**
154
+ * Returns the index of the last element in the array that satisfies the provided testing function
155
+ */
156
+ findLastIndex(predicate, thisArg) {
157
+ return this[forwardArray].findLastIndex(predicate, thisArg);
158
+ }
159
+ /**
160
+ * Determines whether an array includes a certain value among its entries
161
+ */
162
+ includes(searchElement, fromIndex) {
163
+ return this[forwardArray].includes(searchElement, fromIndex);
164
+ }
165
+ /**
166
+ * Returns the first index at which a given element can be found in the array
167
+ */
168
+ indexOf(searchElement, fromIndex) {
169
+ return this[forwardArray].indexOf(searchElement, fromIndex);
170
+ }
171
+ /**
172
+ * Returns the last index at which a given element can be found in the array
173
+ */
174
+ lastIndexOf(searchElement, fromIndex) {
175
+ return this[forwardArray].lastIndexOf(searchElement, fromIndex);
176
+ }
177
+ /**
178
+ * Returns a shallow copy of a portion of an array into a new array object
179
+ */
180
+ slice(start, end) {
181
+ return this[forwardArray].slice(start, end);
182
+ }
183
+ concat(...items) {
184
+ return this[forwardArray].concat(...items);
185
+ }
186
+ /**
187
+ * Tests whether all elements in the array pass the test implemented by the provided function
188
+ */
189
+ every(predicate, thisArg) {
190
+ return this[forwardArray].every(predicate, thisArg);
191
+ }
192
+ /**
193
+ * Tests whether at least one element in the array passes the test implemented by the provided function
194
+ */
195
+ some(predicate, thisArg) {
196
+ return this[forwardArray].some(predicate, thisArg);
197
+ }
198
+ /**
199
+ * Joins all elements of an array into a string
200
+ */
201
+ join(separator) {
202
+ return this[forwardArray].join(separator);
203
+ }
204
+ /**
205
+ * Returns a new array iterator that contains the keys for each index in the array
206
+ */
207
+ keys() {
208
+ return this[forwardArray].keys();
209
+ }
210
+ /**
211
+ * Returns a new array iterator that contains the values for each index in the array
212
+ */
213
+ values() {
214
+ return this[forwardArray].values();
215
+ }
216
+ /**
217
+ * Returns a new array iterator that contains the key/value pairs for each index in the array
218
+ */
219
+ entries() {
220
+ return this[forwardArray].entries();
221
+ }
222
+ /**
223
+ * Returns a string representation of the array
224
+ */
225
+ toString() {
226
+ return this[forwardArray].toString();
227
+ }
228
+ /**
229
+ * Returns a localized string representing the array
230
+ */
231
+ toLocaleString(locales, options) {
232
+ return this[forwardArray].toLocaleString(locales, options);
233
+ }
234
+ /**
235
+ * Returns the element at the specified index, or undefined if the index is out of bounds
236
+ */
237
+ at(index) {
238
+ return this[forwardArray].at(index);
239
+ }
240
+ /**
241
+ * Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth
242
+ */
243
+ flat(depth) {
244
+ return this[forwardArray].flat(depth);
245
+ }
246
+ /**
247
+ * Returns a new array formed by applying a given callback function to each element of the array,
248
+ * and then flattening the result by one level
249
+ */
250
+ flatMap(callback, thisArg) {
251
+ return this[forwardArray].flatMap(callback, thisArg);
252
+ }
253
+ /**
254
+ * Returns a new array with elements in reversed order (ES2023)
255
+ */
256
+ toReversed() {
257
+ return this[forwardArray].toReversed?.() ?? [...this[forwardArray]].reverse();
258
+ }
259
+ /**
260
+ * Returns a new array with elements sorted (ES2023)
261
+ */
262
+ toSorted(compareFn) {
263
+ return this[forwardArray].toSorted?.(compareFn) ?? [...this[forwardArray]].sort(compareFn);
264
+ }
265
+ /**
266
+ * Returns a new array with some elements removed and/or replaced at a given index (ES2023)
267
+ */
268
+ toSpliced(start, deleteCount, ...items) {
269
+ if (deleteCount === undefined)
270
+ return this[forwardArray].toSpliced(start);
271
+ return this[forwardArray].toSpliced(start, deleteCount, ...items);
272
+ }
273
+ /**
274
+ * Returns a new array with the element at the given index replaced with the given value (ES2023)
275
+ */
276
+ with(index, value) {
277
+ return this[forwardArray].with(index, value);
278
+ }
279
+ get [Symbol.unscopables]() {
280
+ return this[forwardArray][Symbol.unscopables];
281
+ }
282
+ }
89
283
 
90
- export { Indexable, getAt, setAt };
284
+ export { ArrayReadForward, Indexable, forwardArray, getAt, setAt };
91
285
  //# sourceMappingURL=indexable.esm.js.map