@dxos/util 0.6.11 → 0.6.12-main.5a87ad5
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 +92 -92
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +83 -83
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1978 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- 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 +4 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/params.d.ts.map +1 -1
- package/dist/types/src/platform.browser.test.d.ts +2 -0
- package/dist/types/src/platform.browser.test.d.ts.map +1 -0
- package/dist/types/src/platform.node.test.d.ts +2 -0
- package/dist/types/src/platform.node.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 +8 -7
- package/src/array.test.ts +1 -2
- package/src/bitfield.test.ts +1 -2
- package/src/callback.test.ts +1 -2
- package/src/complex.test.ts +1 -2
- package/src/complex.ts +8 -8
- package/src/defer.test.ts +1 -2
- package/src/human-hash.test.ts +1 -2
- package/src/index.ts +4 -4
- package/src/join-tables.test.ts +1 -2
- package/src/order.test.ts +1 -2
- package/src/params.test.ts +1 -2
- package/src/params.ts +2 -0
- package/src/platform.browser.test.ts +11 -0
- package/src/platform.node.test.ts +11 -0
- package/src/reducers.test.ts +1 -2
- package/src/safe-instanceof.test.ts +1 -2
- package/src/sort.test.ts +1 -2
- package/src/tracer.test.ts +1 -2
- package/src/types.test.ts +1 -2
- package/src/uint8array.test.ts +1 -2
- package/src/weak.test.ts +4 -8
- package/src/weak.ts +4 -4
- package/dist/types/src/platform.test.d.ts +0 -2
- package/dist/types/src/platform.test.d.ts.map +0 -1
- package/src/platform.test.ts +0 -17
- package/src/typings.d.ts +0 -5
package/src/complex.ts
CHANGED
|
@@ -78,21 +78,21 @@ export class ComplexSet<T> implements Set<T> {
|
|
|
78
78
|
return this._values.size;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
[Symbol.iterator]():
|
|
81
|
+
[Symbol.iterator](): SetIterator<T> {
|
|
82
82
|
return this._values.values();
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
*entries():
|
|
85
|
+
*entries(): SetIterator<[T, T]> {
|
|
86
86
|
for (const value of this._values.values()) {
|
|
87
87
|
yield [value, value];
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
keys():
|
|
91
|
+
keys(): SetIterator<T> {
|
|
92
92
|
return this[Symbol.iterator]();
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
values():
|
|
95
|
+
values(): SetIterator<T> {
|
|
96
96
|
return this[Symbol.iterator]();
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -218,22 +218,22 @@ export class ComplexMap<K, V> implements Map<K, V> {
|
|
|
218
218
|
return this._keys.size;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
*[Symbol.iterator]():
|
|
221
|
+
*[Symbol.iterator](): SetIterator<[K, V]> {
|
|
222
222
|
for (const [primitive, key] of this._keys) {
|
|
223
223
|
const value = this._values.get(primitive) ?? raise(new Error('Map corrupted.'));
|
|
224
224
|
yield [key, value];
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
entries():
|
|
228
|
+
entries(): SetIterator<[K, V]> {
|
|
229
229
|
return this[Symbol.iterator]();
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
keys():
|
|
232
|
+
keys(): SetIterator<K> {
|
|
233
233
|
return this._keys.values();
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
values():
|
|
236
|
+
values(): SetIterator<V> {
|
|
237
237
|
return this._values.values();
|
|
238
238
|
}
|
|
239
239
|
|
package/src/defer.test.ts
CHANGED
package/src/human-hash.test.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -7,6 +7,8 @@ export * from './assign';
|
|
|
7
7
|
export * from './binder';
|
|
8
8
|
export * from './bitfield';
|
|
9
9
|
export * from './callback';
|
|
10
|
+
export * from './callback-collection';
|
|
11
|
+
export * from './chunk-array';
|
|
10
12
|
export * from './circular-buffer';
|
|
11
13
|
export * from './complex';
|
|
12
14
|
export * from './defer';
|
|
@@ -30,14 +32,12 @@ export * from './reducers';
|
|
|
30
32
|
export * from './safe-await';
|
|
31
33
|
export * from './safe-instanceof';
|
|
32
34
|
export * from './safe-parse-json';
|
|
35
|
+
export * from './sliding-window-summary';
|
|
33
36
|
export * from './sort';
|
|
37
|
+
export * from './sum';
|
|
34
38
|
export * from './throw-unhandled-error';
|
|
35
39
|
export * from './to-fallback';
|
|
36
40
|
export * from './tracer';
|
|
37
41
|
export * from './types';
|
|
38
42
|
export * from './uint8array';
|
|
39
|
-
export * from './sum';
|
|
40
43
|
export * from './weak';
|
|
41
|
-
export * from './sliding-window-summary';
|
|
42
|
-
export * from './callback-collection';
|
|
43
|
-
export * from './chunk-array';
|
package/src/join-tables.test.ts
CHANGED
package/src/order.test.ts
CHANGED
package/src/params.test.ts
CHANGED
package/src/params.ts
CHANGED
|
@@ -13,7 +13,9 @@ import { decamelize } from 'xcase';
|
|
|
13
13
|
// TODO(burdon): Change annotations.
|
|
14
14
|
|
|
15
15
|
type ParamKeyAnnotationType = string;
|
|
16
|
+
|
|
16
17
|
const ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKeyAnnotation');
|
|
18
|
+
|
|
17
19
|
export const ParamKeyAnnotation =
|
|
18
20
|
(value: ParamKeyAnnotationType) =>
|
|
19
21
|
<S extends Annotable.All>(self: S): Annotable.Self<S> =>
|
package/src/reducers.test.ts
CHANGED
package/src/sort.test.ts
CHANGED
package/src/tracer.test.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
6
|
-
import { describe, test } from 'vitest';
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
7
6
|
|
|
8
7
|
import { createBucketReducer, numericalValues, reduceGroupBy, reduceSeries, reduceSet } from './reducers';
|
|
9
8
|
import { Tracer } from './tracer';
|
package/src/types.test.ts
CHANGED
package/src/uint8array.test.ts
CHANGED
package/src/weak.test.ts
CHANGED
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
6
|
-
import { test, describe } from 'vitest';
|
|
7
|
-
import waitForExpect from 'wait-for-expect';
|
|
5
|
+
import { test, expect, describe } from 'vitest';
|
|
8
6
|
|
|
9
7
|
import { WeakDictionary } from './weak';
|
|
10
8
|
|
|
11
9
|
describe('WeakDictionary', () => {
|
|
12
10
|
// Skipped because it takes a long time for garbage collection to kick in (~8 sec)
|
|
13
11
|
// but it works otherwise.
|
|
14
|
-
test.skip('unref item gets garbage collected', async () => {
|
|
12
|
+
test.skip('unref item gets garbage collected', { timeout: 20_000 }, async () => {
|
|
15
13
|
const map = new WeakDictionary<string, any>();
|
|
16
14
|
const key = 'key';
|
|
17
15
|
|
|
@@ -32,10 +30,8 @@ describe('WeakDictionary', () => {
|
|
|
32
30
|
|
|
33
31
|
setValue();
|
|
34
32
|
// Garbage collection should remove the item because no references exist.
|
|
35
|
-
await
|
|
36
|
-
expect(map.size).to.equal(0);
|
|
37
|
-
}, 20000);
|
|
33
|
+
await expect.poll(() => map.size, { timeout: 20_000 }).toEqual(0);
|
|
38
34
|
|
|
39
35
|
expect(map.has(key)).to.equal(false);
|
|
40
|
-
}
|
|
36
|
+
});
|
|
41
37
|
});
|
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(): SetIterator<[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(): SetIterator<K> {
|
|
26
26
|
return this._internal.keys();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
*values():
|
|
29
|
+
*values(): SetIterator<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](): SetIterator<[K, V]> {
|
|
40
40
|
for (const [key, value] of this._internal) {
|
|
41
41
|
yield [key, value.deref()!];
|
|
42
42
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platform.test.d.ts","sourceRoot":"","sources":["../../../src/platform.test.ts"],"names":[],"mappings":""}
|
package/src/platform.test.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2020 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { expect } from 'chai';
|
|
6
|
-
import { test } from 'vitest';
|
|
7
|
-
|
|
8
|
-
import { isNode } from './platform';
|
|
9
|
-
|
|
10
|
-
// TODO(dmaretskyi): Broken with vitest conversion.
|
|
11
|
-
test.skip('knows when running in node', () => {
|
|
12
|
-
if (mochaExecutor.environment === 'nodejs') {
|
|
13
|
-
expect(isNode()).to.be.true;
|
|
14
|
-
} else {
|
|
15
|
-
expect(isNode()).to.be.false;
|
|
16
|
-
}
|
|
17
|
-
});
|