@dxos/util 0.4.4 → 0.4.5-main.b5b1909
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/package.json +6 -6
- package/src/bitfield.test.ts +1 -2
- package/src/callback.test.ts +1 -2
- package/src/complex.test.ts +1 -1
- package/src/defer.test.ts +1 -2
- package/src/human-hash.test.ts +1 -1
- package/src/order.test.ts +1 -2
- package/src/platform.test.ts +3 -3
- 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 +28 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/util",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5-main.b5b1909",
|
|
4
4
|
"description": "Temporary bucket for misc functions, which should graduate into separate packages.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@dxos/debug": "0.4.
|
|
20
|
-
"@dxos/invariant": "0.4.
|
|
21
|
-
"@dxos/
|
|
22
|
-
"@dxos/
|
|
19
|
+
"@dxos/debug": "0.4.5-main.b5b1909",
|
|
20
|
+
"@dxos/invariant": "0.4.5-main.b5b1909",
|
|
21
|
+
"@dxos/keys": "0.4.5-main.b5b1909",
|
|
22
|
+
"@dxos/node-std": "0.4.5-main.b5b1909"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@dxos/crypto": "0.4.
|
|
25
|
+
"@dxos/crypto": "0.4.5-main.b5b1909"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
package/src/bitfield.test.ts
CHANGED
package/src/callback.test.ts
CHANGED
package/src/complex.test.ts
CHANGED
package/src/defer.test.ts
CHANGED
package/src/human-hash.test.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { expect } from 'chai';
|
|
6
|
+
import { test } from 'vitest';
|
|
6
7
|
|
|
7
8
|
import { createKeyPair, createId } from '@dxos/crypto';
|
|
8
9
|
import { PublicKey } from '@dxos/keys';
|
|
9
|
-
import { test } from '@dxos/test';
|
|
10
10
|
|
|
11
11
|
import { humanize } from './human-hash';
|
|
12
12
|
|
package/src/order.test.ts
CHANGED
package/src/platform.test.ts
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { expect } from 'chai';
|
|
6
|
-
|
|
7
|
-
import { test } from '@dxos/test';
|
|
6
|
+
import { test } from 'vitest';
|
|
8
7
|
|
|
9
8
|
import { isNode } from './platform';
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
// TODO(dmaretskyi): Broken with vitest conversion.
|
|
11
|
+
test.skip('knows when running in node', () => {
|
|
12
12
|
if (mochaExecutor.environment === 'nodejs') {
|
|
13
13
|
expect(isNode()).to.be.true;
|
|
14
14
|
} else {
|
package/src/reducers.test.ts
CHANGED
package/src/sort.test.ts
CHANGED
package/src/tracer.test.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { expect } from 'chai';
|
|
6
|
-
|
|
7
|
-
import { describe, test } from '@dxos/test';
|
|
6
|
+
import { describe, test } from 'vitest';
|
|
8
7
|
|
|
9
8
|
import { createBucketReducer, numericalValues, reduceGroupBy, reduceSeries, reduceSet } from './reducers';
|
|
10
9
|
import { Tracer } from './tracer';
|
package/src/types.test.ts
CHANGED
package/src/uint8array.test.ts
CHANGED
package/src/weak.test.ts
CHANGED
|
@@ -3,42 +3,39 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { expect } from 'chai';
|
|
6
|
+
import { test, describe } from 'vitest';
|
|
6
7
|
import waitForExpect from 'wait-for-expect';
|
|
7
8
|
|
|
8
|
-
import { test, describe } from '@dxos/test';
|
|
9
|
-
|
|
10
9
|
import { WeakDictionary } from './weak';
|
|
11
10
|
|
|
12
11
|
describe('WeakDictionary', () => {
|
|
13
12
|
// Skipped because it takes a long time for garbage collection to kick in (~8 sec)
|
|
14
13
|
// but it works otherwise.
|
|
15
|
-
test
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
})
|
|
43
|
-
.timeout(20000);
|
|
14
|
+
test.skip('unref item gets garbage collected', async () => {
|
|
15
|
+
const map = new WeakDictionary<string, any>();
|
|
16
|
+
const key = 'key';
|
|
17
|
+
|
|
18
|
+
const setValue = () => {
|
|
19
|
+
const value = { test: 'test' };
|
|
20
|
+
map.set(key, value);
|
|
21
|
+
expect(map.get(key)).to.equal(value);
|
|
22
|
+
expect(map.size).to.equal(1);
|
|
23
|
+
expect(map.has(key)).to.equal(true);
|
|
24
|
+
expect([...map.keys()]).to.deep.equal([key]);
|
|
25
|
+
expect([...map.values()]).to.deep.equal([value]);
|
|
26
|
+
|
|
27
|
+
for (const [k, v] of map) {
|
|
28
|
+
expect(k).to.equal(key);
|
|
29
|
+
expect(v).to.equal(value);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
setValue();
|
|
34
|
+
// Garbage collection should remove the item because no references exist.
|
|
35
|
+
await waitForExpect(() => {
|
|
36
|
+
expect(map.size).to.equal(0);
|
|
37
|
+
}, 20000);
|
|
38
|
+
|
|
39
|
+
expect(map.has(key)).to.equal(false);
|
|
40
|
+
}, 20_000);
|
|
44
41
|
});
|