@dxos/util 0.6.11 → 0.6.12-main.5cc132e

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 (39) hide show
  1. package/dist/lib/browser/index.mjs.map +2 -2
  2. package/dist/lib/browser/meta.json +1 -1
  3. package/dist/lib/node/index.cjs.map +2 -2
  4. package/dist/lib/node/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +1976 -0
  6. package/dist/lib/node-esm/index.mjs.map +7 -0
  7. package/dist/lib/node-esm/meta.json +1 -0
  8. package/dist/types/src/complex.d.ts +8 -8
  9. package/dist/types/src/complex.d.ts.map +1 -1
  10. package/dist/types/src/platform.browser.test.d.ts +2 -0
  11. package/dist/types/src/platform.browser.test.d.ts.map +1 -0
  12. package/dist/types/src/platform.node.test.d.ts +2 -0
  13. package/dist/types/src/platform.node.test.d.ts.map +1 -0
  14. package/dist/types/src/weak.d.ts +4 -4
  15. package/dist/types/src/weak.d.ts.map +1 -1
  16. package/package.json +8 -7
  17. package/src/array.test.ts +1 -2
  18. package/src/bitfield.test.ts +1 -2
  19. package/src/callback.test.ts +1 -2
  20. package/src/complex.test.ts +1 -2
  21. package/src/complex.ts +8 -8
  22. package/src/defer.test.ts +1 -2
  23. package/src/human-hash.test.ts +1 -2
  24. package/src/join-tables.test.ts +1 -2
  25. package/src/order.test.ts +1 -2
  26. package/src/params.test.ts +1 -2
  27. package/src/platform.browser.test.ts +11 -0
  28. package/src/platform.node.test.ts +11 -0
  29. package/src/reducers.test.ts +1 -2
  30. package/src/safe-instanceof.test.ts +1 -2
  31. package/src/sort.test.ts +1 -2
  32. package/src/tracer.test.ts +1 -2
  33. package/src/types.test.ts +1 -2
  34. package/src/uint8array.test.ts +1 -2
  35. package/src/weak.test.ts +4 -8
  36. package/src/weak.ts +4 -4
  37. package/dist/types/src/platform.test.d.ts +0 -2
  38. package/dist/types/src/platform.test.d.ts.map +0 -1
  39. package/src/platform.test.ts +0 -17
@@ -2,8 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
6
- import { test } from 'vitest';
5
+ import { expect, test } from 'vitest';
7
6
 
8
7
  import { createKeyPair, createId } from '@dxos/crypto';
9
8
  import { PublicKey } from '@dxos/keys';
@@ -2,8 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
6
- import { describe, test } from 'vitest';
5
+ import { describe, expect, test } from 'vitest';
7
6
 
8
7
  import { joinTables } from './join-tables';
9
8
 
package/src/order.test.ts CHANGED
@@ -2,8 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
6
- import { describe, test } from 'vitest';
5
+ import { describe, expect, test } from 'vitest';
7
6
 
8
7
  import { inferObjectOrder, inferRecordOrder } from './order';
9
8
 
@@ -3,8 +3,7 @@
3
3
  //
4
4
 
5
5
  import { Schema as S } from '@effect/schema';
6
- import { expect } from 'chai';
7
- import { describe, test } from 'vitest';
6
+ import { describe, expect, test } from 'vitest';
8
7
 
9
8
  import { ParamKeyAnnotation, Params } from './params';
10
9
 
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright 2020 DXOS.org
3
+ //
4
+
5
+ import { expect, test } from 'vitest';
6
+
7
+ import { isNode } from './platform';
8
+
9
+ test('knows when running in node', () => {
10
+ expect(isNode()).to.be.false;
11
+ });
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright 2020 DXOS.org
3
+ //
4
+
5
+ import { expect, test } from 'vitest';
6
+
7
+ import { isNode } from './platform';
8
+
9
+ test('knows when running in node', () => {
10
+ expect(isNode()).to.be.true;
11
+ });
@@ -2,8 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
6
- import { describe, test } from 'vitest';
5
+ import { describe, expect, test } from 'vitest';
7
6
 
8
7
  import { median, numericalValues } from './reducers';
9
8
 
@@ -2,8 +2,7 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
6
- import { describe, test } from 'vitest';
5
+ import { describe, expect, test } from 'vitest';
7
6
 
8
7
  import { safeInstanceof } from './safe-instanceof';
9
8
 
package/src/sort.test.ts CHANGED
@@ -2,8 +2,7 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
6
- import { describe, test } from 'vitest';
5
+ import { describe, expect, test } from 'vitest';
7
6
 
8
7
  import { compareMulti, compareScalar, compareObject, compareString } from './sort';
9
8
 
@@ -2,8 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
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
@@ -2,8 +2,7 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
6
- import { describe, test } from 'vitest';
5
+ import { describe, expect, test } from 'vitest';
7
6
 
8
7
  import { nonNullable } from './types';
9
8
 
@@ -2,8 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
6
- import { test, describe } from 'vitest';
5
+ import { test, expect, describe } from 'vitest';
7
6
 
8
7
  import { arrayToBuffer, arrayToString, bufferToArray, stringToArray } from './uint8array';
9
8
 
package/src/weak.test.ts CHANGED
@@ -2,16 +2,14 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
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 waitForExpect(() => {
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
- }, 20_000);
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(): IterableIterator<[K, V]> {
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(): IterableIterator<K> {
25
+ keys(): SetIterator<K> {
26
26
  return this._internal.keys();
27
27
  }
28
28
 
29
- *values(): IterableIterator<V> {
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](): IterableIterator<[K, V]> {
39
+ *[Symbol.iterator](): SetIterator<[K, V]> {
40
40
  for (const [key, value] of this._internal) {
41
41
  yield [key, value.deref()!];
42
42
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=platform.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"platform.test.d.ts","sourceRoot":"","sources":["../../../src/platform.test.ts"],"names":[],"mappings":""}
@@ -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
- });