mutts 1.0.8 → 1.0.10

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 (195) hide show
  1. package/README.md +77 -35
  2. package/dist/browser.cjs +2144 -5355
  3. package/dist/browser.cjs.map +1 -1
  4. package/dist/browser.d.ts +2 -1655
  5. package/dist/browser.dev.cjs +110 -0
  6. package/dist/browser.dev.cjs.map +1 -0
  7. package/dist/browser.dev.d.ts +2 -0
  8. package/dist/browser.dev.esm.js +5 -0
  9. package/dist/browser.dev.esm.js.map +1 -0
  10. package/dist/browser.esm.js +20 -107
  11. package/dist/browser.esm.js.map +1 -1
  12. package/dist/chunks/{async-browser-CA0jPWIi.cjs → async-browser-BU_IfxYD.cjs} +19 -107
  13. package/dist/chunks/async-browser-BU_IfxYD.cjs.map +1 -0
  14. package/dist/chunks/{async-core-UqHzvJ-S.cjs → async-core-CRLKP3l-.cjs} +8 -4
  15. package/dist/chunks/async-core-CRLKP3l-.cjs.map +1 -0
  16. package/dist/chunks/{async-node-BYHuGTni.cjs → async-node-3PrbVAbB.cjs} +7 -12
  17. package/dist/chunks/async-node-3PrbVAbB.cjs.map +1 -0
  18. package/dist/chunks/index-CaaQQlPJ.esm.js +3174 -0
  19. package/dist/chunks/index-CaaQQlPJ.esm.js.map +1 -0
  20. package/dist/chunks/node-nKJBk8iJ.esm.js +96 -0
  21. package/dist/chunks/node-nKJBk8iJ.esm.js.map +1 -0
  22. package/dist/chunks/proxy-Dtg-bJ3T.cjs +3763 -0
  23. package/dist/chunks/proxy-Dtg-bJ3T.cjs.map +1 -0
  24. package/dist/chunks/proxy-r7lARftl.esm.js +3701 -0
  25. package/dist/chunks/proxy-r7lARftl.esm.js.map +1 -0
  26. package/dist/debug.cjs +980 -0
  27. package/dist/debug.cjs.map +1 -0
  28. package/dist/debug.d.ts +208 -0
  29. package/dist/debug.esm.js +950 -0
  30. package/dist/debug.esm.js.map +1 -0
  31. package/dist/devtools/manifest.json +1 -1
  32. package/dist/devtools/panel.html +1 -1
  33. package/dist/devtools/panel.js +107 -94
  34. package/dist/devtools/panel.js.map +1 -1
  35. package/dist/index.d.ts +1447 -13
  36. package/dist/mutts.umd.js +7167 -1
  37. package/dist/mutts.umd.js.map +1 -1
  38. package/dist/mutts.umd.min.js +1 -1
  39. package/dist/mutts.umd.min.js.map +1 -1
  40. package/dist/node.cjs +70 -66
  41. package/dist/node.cjs.map +1 -1
  42. package/dist/node.d.ts +2 -1
  43. package/dist/node.dev.cjs +110 -0
  44. package/dist/node.dev.cjs.map +1 -0
  45. package/dist/node.dev.d.ts +2 -0
  46. package/dist/node.dev.esm.js +6 -0
  47. package/dist/node.dev.esm.js.map +1 -0
  48. package/dist/node.esm.js +4 -103
  49. package/dist/node.esm.js.map +1 -1
  50. package/dist/{reactive/types.d.ts → types-W5vD6m2n.d.ts} +186 -93
  51. package/docs/ai/api-reference.md +12 -19
  52. package/docs/ai/manual.md +521 -17
  53. package/docs/events.md +57 -2
  54. package/docs/flavored.md +210 -0
  55. package/docs/reactive/advanced.md +314 -5
  56. package/docs/reactive/attend.md +142 -0
  57. package/docs/reactive/collections.md +76 -39
  58. package/docs/reactive/core.md +100 -14
  59. package/docs/reactive/debugging.md +123 -18
  60. package/docs/reactive/error-handling.md +121 -0
  61. package/docs/reactive/resource.md +125 -0
  62. package/docs/reactive/scan.md +247 -1
  63. package/docs/reactive.md +4 -1
  64. package/docs/std-decorators.md +102 -51
  65. package/docs/utils.md +70 -0
  66. package/docs/zone.md +3 -7
  67. package/package.json +64 -30
  68. package/dist/async/browser.d.ts +0 -2
  69. package/dist/async/browser.d.ts.map +0 -1
  70. package/dist/async/index.d.ts +0 -18
  71. package/dist/async/index.d.ts.map +0 -1
  72. package/dist/async/node.d.ts +0 -2
  73. package/dist/async/node.d.ts.map +0 -1
  74. package/dist/chunks/async-browser-CA0jPWIi.cjs.map +0 -1
  75. package/dist/chunks/async-core-UqHzvJ-S.cjs.map +0 -1
  76. package/dist/chunks/async-node-BYHuGTni.cjs.map +0 -1
  77. package/dist/chunks/index-DhaOVusv.esm.js +0 -6411
  78. package/dist/chunks/index-DhaOVusv.esm.js.map +0 -1
  79. package/dist/decorator.d.ts +0 -106
  80. package/dist/decorator.d.ts.map +0 -1
  81. package/dist/destroyable.d.ts +0 -87
  82. package/dist/destroyable.d.ts.map +0 -1
  83. package/dist/entry-browser.d.ts +0 -3
  84. package/dist/entry-browser.d.ts.map +0 -1
  85. package/dist/entry-node.d.ts +0 -3
  86. package/dist/entry-node.d.ts.map +0 -1
  87. package/dist/eventful.d.ts +0 -18
  88. package/dist/eventful.d.ts.map +0 -1
  89. package/dist/index.d.ts.map +0 -1
  90. package/dist/indexable.d.ts +0 -243
  91. package/dist/indexable.d.ts.map +0 -1
  92. package/dist/introspection.d.ts +0 -27
  93. package/dist/introspection.d.ts.map +0 -1
  94. package/dist/iterableWeak.d.ts +0 -53
  95. package/dist/iterableWeak.d.ts.map +0 -1
  96. package/dist/mixins.d.ts +0 -25
  97. package/dist/mixins.d.ts.map +0 -1
  98. package/dist/promiseChain.d.ts +0 -20
  99. package/dist/promiseChain.d.ts.map +0 -1
  100. package/dist/reactive/array.d.ts +0 -49
  101. package/dist/reactive/array.d.ts.map +0 -1
  102. package/dist/reactive/buffer.d.ts +0 -44
  103. package/dist/reactive/buffer.d.ts.map +0 -1
  104. package/dist/reactive/change.d.ts +0 -29
  105. package/dist/reactive/change.d.ts.map +0 -1
  106. package/dist/reactive/debug.d.ts +0 -111
  107. package/dist/reactive/debug.d.ts.map +0 -1
  108. package/dist/reactive/deep-touch.d.ts +0 -28
  109. package/dist/reactive/deep-touch.d.ts.map +0 -1
  110. package/dist/reactive/deep-watch-state.d.ts +0 -25
  111. package/dist/reactive/deep-watch-state.d.ts.map +0 -1
  112. package/dist/reactive/deep-watch.d.ts +0 -19
  113. package/dist/reactive/deep-watch.d.ts.map +0 -1
  114. package/dist/reactive/effect-context.d.ts +0 -7
  115. package/dist/reactive/effect-context.d.ts.map +0 -1
  116. package/dist/reactive/effects.d.ts +0 -151
  117. package/dist/reactive/effects.d.ts.map +0 -1
  118. package/dist/reactive/index.d.ts +0 -20
  119. package/dist/reactive/index.d.ts.map +0 -1
  120. package/dist/reactive/interface.d.ts +0 -64
  121. package/dist/reactive/interface.d.ts.map +0 -1
  122. package/dist/reactive/map.d.ts +0 -30
  123. package/dist/reactive/map.d.ts.map +0 -1
  124. package/dist/reactive/memoize.d.ts +0 -5
  125. package/dist/reactive/memoize.d.ts.map +0 -1
  126. package/dist/reactive/non-reactive-state.d.ts +0 -9
  127. package/dist/reactive/non-reactive-state.d.ts.map +0 -1
  128. package/dist/reactive/non-reactive.d.ts +0 -11
  129. package/dist/reactive/non-reactive.d.ts.map +0 -1
  130. package/dist/reactive/project.d.ts +0 -41
  131. package/dist/reactive/project.d.ts.map +0 -1
  132. package/dist/reactive/proxy-state.d.ts +0 -8
  133. package/dist/reactive/proxy-state.d.ts.map +0 -1
  134. package/dist/reactive/proxy.d.ts +0 -23
  135. package/dist/reactive/proxy.d.ts.map +0 -1
  136. package/dist/reactive/record.d.ts +0 -116
  137. package/dist/reactive/record.d.ts.map +0 -1
  138. package/dist/reactive/register.d.ts +0 -64
  139. package/dist/reactive/register.d.ts.map +0 -1
  140. package/dist/reactive/registry.d.ts +0 -20
  141. package/dist/reactive/registry.d.ts.map +0 -1
  142. package/dist/reactive/set.d.ts +0 -28
  143. package/dist/reactive/set.d.ts.map +0 -1
  144. package/dist/reactive/tracking.d.ts +0 -7
  145. package/dist/reactive/tracking.d.ts.map +0 -1
  146. package/dist/reactive/types.d.ts.map +0 -1
  147. package/dist/std-decorators.d.ts +0 -50
  148. package/dist/std-decorators.d.ts.map +0 -1
  149. package/dist/utils.d.ts +0 -49
  150. package/dist/utils.d.ts.map +0 -1
  151. package/dist/zone.d.ts +0 -40
  152. package/dist/zone.d.ts.map +0 -1
  153. package/docs/reactive/project.md +0 -93
  154. package/src/async/browser.ts +0 -319
  155. package/src/async/index.ts +0 -23
  156. package/src/async/node.ts +0 -104
  157. package/src/decorator.ts +0 -272
  158. package/src/destroyable.ts +0 -199
  159. package/src/entry-browser.ts +0 -5
  160. package/src/entry-node.ts +0 -5
  161. package/src/eventful.ts +0 -77
  162. package/src/index.d.ts +0 -12
  163. package/src/index.ts +0 -64
  164. package/src/indexable.ts +0 -526
  165. package/src/introspection.ts +0 -59
  166. package/src/iterableWeak.ts +0 -233
  167. package/src/mixins.ts +0 -123
  168. package/src/promiseChain.ts +0 -110
  169. package/src/reactive/array.ts +0 -507
  170. package/src/reactive/buffer.ts +0 -168
  171. package/src/reactive/change.ts +0 -138
  172. package/src/reactive/debug.ts +0 -517
  173. package/src/reactive/deep-touch.ts +0 -268
  174. package/src/reactive/deep-watch-state.ts +0 -82
  175. package/src/reactive/deep-watch.ts +0 -168
  176. package/src/reactive/effect-context.ts +0 -18
  177. package/src/reactive/effects.ts +0 -1382
  178. package/src/reactive/index.ts +0 -75
  179. package/src/reactive/interface.ts +0 -210
  180. package/src/reactive/map.ts +0 -158
  181. package/src/reactive/memoize.ts +0 -163
  182. package/src/reactive/non-reactive-state.ts +0 -49
  183. package/src/reactive/non-reactive.ts +0 -43
  184. package/src/reactive/project.ts +0 -453
  185. package/src/reactive/proxy-state.ts +0 -27
  186. package/src/reactive/proxy.ts +0 -264
  187. package/src/reactive/record.ts +0 -196
  188. package/src/reactive/register.ts +0 -419
  189. package/src/reactive/registry.ts +0 -59
  190. package/src/reactive/set.ts +0 -130
  191. package/src/reactive/tracking.ts +0 -44
  192. package/src/reactive/types.ts +0 -440
  193. package/src/std-decorators.ts +0 -217
  194. package/src/utils.ts +0 -301
  195. package/src/zone.ts +0 -138
