@dxos/util 0.6.13-main.ed424a1 → 0.6.13
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/lib/browser/index.mjs +140 -105
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +132 -96
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/complex.d.ts +8 -8
- package/dist/types/src/complex.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/params.d.ts +22 -0
- package/dist/types/src/params.d.ts.map +1 -0
- package/dist/types/src/params.test.d.ts +2 -0
- package/dist/types/src/params.test.d.ts.map +1 -0
- package/dist/types/src/platform.test.d.ts +2 -0
- package/dist/types/src/platform.test.d.ts.map +1 -0
- package/dist/types/src/weak.d.ts +4 -4
- package/dist/types/src/weak.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/array.test.ts +2 -1
- package/src/bitfield.test.ts +2 -1
- package/src/callback.test.ts +2 -1
- package/src/complex.test.ts +2 -1
- package/src/complex.ts +8 -8
- package/src/defer.test.ts +2 -1
- package/src/human-hash.test.ts +2 -1
- package/src/index.ts +3 -5
- package/src/join-tables.test.ts +2 -1
- package/src/order.test.ts +2 -1
- package/src/params.test.ts +38 -0
- package/src/params.ts +68 -0
- package/src/platform.test.ts +17 -0
- package/src/reducers.test.ts +2 -1
- package/src/safe-instanceof.test.ts +2 -1
- package/src/sort.test.ts +2 -1
- package/src/tracer.test.ts +2 -1
- package/src/types.test.ts +2 -1
- package/src/typings.d.ts +5 -0
- package/src/uint8array.test.ts +2 -1
- package/src/weak.test.ts +8 -4
- package/src/weak.ts +4 -4
- package/dist/lib/node-esm/index.mjs +0 -1943
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/types/src/array-to-hex.d.ts +0 -2
- package/dist/types/src/array-to-hex.d.ts.map +0 -1
- package/dist/types/src/platform.browser.test.d.ts +0 -2
- package/dist/types/src/platform.browser.test.d.ts.map +0 -1
- package/dist/types/src/platform.node.test.d.ts +0 -2
- package/dist/types/src/platform.node.test.d.ts.map +0 -1
- package/src/array-to-hex.ts +0 -23
- package/src/platform.browser.test.ts +0 -11
- package/src/platform.node.test.ts +0 -11
package/src/sort.test.ts
CHANGED
package/src/tracer.test.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { expect } from 'chai';
|
|
6
|
+
import { describe, test } from 'vitest';
|
|
6
7
|
|
|
7
8
|
import { createBucketReducer, numericalValues, reduceGroupBy, reduceSeries, reduceSet } from './reducers';
|
|
8
9
|
import { Tracer } from './tracer';
|
package/src/types.test.ts
CHANGED
package/src/typings.d.ts
ADDED
package/src/uint8array.test.ts
CHANGED
package/src/weak.test.ts
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { expect } from 'chai';
|
|
6
|
+
import { test, describe } from 'vitest';
|
|
7
|
+
import waitForExpect from 'wait-for-expect';
|
|
6
8
|
|
|
7
9
|
import { WeakDictionary } from './weak';
|
|
8
10
|
|
|
9
11
|
describe('WeakDictionary', () => {
|
|
10
12
|
// Skipped because it takes a long time for garbage collection to kick in (~8 sec)
|
|
11
13
|
// but it works otherwise.
|
|
12
|
-
test.skip('unref item gets garbage collected',
|
|
14
|
+
test.skip('unref item gets garbage collected', async () => {
|
|
13
15
|
const map = new WeakDictionary<string, any>();
|
|
14
16
|
const key = 'key';
|
|
15
17
|
|
|
@@ -30,8 +32,10 @@ describe('WeakDictionary', () => {
|
|
|
30
32
|
|
|
31
33
|
setValue();
|
|
32
34
|
// Garbage collection should remove the item because no references exist.
|
|
33
|
-
await
|
|
35
|
+
await waitForExpect(() => {
|
|
36
|
+
expect(map.size).to.equal(0);
|
|
37
|
+
}, 20000);
|
|
34
38
|
|
|
35
39
|
expect(map.has(key)).to.equal(false);
|
|
36
|
-
});
|
|
40
|
+
}, 20_000);
|
|
37
41
|
});
|
package/src/weak.ts
CHANGED
|
@@ -16,17 +16,17 @@ export class WeakDictionary<K, V extends object> implements Map<K, V> {
|
|
|
16
16
|
entries?.forEach(([key, value]) => this._register(key, value));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
*entries():
|
|
19
|
+
*entries(): IterableIterator<[K, V]> {
|
|
20
20
|
for (const [key, value] of this._internal) {
|
|
21
21
|
yield [key, value.deref()!];
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
keys():
|
|
25
|
+
keys(): IterableIterator<K> {
|
|
26
26
|
return this._internal.keys();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
*values():
|
|
29
|
+
*values(): IterableIterator<V> {
|
|
30
30
|
for (const value of this._internal.values()) {
|
|
31
31
|
const deref = value.deref();
|
|
32
32
|
if (!deref) {
|
|
@@ -36,7 +36,7 @@ export class WeakDictionary<K, V extends object> implements Map<K, V> {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
*[Symbol.iterator]():
|
|
39
|
+
*[Symbol.iterator](): IterableIterator<[K, V]> {
|
|
40
40
|
for (const [key, value] of this._internal) {
|
|
41
41
|
yield [key, value.deref()!];
|
|
42
42
|
}
|