@bodil/signal 0.3.5 → 0.4.1

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/dist/array.d.ts CHANGED
@@ -1,33 +1,167 @@
1
+ import type { Equals } from "@bodil/core/types";
1
2
  import { type Option } from "@bodil/opt";
2
- export interface SignalReadonlyArray<A> extends Iterable<A> {
3
+ import * as Signal from "./signal";
4
+ declare const instance: unique symbol;
5
+ type InstanceProps<A> = {
6
+ array: Array<A>;
7
+ signal: Signal.State<null>;
8
+ equals?: (a: A, b: A) => boolean;
9
+ };
10
+ /**
11
+ * A read-only view of a {@link Signal.Array}.
12
+ *
13
+ * This acts just like the {@link Signal.Array} it was created from, mirroring
14
+ * the current contents of the source array, but without the ability to modify
15
+ * it.
16
+ */
17
+ export declare class ReadonlySignalArray<A> implements Iterable<A>, Equals {
18
+ /** @ignore */
19
+ protected readonly [instance]: InstanceProps<A>;
20
+ /** @ignore */
21
+ protected constructor(instanceProps: InstanceProps<A>);
22
+ /**
23
+ * Test whether a value is a `Signal.ReadonlyArray`.
24
+ */
25
+ static is(value: unknown): value is Signal.ReadonlyArray<unknown>;
26
+ /**
27
+ * Test whether the array is empty.
28
+ */
3
29
  isEmpty(): boolean;
30
+ /**
31
+ * Get the size of the array.
32
+ */
4
33
  size(): number;
34
+ /**
35
+ * Find the index at which the given value first occurs in the array,
36
+ * optionally starting at `fromIndex`. If the value doesn't occur in the
37
+ * array, return `-1`.
38
+ */
5
39
  indexOf(value: A, fromIndex?: number): number;
40
+ /**
41
+ * Find the first index in the array for which the `predicate` function
42
+ * returns true for the value at that index, or `-1` if it never does.
43
+ */
6
44
  findIndex(predicate: (value: A, index: number, obj: Array<A>) => boolean, thisArg?: any): number;
45
+ /**
46
+ * Test whether a value is an array with identical contents to this array.
47
+ */
48
+ equals(other: unknown): other is Signal.ReadonlyArray<A>;
49
+ /**
50
+ * Copy the contents of this array into a normal {@link Array}.
51
+ */
7
52
  toArray(): Array<A>;
53
+ /**
54
+ * Get the value at the given index, or {@link None} if the index is out of
55
+ * bounds.
56
+ *
57
+ * @throws {@link TypeError} of `index` is not an integer
58
+ */
8
59
  get(index: number): Option<A>;
9
- }
10
- export declare class SignalArray<A> implements Iterable<A>, SignalReadonlyArray<A> {
11
- #private;
12
- static from<T>(iterable: Iterable<T>): SignalArray<T>;
13
- constructor(iterable: Iterable<A>);
60
+ /**
61
+ * Iterate over the contents of the array.
62
+ */
14
63
  [Symbol.iterator](): IteratorObject<A>;
15
- isEmpty(): boolean;
16
- size(): number;
17
- indexOf(value: A, fromIndex?: number): number;
18
- findIndex(predicate: (value: A, index: number, obj: Array<A>) => boolean, thisArg?: any): number;
19
- toArray(): Array<A>;
20
- get(index: number): Option<A>;
21
- readOnly(): SignalReadonlyArray<A>;
22
- set(index: number, value: A): void;
64
+ }
65
+ /**
66
+ * An array which behaves like a signal.
67
+ *
68
+ * Any read operation on the array, like {@link Signal.Array.get},
69
+ * {@link Signal.Array.size}, or iteration, acts like a
70
+ * {@link Signal.State.get}, registering the array as a dependency in any
71
+ * computed signals or effects it's used in. Correspondingly, any write
72
+ * operation to the array will cause all of these dependencies to update as
73
+ * with a {@link Signal.State.set}.
74
+ *
75
+ * Note that the API of this array is different from the built-in
76
+ * {@link Array}. This is intentional. Additionally, many operations you'd
77
+ * expect to find on an array, like {@link Array.map} or predicates like
78
+ * {@link Array.every}, are missing from the array itself. It's recommended
79
+ * that you access these through {@link Iterator}s instead.
80
+ *
81
+ * Note also that array access doesn't come with any granularity: if you read
82
+ * only a single index from the array inside a computed signal, *any* change to
83
+ * the array causes the signal to recompute, regardless of whether the value at
84
+ * the index you read changed.
85
+ */
86
+ export declare class SignalArray<A> extends ReadonlySignalArray<A> {
87
+ /**
88
+ * Construct a new array with the contents of the provided iterable.
89
+ */
90
+ static from<T>(iterable: Iterable<T>): Signal.Array<T>;
91
+ /**
92
+ * Test whether a value is a `Signal.Array`.
93
+ */
94
+ static is(value: unknown): value is Signal.Array<unknown>;
95
+ /**
96
+ * Construct a new array, optionally filling it with the contents of the
97
+ * provided iterable.
98
+ */
99
+ constructor(iterable?: Iterable<A>, options?: Signal.Options<A>);
100
+ /**
101
+ * Return a read-only view of the array.
102
+ */
103
+ readOnly(): Signal.ReadonlyArray<A>;
104
+ /**
105
+ * Write the given value to the given index of the array, overwriting
106
+ * anything that may have been there before.
107
+ *
108
+ * @throws {@link TypeError} if `index` is negative or not an integer
109
+ */
110
+ set(index: number, value: A): this;
111
+ /**
112
+ * Append the provided values to the end of the array.
113
+ *
114
+ * @returns the number of values that were inserted.
115
+ */
23
116
  push(...values: Array<A>): number;
117
+ /**
118
+ * Prepend the provided values to the start of the array.
119
+ *
120
+ * @returns the number of values that were inserted.
121
+ */
24
122
  unshift(...values: Array<A>): number;
123
+ /**
124
+ * Remove the item at the front of the array and return it.
125
+ */
25
126
  pop(): Option<A>;
127
+ /**
128
+ * Remove the item at the end of the array and return it.
129
+ */
26
130
  shift(): Option<A>;
27
- splice(start: number, deleteCount: number, ...values: Array<A>): Array<A>;
131
+ /** @see {@link Array.splice} */
132
+ splice(start: number, deleteCount?: number, ...values: Array<A>): Array<A>;
133
+ /**
134
+ * Insert the given values starting at the given index, shifting the
135
+ * remainder of the array to higher indices accordingly.
136
+ *
137
+ * @throws {@link TypeError} if `index` is not an integer
138
+ */
28
139
  insert(index: number, ...values: Array<A>): this;
140
+ /**
141
+ * Remove the value at the given index and return it. If there's no value at
142
+ * the given index, return {@link None}.
143
+ *
144
+ * @throws {@link TypeError} if `index` is not an integer
145
+ */
29
146
  removeIndex(index: number): Option<A>;
147
+ /**
148
+ * Remove the first occurrence of the given value from the array, if it
149
+ * exists in the array.
150
+ */
30
151
  remove(value: A): Option<A>;
152
+ /**
153
+ * Remove the first value from the array that matches the given predicate
154
+ * function, if any.
155
+ */
31
156
  removeFn(predicate: (value: A, index: number, obj: Array<A>) => boolean): Option<A>;
157
+ /**
158
+ * Discard all values in the array, leaving an empty array.
159
+ */
32
160
  clear(): this;
161
+ /**
162
+ * Replace the contents of this array with the values contained in
163
+ * `iterable`.
164
+ */
165
+ replace(iterable: Iterable<A>): this;
33
166
  }
167
+ export {};
package/dist/array.js CHANGED
@@ -1,126 +1,303 @@
1
1
  import { None, Some } from "@bodil/opt";
2
- import { Signal } from ".";
3
- export class SignalArray {
4
- #array;
5
- #signal = Signal(null, { equals: () => false });
6
- static from(iterable) {
7
- return new SignalArray(iterable);
8
- }
9
- constructor(iterable) {
10
- this.#array = [...iterable];
2
+ import * as Signal from "./signal";
3
+ const instance = Symbol("Signal.Array");
4
+ function arraysEqual(a, b, equals) {
5
+ return a.length === b.length && a.every((value, index) => equals(value, b[index]));
6
+ }
7
+ /**
8
+ * A read-only view of a {@link Signal.Array}.
9
+ *
10
+ * This acts just like the {@link Signal.Array} it was created from, mirroring
11
+ * the current contents of the source array, but without the ability to modify
12
+ * it.
13
+ */
14
+ export class ReadonlySignalArray {
15
+ /** @ignore */
16
+ constructor(instanceProps) {
17
+ this[instance] = instanceProps;
11
18
  }
12
- [Symbol.iterator]() {
13
- this.#signal.get();
14
- return Iterator.from(this.#array);
19
+ /**
20
+ * Test whether a value is a `Signal.ReadonlyArray`.
21
+ */
22
+ static is(value) {
23
+ return value instanceof ReadonlySignalArray;
15
24
  }
25
+ /**
26
+ * Test whether the array is empty.
27
+ */
16
28
  isEmpty() {
17
- this.#signal.get();
18
- return this.#array.length === 0;
29
+ const self = this[instance];
30
+ self.signal.get();
31
+ return self.array.length === 0;
19
32
  }
33
+ /**
34
+ * Get the size of the array.
35
+ */
20
36
  size() {
21
- this.#signal.get();
22
- return this.#array.length;
37
+ const self = this[instance];
38
+ self.signal.get();
39
+ return self.array.length;
23
40
  }
41
+ /**
42
+ * Find the index at which the given value first occurs in the array,
43
+ * optionally starting at `fromIndex`. If the value doesn't occur in the
44
+ * array, return `-1`.
45
+ */
24
46
  indexOf(value, fromIndex) {
25
- this.#signal.get();
26
- return this.#array.indexOf(value, fromIndex);
47
+ const self = this[instance];
48
+ self.signal.get();
49
+ return self.array.indexOf(value, fromIndex);
27
50
  }
51
+ /**
52
+ * Find the first index in the array for which the `predicate` function
53
+ * returns true for the value at that index, or `-1` if it never does.
54
+ */
28
55
  findIndex(predicate, thisArg) {
29
- this.#signal.get();
30
- return this.#array.findIndex(predicate, thisArg);
56
+ const self = this[instance];
57
+ self.signal.get();
58
+ return self.array.findIndex(predicate, thisArg);
31
59
  }
60
+ /**
61
+ * Test whether a value is an array with identical contents to this array.
62
+ */
63
+ equals(other) {
64
+ if (!ReadonlySignalArray.is(other)) {
65
+ return false;
66
+ }
67
+ const self = this[instance];
68
+ self.signal.get();
69
+ other[instance].signal.get();
70
+ return arraysEqual(self.array, other[instance].array, self.equals ?? Object.is);
71
+ }
72
+ /**
73
+ * Copy the contents of this array into a normal {@link Array}.
74
+ */
32
75
  toArray() {
33
- this.#signal.get();
34
- return this.#array.slice();
76
+ const self = this[instance];
77
+ self.signal.get();
78
+ return self.array.slice();
35
79
  }
80
+ /**
81
+ * Get the value at the given index, or {@link None} if the index is out of
82
+ * bounds.
83
+ *
84
+ * @throws {@link TypeError} of `index` is not an integer
85
+ */
36
86
  get(index) {
37
87
  if (!Number.isInteger(index)) {
38
88
  throw new TypeError(`Signal.Array.get: index ${index} is not an integer`);
39
89
  }
40
- this.#signal.get();
41
- return index >= 0 && this.#array.length > index ? Some(this.#array[index]) : None;
90
+ const self = this[instance];
91
+ self.signal.get();
92
+ return Object.hasOwn(this, index) ? Some(self.array[index]) : None;
93
+ }
94
+ /**
95
+ * Iterate over the contents of the array.
96
+ */
97
+ [Symbol.iterator]() {
98
+ const self = this[instance];
99
+ self.signal.get();
100
+ return Iterator.from(self.array);
101
+ }
102
+ }
103
+ /**
104
+ * An array which behaves like a signal.
105
+ *
106
+ * Any read operation on the array, like {@link Signal.Array.get},
107
+ * {@link Signal.Array.size}, or iteration, acts like a
108
+ * {@link Signal.State.get}, registering the array as a dependency in any
109
+ * computed signals or effects it's used in. Correspondingly, any write
110
+ * operation to the array will cause all of these dependencies to update as
111
+ * with a {@link Signal.State.set}.
112
+ *
113
+ * Note that the API of this array is different from the built-in
114
+ * {@link Array}. This is intentional. Additionally, many operations you'd
115
+ * expect to find on an array, like {@link Array.map} or predicates like
116
+ * {@link Array.every}, are missing from the array itself. It's recommended
117
+ * that you access these through {@link Iterator}s instead.
118
+ *
119
+ * Note also that array access doesn't come with any granularity: if you read
120
+ * only a single index from the array inside a computed signal, *any* change to
121
+ * the array causes the signal to recompute, regardless of whether the value at
122
+ * the index you read changed.
123
+ */
124
+ export class SignalArray extends ReadonlySignalArray {
125
+ /**
126
+ * Construct a new array with the contents of the provided iterable.
127
+ */
128
+ static from(iterable) {
129
+ return new SignalArray(iterable);
130
+ }
131
+ /**
132
+ * Test whether a value is a `Signal.Array`.
133
+ */
134
+ static is(value) {
135
+ return value instanceof SignalArray;
42
136
  }
137
+ /**
138
+ * Construct a new array, optionally filling it with the contents of the
139
+ * provided iterable.
140
+ */
141
+ constructor(iterable = [], options) {
142
+ super({
143
+ array: Array.from(iterable),
144
+ signal: new Signal.State(null, { equals: () => false }),
145
+ equals: options?.equals,
146
+ });
147
+ }
148
+ /**
149
+ * Return a read-only view of the array.
150
+ */
43
151
  readOnly() {
44
- return this;
152
+ return new ReadonlySignalArray(this[instance]);
45
153
  }
154
+ /**
155
+ * Write the given value to the given index of the array, overwriting
156
+ * anything that may have been there before.
157
+ *
158
+ * @throws {@link TypeError} if `index` is negative or not an integer
159
+ */
46
160
  set(index, value) {
47
161
  if (!Number.isInteger(index)) {
48
162
  throw new TypeError(`Signal.Array.set: index ${index} is not an integer`);
49
163
  }
50
- if (index > this.#array.length || index < 0) {
164
+ if (index < 0) {
51
165
  throw new RangeError(`Signal.Array.set: index ${index} out of bounds`);
52
166
  }
53
- this.#array[index] = value;
54
- this.#signal.set(null);
167
+ const self = this[instance];
168
+ if (!(self.equals ?? Object.is)(self.array[index], value)) {
169
+ self.array[index] = value;
170
+ self.signal.set(null);
171
+ }
172
+ return this;
55
173
  }
174
+ /**
175
+ * Append the provided values to the end of the array.
176
+ *
177
+ * @returns the number of values that were inserted.
178
+ */
56
179
  push(...values) {
57
- const result = this.#array.push(...values);
58
- this.#signal.set(null);
180
+ const self = this[instance];
181
+ const result = self.array.push(...values);
182
+ self.signal.set(null);
59
183
  return result;
60
184
  }
185
+ /**
186
+ * Prepend the provided values to the start of the array.
187
+ *
188
+ * @returns the number of values that were inserted.
189
+ */
61
190
  unshift(...values) {
62
- const result = this.#array.unshift(...values);
63
- this.#signal.set(null);
191
+ const self = this[instance];
192
+ const result = self.array.unshift(...values);
193
+ self.signal.set(null);
64
194
  return result;
65
195
  }
196
+ /**
197
+ * Remove the item at the front of the array and return it.
198
+ */
66
199
  pop() {
67
200
  if (this.isEmpty()) {
68
201
  return None;
69
202
  }
70
- const result = this.#array.pop();
71
- this.#signal.set(null);
203
+ const self = this[instance];
204
+ const result = self.array.pop();
205
+ self.signal.set(null);
72
206
  return Some(result);
73
207
  }
208
+ /**
209
+ * Remove the item at the end of the array and return it.
210
+ */
74
211
  shift() {
75
212
  if (this.isEmpty()) {
76
213
  return None;
77
214
  }
78
- const result = this.#array.shift();
79
- this.#signal.set(null);
215
+ const self = this[instance];
216
+ const result = self.array.shift();
217
+ self.signal.set(null);
80
218
  return Some(result);
81
219
  }
220
+ /** @see {@link Array.splice} */
82
221
  splice(start, deleteCount, ...values) {
83
222
  if (!Number.isInteger(start)) {
84
- throw new TypeError(`Signal.Array.splice: index ${start} is not an integer`);
223
+ throw new TypeError(`Signal.Array.splice: start ${start} is not an integer`);
85
224
  }
86
- if (start > this.#array.length || start < 0) {
87
- throw new RangeError(`Signal.Array.splice: index ${start} out of bounds`);
225
+ if (deleteCount !== undefined && !Number.isInteger(deleteCount)) {
226
+ throw new TypeError(`Signal.Array.splice: deleteCount ${deleteCount} is not an integer`);
88
227
  }
89
- const result = this.#array.splice(start, deleteCount, ...values);
90
- this.#signal.set(null);
228
+ const self = this[instance];
229
+ const result = self.array.splice(start, deleteCount, ...values);
230
+ self.signal.set(null);
91
231
  return result;
92
232
  }
233
+ /**
234
+ * Insert the given values starting at the given index, shifting the
235
+ * remainder of the array to higher indices accordingly.
236
+ *
237
+ * @throws {@link TypeError} if `index` is not an integer
238
+ */
93
239
  insert(index, ...values) {
94
240
  if (!Number.isInteger(index)) {
95
241
  throw new TypeError(`Signal.Array.insert: index ${index} is not an integer`);
96
242
  }
97
- if (index > this.#array.length || index < 0) {
98
- throw new RangeError(`Signal.Array.insert: index ${index} out of bounds`);
99
- }
100
- this.#array.splice(index, 0, ...values);
101
- this.#signal.set(null);
243
+ this.splice(index, 0, ...values);
102
244
  return this;
103
245
  }
246
+ /**
247
+ * Remove the value at the given index and return it. If there's no value at
248
+ * the given index, return {@link None}.
249
+ *
250
+ * @throws {@link TypeError} if `index` is not an integer
251
+ */
104
252
  removeIndex(index) {
105
253
  if (!Number.isInteger(index)) {
106
254
  throw new TypeError(`Signal.Array.removeIndex: index ${index} is not an integer`);
107
255
  }
108
- if (index < 0 || index >= this.#array.length) {
256
+ if (!Object.hasOwn(this, index)) {
109
257
  return None;
110
258
  }
111
- const removed = this.#array.splice(index, 1).pop();
112
- this.#signal.set(null);
259
+ const self = this[instance];
260
+ const removed = self.array.splice(index, 1).pop();
261
+ self.signal.set(null);
113
262
  return Some(removed);
114
263
  }
264
+ /**
265
+ * Remove the first occurrence of the given value from the array, if it
266
+ * exists in the array.
267
+ */
115
268
  remove(value) {
116
- return this.removeIndex(this.indexOf(value));
269
+ const index = this.indexOf(value);
270
+ return index < 0 ? None : this.removeIndex(index);
117
271
  }
272
+ /**
273
+ * Remove the first value from the array that matches the given predicate
274
+ * function, if any.
275
+ */
118
276
  removeFn(predicate) {
119
- return this.removeIndex(this.findIndex(predicate));
277
+ const index = this.findIndex(predicate);
278
+ return index < 0 ? None : this.removeIndex(index);
120
279
  }
280
+ /**
281
+ * Discard all values in the array, leaving an empty array.
282
+ */
121
283
  clear() {
122
- this.#array = [];
123
- this.#signal.set(null);
284
+ const self = this[instance];
285
+ self.array = [];
286
+ self.signal.set(null);
287
+ return this;
288
+ }
289
+ /**
290
+ * Replace the contents of this array with the values contained in
291
+ * `iterable`.
292
+ */
293
+ replace(iterable) {
294
+ const self = this[instance];
295
+ const oldArray = self.array;
296
+ const newArray = Array.from(iterable);
297
+ if (!arraysEqual(oldArray, newArray, self.equals ?? Object.is)) {
298
+ self.array = newArray;
299
+ self.signal.set(null);
300
+ }
124
301
  return this;
125
302
  }
126
303
  }
package/dist/array.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"array.js","sourceRoot":"","sources":["../src/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAc3B,MAAM,OAAO,WAAW;IACpB,MAAM,CAAW;IACR,OAAO,GAAG,MAAM,CAAO,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;IAE/D,MAAM,CAAC,IAAI,CAAI,QAAqB;QAChC,OAAO,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,YAAY,QAAqB;QAC7B,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACb,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QACnB,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,OAAO;QACH,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,IAAI;QACA,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,MAAM,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C;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;YAC7D,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}
@@ -1,6 +1,7 @@
1
+ import { sleep } from "@bodil/core/async";
1
2
  import { expect, test } from "vitest";
2
3
  import { Signal } from ".";
3
- test("SignalArray", () => {
4
+ test("Signal.Array", () => {
4
5
  const t = Signal.array([1, 2, 3]);
5
6
  const length = Signal.computed(() => t.size());
6
7
  const three = Signal.computed(() => t.indexOf(3));
@@ -25,4 +26,36 @@ test("SignalArray", () => {
25
26
  expect(t.toArray()).toEqual([0, 1, 2, 3, 4]);
26
27
  expect(inc.get()).toEqual([1, 2, 3, 4, 5]);
27
28
  });
29
+ test("Signal.Array.equals", () => {
30
+ const a = Signal.array([1, 2, 3, 4, 5]);
31
+ const b = Signal.array([1, 2, 3, 4, 5]);
32
+ expect(a.equals(b)).toBeTruthy();
33
+ const c = Signal.array([1, 2, 3, 5, 4]);
34
+ expect(a.equals(c)).toBeFalsy();
35
+ const d = Signal.array([1, 2, 3, 4]);
36
+ expect(a.equals(d)).toBeFalsy();
37
+ const e = [1, 2, 3, 4, 5];
38
+ expect(a.equals(e)).toBeFalsy();
39
+ });
40
+ test("Signal.Array.replace", async () => {
41
+ const a = Signal.array([1, 2, 3, 4, 5]);
42
+ let updates = 0;
43
+ Signal.effect(() => {
44
+ a.size();
45
+ updates++;
46
+ });
47
+ expect(updates).toBe(1);
48
+ a.set(2, 0);
49
+ await sleep(1);
50
+ expect(updates).toBe(2);
51
+ expect(a.toArray()).toEqual([1, 2, 0, 4, 5]);
52
+ a.replace([1, 2, 0, 4, 5]);
53
+ await sleep(1);
54
+ expect(updates).toBe(2);
55
+ expect(a.toArray()).toEqual([1, 2, 0, 4, 5]);
56
+ a.replace([1, 2, 3, 5, 4]);
57
+ await sleep(1);
58
+ expect(a.toArray()).toEqual([1, 2, 3, 5, 4]);
59
+ expect(updates).toBe(3);
60
+ });
28
61
  //# sourceMappingURL=array.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"array.test.js","sourceRoot":"","sources":["../src/array.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAE3B,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;IACrB,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAC7B,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;SACjB,OAAO,EAAE,CACjB,CAAC;IAEF,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,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