@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.
Files changed (53) hide show
  1. package/dist/lib/browser/index.mjs +140 -105
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +132 -96
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/types/src/complex.d.ts +8 -8
  8. package/dist/types/src/complex.d.ts.map +1 -1
  9. package/dist/types/src/index.d.ts +3 -5
  10. package/dist/types/src/index.d.ts.map +1 -1
  11. package/dist/types/src/params.d.ts +22 -0
  12. package/dist/types/src/params.d.ts.map +1 -0
  13. package/dist/types/src/params.test.d.ts +2 -0
  14. package/dist/types/src/params.test.d.ts.map +1 -0
  15. package/dist/types/src/platform.test.d.ts +2 -0
  16. package/dist/types/src/platform.test.d.ts.map +1 -0
  17. package/dist/types/src/weak.d.ts +4 -4
  18. package/dist/types/src/weak.d.ts.map +1 -1
  19. package/package.json +9 -8
  20. package/src/array.test.ts +2 -1
  21. package/src/bitfield.test.ts +2 -1
  22. package/src/callback.test.ts +2 -1
  23. package/src/complex.test.ts +2 -1
  24. package/src/complex.ts +8 -8
  25. package/src/defer.test.ts +2 -1
  26. package/src/human-hash.test.ts +2 -1
  27. package/src/index.ts +3 -5
  28. package/src/join-tables.test.ts +2 -1
  29. package/src/order.test.ts +2 -1
  30. package/src/params.test.ts +38 -0
  31. package/src/params.ts +68 -0
  32. package/src/platform.test.ts +17 -0
  33. package/src/reducers.test.ts +2 -1
  34. package/src/safe-instanceof.test.ts +2 -1
  35. package/src/sort.test.ts +2 -1
  36. package/src/tracer.test.ts +2 -1
  37. package/src/types.test.ts +2 -1
  38. package/src/typings.d.ts +5 -0
  39. package/src/uint8array.test.ts +2 -1
  40. package/src/weak.test.ts +8 -4
  41. package/src/weak.ts +4 -4
  42. package/dist/lib/node-esm/index.mjs +0 -1943
  43. package/dist/lib/node-esm/index.mjs.map +0 -7
  44. package/dist/lib/node-esm/meta.json +0 -1
  45. package/dist/types/src/array-to-hex.d.ts +0 -2
  46. package/dist/types/src/array-to-hex.d.ts.map +0 -1
  47. package/dist/types/src/platform.browser.test.d.ts +0 -2
  48. package/dist/types/src/platform.browser.test.d.ts.map +0 -1
  49. package/dist/types/src/platform.node.test.d.ts +0 -2
  50. package/dist/types/src/platform.node.test.d.ts.map +0 -1
  51. package/src/array-to-hex.ts +0 -23
  52. package/src/platform.browser.test.ts +0 -11
  53. package/src/platform.node.test.ts +0 -11
@@ -2,7 +2,8 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { describe, expect, test } from 'vitest';
5
+ import { expect } from 'chai';
6
+ import { describe, test } from 'vitest';
6
7
 
7
8
  import { safeInstanceof } from './safe-instanceof';
8
9
 
package/src/sort.test.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { describe, expect, test } from 'vitest';
5
+ import { expect } from 'chai';
6
+ import { describe, test } from 'vitest';
6
7
 
7
8
  import { compareMulti, compareScalar, compareObject, compareString } from './sort';
8
9
 
@@ -2,7 +2,8 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { describe, expect, test } from 'vitest';
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
@@ -2,7 +2,8 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { describe, expect, test } from 'vitest';
5
+ import { expect } from 'chai';
6
+ import { describe, test } from 'vitest';
6
7
 
7
8
  import { nonNullable } from './types';
8
9
 
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ declare module 'xcase';
@@ -2,7 +2,8 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { test, expect, describe } from 'vitest';
5
+ import { expect } from 'chai';
6
+ import { test, describe } from 'vitest';
6
7
 
7
8
  import { arrayToBuffer, arrayToString, bufferToArray, stringToArray } from './uint8array';
8
9
 
package/src/weak.test.ts CHANGED
@@ -2,14 +2,16 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { test, expect, describe } from 'vitest';
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', { timeout: 20_000 }, async () => {
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 expect.poll(() => map.size, { timeout: 20_000 }).toEqual(0);
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(): SetIterator<[K, V]> {
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(): SetIterator<K> {
25
+ keys(): IterableIterator<K> {
26
26
  return this._internal.keys();
27
27
  }
28
28
 
29
- *values(): SetIterator<V> {
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](): SetIterator<[K, V]> {
39
+ *[Symbol.iterator](): IterableIterator<[K, V]> {
40
40
  for (const [key, value] of this._internal) {
41
41
  yield [key, value.deref()!];
42
42
  }