package/src/indexable.ts DELETED
@@ -1,526 +0,0 @@
1
- /**
2
- * Symbol for defining custom getter logic for numeric index access
3
- */
4
- export const getAt = Symbol('getAt')
5
- /**
6
- * Symbol for defining custom setter logic for numeric index access
7
- */
8
- export const setAt = Symbol('setAt')
9
-
10
- interface IndexingAt<Items = any> {
11
- [getAt](index: number): Items
12
- }
13
-
14
- interface Accessor<T, Items> {
15
- get(this: T, index: number): Items
16
- set?(this: T, index: number, value: Items): void
17
- getLength?(this: T): number
18
- setLength?(this: T, value: number): void
19
- }
20
-
21
- abstract class AbstractGetAt<Items = any> {
22
- abstract [getAt](index: number): Items
23
- }
24
-
25
- /**
26
- * Creates an indexable class with a base class and accessor object
27
- * @param base - The base class to extend
28
- * @param accessor - Object containing get/set methods for numeric index access
29
- * @returns A class that supports numeric index access
30
- */
31
- export function Indexable<Items, Base extends abstract new (...args: any[]) => any>(
32
- base: Base,
33
- accessor: Accessor<InstanceType<Base>, Items>
34
- ): new (
35
- ...args: ConstructorParameters<Base>
36
- ) => InstanceType<Base> & { [x: number]: Items }
37
-
38
- /**
39
- * Creates an indexable class with only an accessor object (no base class)
40
- * @param accessor - Object containing get/set methods for numeric index access
41
- * @returns A class that supports numeric index access
42
- */
43
- export function Indexable<Items>(accessor: Accessor<any, Items>): new () => { [x: number]: Items }
44
-
45
- /**
46
- * Creates an indexable class with a base class that has [getAt] method
47
- * @param base - The base class that implements [getAt] method
48
- * @returns A class that supports numeric index access using the base class's [getAt] method
49
- */
50
- export function Indexable<Base extends new (...args: any[]) => IndexingAt>(
51
- base: Base
52
- ): new (
53
- ...args: ConstructorParameters<Base>
54
- ) => InstanceType<Base> & { [x: number]: AtReturnType<InstanceType<Base>> }
55
-
56
- /**
57
- * Creates an abstract indexable base class
58
- * @returns An abstract class that supports numeric index access
59
- */
60
- export function Indexable<Items>(): abstract new (
61
- ...args: any[]
62
- ) => AbstractGetAt & { [x: number]: Items }
63
-
64
- export function Indexable<Items, Base extends abstract new (...args: any[]) => any>(
65
- base?: Base | Accessor<Base, Items>,
66
- accessor?: Accessor<Base, Items>
67
- ) {
68
- if (base && typeof base !== 'function') {
69
- accessor = base as Accessor<Base, Items>
70
- base = undefined
71
- }
72
- if (!base) {
73
- //@ts-expect-error
74
- base = class {} as Base
75
- }
76
- if (!accessor) {
77
- accessor = {
78
- get(this: any, index: number) {
79
- if (typeof this[getAt] !== 'function') {
80
- throw new Error('Indexable class must have an [getAt] method')
81
- }
82
- return this[getAt](index)
83
- },
84
- set(this: any, index: number, value: Items) {
85
- if (typeof this[setAt] !== 'function') {
86
- throw new Error('Indexable class has read-only numeric index access')
87
- }
88
- this[setAt](index, value)
89
- },
90
- }
91
- }
92
-
93
- abstract class Indexable extends (base as Base) {
94
- [x: number]: Items
95
- }
96
-
97
- Object.setPrototypeOf(
98
- Indexable.prototype,
99
- new Proxy((base as Base).prototype, {
100
- //@ts-expect-error
101
- [Symbol.toStringTag]: 'MutTs Indexable',
102
- get(target, prop, receiver) {
103
- if (prop in target) {
104
- const getter = Object.getOwnPropertyDescriptor(target, prop)?.get
105
- return getter ? getter.call(receiver) : target[prop]
106
- }
107
- if (typeof prop === 'string') {
108
- if (prop === 'length' && accessor.getLength) return accessor.getLength.call(receiver)
109
- const numProp = Number(prop)
110
- if (!Number.isNaN(numProp)) {
111
- return accessor.get!.call(receiver, numProp) as Items
112
- }
113
- }
114
- return undefined
115
- },
116
- set(target, prop, value, receiver) {
117
- if (prop in target) {
118
- const setter = Object.getOwnPropertyDescriptor(target, prop)?.set
119
- if (setter) setter.call(receiver, value)
120
- else target[prop] = value
121
- return true
122
- }
123
- if (typeof prop === 'string') {
124
- if (prop === 'length' && accessor.setLength) {
125
- accessor.setLength.call(receiver, value)
126
- return true
127
- }
128
- const numProp = Number(prop)
129
- if (!Number.isNaN(numProp)) {
130
- if (!accessor.set) throw new Error('Indexable class has read-only numeric index access')
131
- accessor.set!.call(receiver, numProp, value)
132
- return true
133
- }
134
- }
135
- Object.defineProperty(receiver, prop, {
136
- value,
137
- writable: true,
138
- enumerable: true,
139
- configurable: true,
140
- })
141
- return true
142
- },
143
- has(target, prop) {
144
- if (prop in target) return true
145
- if (typeof prop === 'string') {
146
- if (prop === 'length' && accessor.getLength) return true
147
- const numProp = Number(prop)
148
- if (!Number.isNaN(numProp)) return true
149
- }
150
- return false
151
- },
152
- ownKeys(target) {
153
- const keys = Reflect.ownKeys(target)
154
- if (accessor.getLength) {
155
- keys.push('length')
156
- const len = accessor.getLength.call(this as any)
157
- for (let i = 0; i < len; i++) keys.push(String(i))
158
- }
159
- return keys
160
- },
161
- getOwnPropertyDescriptor(target, prop) {
162
- if (prop in target) return Object.getOwnPropertyDescriptor(target, prop)
163
- if (typeof prop === 'string') {
164
- if (prop === 'length' && accessor.getLength) {
165
- return {
166
- enumerable: false,
167
- configurable: true,
168
- get: () => accessor.getLength!.call(this as any),
169
- }
170
- }
171
- const numProp = Number(prop)
172
- if (!Number.isNaN(numProp)) {
173
- return {
174
- enumerable: true,
175
- configurable: true,
176
- get: () => accessor.get!.call(this as any, numProp),
177
- set: accessor.set
178
- ? (v: any) => accessor.set!.call(this as any, numProp, v)
179
- : undefined,
180
- }
181
- }
182
- }
183
- return undefined
184
- },
185
- })
186
- )
187
- return Indexable
188
- }
189
-
190
- type AtReturnType<T> = T extends { [getAt](index: number): infer R } ? R : never
191
-
192
- /**
193
- * Symbol for accessing the forwarded array in ArrayReadForward
194
- */
195
- export const forwardArray = Symbol('forwardArray')
196
-
197
- /**
198
- * A read-only array forwarder that implements all reading/iterating methods of Array
199
- * but does not implement modification methods.
200
- *
201
- * The constructor takes a callback that returns an array, and all methods forward
202
- * their behavior to the result of that callback.
203
- */
204
- export class ArrayReadForward<T> {
205
- protected get [forwardArray](): readonly T[] {
206
- throw new Error('ArrayReadForward is not implemented')
207
- }
208
-
209
- /**
210
- * Get the length of the array
211
- */
212
- get length(): number {
213
- return this[forwardArray].length
214
- }
215
-
216
- /**
217
- * Get an element at a specific index
218
- */
219
- [index: number]: T | undefined
220
-
221
- /**
222
- * Iterator protocol support
223
- */
224
- [Symbol.iterator](): Iterator<T> {
225
- return this[forwardArray][Symbol.iterator]()
226
- }
227
-
228
- // Reading/Iterating methods
229
-
230
- /**
231
- * Creates a new array with the results of calling a provided function on every element
232
- */
233
- map<U>(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[] {
234
- return this[forwardArray].map(callbackfn, thisArg)
235
- }
236
-
237
- /**
238
- * Creates a new array with all elements that pass the test implemented by the provided function
239
- */
240
- filter<S extends T>(
241
- predicate: (value: T, index: number, array: readonly T[]) => value is S,
242
- thisArg?: any
243
- ): S[]
244
- filter(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[]
245
- filter(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[] {
246
- return this[forwardArray].filter(predicate, thisArg)
247
- }
248
-
249
- /**
250
- * Executes a reducer function on each element of the array, resulting in a single output value
251
- */
252
- reduce(
253
- callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T
254
- ): T
255
- reduce(
256
- callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T,
257
- initialValue: T
258
- ): T
259
- reduce<U>(
260
- callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U,
261
- initialValue: U
262
- ): U
263
- reduce(
264
- callbackfn: (
265
- previousValue: any,
266
- currentValue: T,
267
- currentIndex: number,
268
- array: readonly T[]
269
- ) => any,
270
- initialValue?: any
271
- ): any {
272
- return initialValue !== undefined
273
- ? this[forwardArray].reduce(callbackfn, initialValue)
274
- : this[forwardArray].reduce(callbackfn)
275
- }
276
-
277
- /**
278
- * Executes a reducer function on each element of the array (right-to-left), resulting in a single output value
279
- */
280
- reduceRight(
281
- callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T
282
- ): T
283
- reduceRight(
284
- callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T,
285
- initialValue: T
286
- ): T
287
- reduceRight<U>(
288
- callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U,
289
- initialValue: U
290
- ): U
291
- reduceRight(
292
- callbackfn: (
293
- previousValue: any,
294
- currentValue: T,
295
- currentIndex: number,
296
- array: readonly T[]
297
- ) => any,
298
- initialValue?: any
299
- ): any {
300
- return initialValue !== undefined
301
- ? this[forwardArray].reduceRight(callbackfn, initialValue)
302
- : this[forwardArray].reduceRight(callbackfn)
303
- }
304
-
305
- /**
306
- * Executes a provided function once for each array element
307
- */
308
- forEach(callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void {
309
- this[forwardArray].forEach(callbackfn, thisArg)
310
- }
311
-
312
- /**
313
- * Returns the value of the first element in the array that satisfies the provided testing function
314
- */
315
- find<S extends T>(
316
- predicate: (value: T, index: number, array: readonly T[]) => value is S,
317
- thisArg?: any
318
- ): S | undefined
319
- find(
320
- predicate: (value: T, index: number, array: readonly T[]) => unknown,
321
- thisArg?: any
322
- ): T | undefined
323
- find(
324
- predicate: (value: T, index: number, array: readonly T[]) => unknown,
325
- thisArg?: any
326
- ): T | undefined {
327
- return this[forwardArray].find(predicate, thisArg)
328
- }
329
-
330
- /**
331
- * Returns the index of the first element in the array that satisfies the provided testing function
332
- */
333
- findIndex(
334
- predicate: (value: T, index: number, array: readonly T[]) => unknown,
335
- thisArg?: any
336
- ): number {
337
- return this[forwardArray].findIndex(predicate, thisArg)
338
- }
339
-
340
- /**
341
- * Returns the value of the last element in the array that satisfies the provided testing function
342
- */
343
- findLast<S extends T>(
344
- predicate: (value: T, index: number, array: readonly T[]) => value is S,
345
- thisArg?: any
346
- ): S | undefined
347
- findLast(
348
- predicate: (value: T, index: number, array: readonly T[]) => unknown,
349
- thisArg?: any
350
- ): T | undefined
351
- findLast(
352
- predicate: (value: T, index: number, array: readonly T[]) => unknown,
353
- thisArg?: any
354
- ): T | undefined {
355
- return this[forwardArray].findLast(predicate, thisArg)
356
- }
357
-
358
- /**
359
- * Returns the index of the last element in the array that satisfies the provided testing function
360
- */
361
- findLastIndex(
362
- predicate: (value: T, index: number, array: readonly T[]) => unknown,
363
- thisArg?: any
364
- ): number {
365
- return this[forwardArray].findLastIndex(predicate, thisArg)
366
- }
367
-
368
- /**
369
- * Determines whether an array includes a certain value among its entries
370
- */
371
- includes(searchElement: T, fromIndex?: number): boolean {
372
- return this[forwardArray].includes(searchElement, fromIndex)
373
- }
374
-
375
- /**
376
- * Returns the first index at which a given element can be found in the array
377
- */
378
- indexOf(searchElement: T, fromIndex?: number): number {
379
- return this[forwardArray].indexOf(searchElement, fromIndex)
380
- }
381
-
382
- /**
383
- * Returns the last index at which a given element can be found in the array
384
- */
385
- lastIndexOf(searchElement: T, fromIndex?: number): number {
386
- return this[forwardArray].lastIndexOf(searchElement, fromIndex)
387
- }
388
-
389
- /**
390
- * Returns a shallow copy of a portion of an array into a new array object
391
- */
392
- slice(start?: number, end?: number): T[] {
393
- return this[forwardArray].slice(start, end)
394
- }
395
-
396
- /**
397
- * Returns a new array comprised of this array joined with other array(s) and/or value(s)
398
- */
399
- concat(...items: ConcatArray<T>[]): T[]
400
- concat(...items: (T | ConcatArray<T>)[]): T[]
401
- concat(...items: (T | ConcatArray<T>)[]): T[] {
402
- return this[forwardArray].concat(...items)
403
- }
404
-
405
- /**
406
- * Tests whether all elements in the array pass the test implemented by the provided function
407
- */
408
- every(
409
- predicate: (value: T, index: number, array: readonly T[]) => unknown,
410
- thisArg?: any
411
- ): boolean {
412
- return this[forwardArray].every(predicate, thisArg)
413
- }
414
-
415
- /**
416
- * Tests whether at least one element in the array passes the test implemented by the provided function
417
- */
418
- some(
419
- predicate: (value: T, index: number, array: readonly T[]) => unknown,
420
- thisArg?: any
421
- ): boolean {
422
- return this[forwardArray].some(predicate, thisArg)
423
- }
424
-
425
- /**
426
- * Joins all elements of an array into a string
427
- */
428
- join(separator?: string): string {
429
- return this[forwardArray].join(separator)
430
- }
431
-
432
- /**
433
- * Returns a new array iterator that contains the keys for each index in the array
434
- */
435
- keys(): IterableIterator<number> {
436
- return this[forwardArray].keys()
437
- }
438
-
439
- /**
440
- * Returns a new array iterator that contains the values for each index in the array
441
- */
442
- values(): IterableIterator<T> {
443
- return this[forwardArray].values()
444
- }
445
-
446
- /**
447
- * Returns a new array iterator that contains the key/value pairs for each index in the array
448
- */
449
- entries(): IterableIterator<[number, T]> {
450
- return this[forwardArray].entries()
451
- }
452
-
453
- /**
454
- * Returns a string representation of the array
455
- */
456
- toString(): string {
457
- return this[forwardArray].toString()
458
- }
459
-
460
- /**
461
- * Returns a localized string representing the array
462
- */
463
- toLocaleString(
464
- locales?: string | string[],
465
- options?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions
466
- ): string {
467
- return this[forwardArray].toLocaleString(locales as string | string[], options)
468
- }
469
-
470
- /**
471
- * Returns the element at the specified index, or undefined if the index is out of bounds
472
- */
473
- at(index: number): T | undefined {
474
- return this[forwardArray].at(index)
475
- }
476
-
477
- /**
478
- * Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth
479
- */
480
- flat(depth?: number): T[] {
481
- return this[forwardArray].flat(depth) as T[]
482
- }
483
-
484
- /**
485
- * Returns a new array formed by applying a given callback function to each element of the array,
486
- * and then flattening the result by one level
487
- */
488
- flatMap<U, This = undefined>(
489
- callback: (this: This, value: T, index: number, array: readonly T[]) => U | ReadonlyArray<U>,
490
- thisArg?: This
491
- ): U[] {
492
- return this[forwardArray].flatMap(callback as any, thisArg)
493
- }
494
-
495
- /**
496
- * Returns a new array with elements in reversed order (ES2023)
497
- */
498
- toReversed(): T[] {
499
- return this[forwardArray].toReversed?.() ?? [...this[forwardArray]].reverse()
500
- }
501
-
502
- /**
503
- * Returns a new array with elements sorted (ES2023)
504
- */
505
- toSorted(compareFn?: ((a: T, b: T) => number) | undefined): T[] {
506
- return this[forwardArray].toSorted?.(compareFn) ?? [...this[forwardArray]].sort(compareFn)
507
- }
508
-
509
- /**
510
- * Returns a new array with some elements removed and/or replaced at a given index (ES2023)
511
- */
512
- toSpliced(start: number, deleteCount?: number, ...items: T[]): T[] {
513
- if (deleteCount === undefined) return this[forwardArray].toSpliced(start)
514
- return this[forwardArray].toSpliced(start, deleteCount, ...items)
515
- }
516
-
517
- /**
518
- * Returns a new array with the element at the given index replaced with the given value (ES2023)
519
- */
520
- with(index: number, value: T): T[] {
521
- return this[forwardArray].with(index, value)
522
- }
523
- get [Symbol.unscopables]() {
524
- return this[forwardArray][Symbol.unscopables]
525
- }
526
- }
@@ -1,59 +0,0 @@
1
- /**
2
- * Introspection API for Mutts
3
- * Designed for AI agents and advanced debugging tools to programmatically analyze the reactive system.
4
- */
5
-
6
- import {
7
- type EffectNode,
8
- forceEnableGraphTracking,
9
- type GraphEdge,
10
- getDependencies,
11
- getDependencyGraph,
12
- getDependents,
13
- getMutationHistory,
14
- type MutationRecord,
15
- type ObjectNode,
16
- type ReactivityGraph,
17
- } from './reactive/debug'
18
- import { options, type ReactiveDebugInfo, ReactiveErrorCode } from './reactive/types'
19
-
20
- export {
21
- getDependencyGraph,
22
- getDependents,
23
- getDependencies,
24
- getMutationHistory,
25
- options,
26
- ReactiveErrorCode,
27
- }
28
-
29
- export type {
30
- MutationRecord,
31
- ReactivityGraph,
32
- EffectNode,
33
- ObjectNode,
34
- GraphEdge,
35
- ReactiveDebugInfo,
36
- }
37
-
38
- /**
39
- * Enable introspection features (history recording, etc.)
40
- * @param config Configuration options
41
- */
42
- export function enableIntrospection(config: { historySize?: number } = {}) {
43
- options.introspection.enableHistory = true
44
- forceEnableGraphTracking()
45
- if (config.historySize) {
46
- options.introspection.historySize = config.historySize
47
- }
48
- }
49
-
50
- /**
51
- * Capture a complete snapshot of the current reactive state
52
- */
53
- export function snapshot() {
54
- return {
55
- graph: getDependencyGraph(),
56
- history: getMutationHistory(),
57
- timestamp: Date.now(),
58
- }
59
- }