@dxos/util 0.6.13 → 0.6.14-main.1366248
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 +163 -150
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +156 -138
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1998 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/types/src/array-to-hex.d.ts +2 -0
- package/dist/types/src/array-to-hex.d.ts.map +1 -0
- package/dist/types/src/case.d.ts +3 -0
- package/dist/types/src/case.d.ts.map +1 -0
- package/dist/types/src/case.test.d.ts +2 -0
- package/dist/types/src/case.test.d.ts.map +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 +7 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/map-values.d.ts +2 -2
- package/dist/types/src/map-values.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/random.d.ts +1 -1
- package/dist/types/src/random.d.ts.map +1 -1
- package/dist/types/src/remove-undefined-keys.d.ts +2 -0
- package/dist/types/src/remove-undefined-keys.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 -9
- package/src/array-to-hex.ts +23 -0
- package/src/array.test.ts +1 -2
- package/src/bitfield.test.ts +1 -2
- package/src/callback.test.ts +1 -2
- package/src/case.test.ts +14 -0
- package/src/case.ts +45 -0
- 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 +7 -3
- package/src/join-tables.test.ts +1 -2
- package/src/map-values.ts +29 -10
- package/src/order.test.ts +1 -2
- package/src/platform.browser.test.ts +11 -0
- package/src/platform.node.test.ts +11 -0
- package/src/random.ts +1 -1
- package/src/reducers.test.ts +1 -2
- package/src/remove-undefined-keys.ts +13 -0
- package/src/safe-instanceof.test.ts +1 -2
- package/src/sort.test.ts +1 -2
- package/src/tracer.test.ts +3 -3
- 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/params.d.ts +0 -22
- package/dist/types/src/params.d.ts.map +0 -1
- package/dist/types/src/params.test.d.ts +0 -2
- package/dist/types/src/params.test.d.ts.map +0 -1
- package/dist/types/src/platform.test.d.ts +0 -2
- package/dist/types/src/platform.test.d.ts.map +0 -1
- package/src/params.test.ts +0 -38
- package/src/params.ts +0 -68
- package/src/platform.test.ts +0 -17
- package/src/typings.d.ts +0 -5
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/util",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14-main.1366248",
|
|
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",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "DXOS.org",
|
|
9
|
+
"sideEffects": true,
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
12
|
"browser": "./dist/lib/browser/index.mjs",
|
|
12
13
|
"node": {
|
|
13
|
-
"
|
|
14
|
+
"require": "./dist/lib/node/index.cjs",
|
|
15
|
+
"default": "./dist/lib/node-esm/index.mjs"
|
|
14
16
|
},
|
|
15
17
|
"types": "./dist/types/src/index.d.ts"
|
|
16
18
|
}
|
|
@@ -24,15 +26,13 @@
|
|
|
24
26
|
"src"
|
|
25
27
|
],
|
|
26
28
|
"dependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/node-std": "0.6.13",
|
|
32
|
-
"@dxos/keys": "0.6.13"
|
|
29
|
+
"@dxos/debug": "0.6.14-main.1366248",
|
|
30
|
+
"@dxos/invariant": "0.6.14-main.1366248",
|
|
31
|
+
"@dxos/keys": "0.6.14-main.1366248",
|
|
32
|
+
"@dxos/node-std": "0.6.14-main.1366248"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@dxos/crypto": "0.6.
|
|
35
|
+
"@dxos/crypto": "0.6.14-main.1366248"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// https://stackoverflow.com/a/59416332
|
|
6
|
+
|
|
7
|
+
// Precomputed octet list.
|
|
8
|
+
const byteToHex: string[] = [];
|
|
9
|
+
for (let n = 0; n <= 0xff; ++n) {
|
|
10
|
+
const hexOctet = n.toString(16).padStart(2, '0');
|
|
11
|
+
byteToHex.push(hexOctet);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const arrayToHex = (buf: ArrayBuffer) => {
|
|
15
|
+
const buff = new Uint8Array(buf);
|
|
16
|
+
const hexOctets = []; // new Array(buff.length) is even faster (preallocates necessary array size), then use hexOctets[i] instead of .push()
|
|
17
|
+
|
|
18
|
+
for (let i = 0; i < buff.length; ++i) {
|
|
19
|
+
hexOctets.push(byteToHex[buff[i]]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return hexOctets.join('');
|
|
23
|
+
};
|
package/src/array.test.ts
CHANGED
package/src/bitfield.test.ts
CHANGED
package/src/callback.test.ts
CHANGED
package/src/case.test.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { decamelize, hyphenize } from './case';
|
|
8
|
+
|
|
9
|
+
describe('util', () => {
|
|
10
|
+
test('decamelize', () => {
|
|
11
|
+
expect(decamelize('fooBar')).to.eq('foo_bar');
|
|
12
|
+
expect(hyphenize('fooBar')).to.eq('foo-bar');
|
|
13
|
+
});
|
|
14
|
+
});
|
package/src/case.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
const LOW_DASH = '_'.codePointAt(0)!;
|
|
6
|
+
const HI_DASH = '-'.codePointAt(0)!;
|
|
7
|
+
const SMALL_A = 'a'.codePointAt(0)!;
|
|
8
|
+
const CAPITAL_A = 'A'.codePointAt(0)!;
|
|
9
|
+
const SMALL_Z = 'z'.codePointAt(0)!;
|
|
10
|
+
const CAPITAL_Z = 'Z'.codePointAt(0)!;
|
|
11
|
+
|
|
12
|
+
const isLower = (char: number) => char >= SMALL_A && char <= SMALL_Z;
|
|
13
|
+
|
|
14
|
+
const isUpper = (char: number) => char >= CAPITAL_A && char <= CAPITAL_Z;
|
|
15
|
+
|
|
16
|
+
const toLower = (char: number) => char + 0x20;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* NOTE: Removed `xcase` due to CF dependency conflicts.
|
|
20
|
+
*/
|
|
21
|
+
const changeCase = (str: string, delim: number) => {
|
|
22
|
+
const firstChar = str.charCodeAt(0);
|
|
23
|
+
if (!isLower(firstChar)) {
|
|
24
|
+
return str;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const length = str.length;
|
|
28
|
+
let changed = false;
|
|
29
|
+
const out: number[] = [];
|
|
30
|
+
for (let i = 0; i < length; ++i) {
|
|
31
|
+
const c = str.charCodeAt(i);
|
|
32
|
+
if (isUpper(c)) {
|
|
33
|
+
out.push(delim);
|
|
34
|
+
out.push(toLower(c));
|
|
35
|
+
changed = true;
|
|
36
|
+
} else {
|
|
37
|
+
out.push(c);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return changed ? String.fromCharCode.apply(undefined, out) : str;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const decamelize = (str: string) => changeCase(str, LOW_DASH);
|
|
45
|
+
export const hyphenize = (str: string) => changeCase(str, HI_DASH);
|
package/src/complex.test.ts
CHANGED
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,9 @@ 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 './case';
|
|
12
|
+
export * from './chunk-array';
|
|
10
13
|
export * from './circular-buffer';
|
|
11
14
|
export * from './complex';
|
|
12
15
|
export * from './defer';
|
|
@@ -21,7 +24,6 @@ export * from './json';
|
|
|
21
24
|
export * from './map';
|
|
22
25
|
export * from './map-values';
|
|
23
26
|
export * from './order';
|
|
24
|
-
export * from './params';
|
|
25
27
|
export * from './pick';
|
|
26
28
|
export * from './platform';
|
|
27
29
|
export * from './random';
|
|
@@ -30,14 +32,16 @@ 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
44
|
export * from './sliding-window-summary';
|
|
42
|
-
export * from './callback-collection';
|
|
43
45
|
export * from './chunk-array';
|
|
46
|
+
export * from './array-to-hex';
|
|
47
|
+
export * from './remove-undefined-keys';
|
package/src/join-tables.test.ts
CHANGED
package/src/map-values.ts
CHANGED
|
@@ -14,21 +14,30 @@ export const mapValues = <T, U>(obj: Record<string, T>, fn: (value: T, key: stri
|
|
|
14
14
|
* Recursively maps values traversing arrays and objects.
|
|
15
15
|
* @param fn Function to apply to each value. Second argument is a function to recurse into the value.
|
|
16
16
|
*/
|
|
17
|
-
export const deepMapValues = (
|
|
17
|
+
export const deepMapValues = (
|
|
18
|
+
value: any,
|
|
19
|
+
fn: (value: any, recurse: (value: any) => any, key: string | number | undefined) => any,
|
|
20
|
+
): any => {
|
|
18
21
|
return new DeepMapper(fn).map(value);
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
class DeepMapper {
|
|
22
25
|
private readonly _cyclic = new Map<any, any>();
|
|
23
26
|
|
|
24
|
-
constructor(
|
|
27
|
+
constructor(
|
|
28
|
+
private readonly _fn: (value: any, recurse: (value: any) => any, key: string | number | undefined) => any,
|
|
29
|
+
) {}
|
|
25
30
|
|
|
26
31
|
map(value: any): any {
|
|
32
|
+
return this._map(value, undefined);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private _map(value: any, key: string | number | undefined): any {
|
|
27
36
|
if (this._cyclic.has(value)) {
|
|
28
37
|
return this._cyclic.get(value);
|
|
29
38
|
}
|
|
30
39
|
|
|
31
|
-
return this._fn(value, this._recurse);
|
|
40
|
+
return this._fn(value, this._recurse, key);
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
private _recurse = (value: any) => {
|
|
@@ -40,14 +49,14 @@ class DeepMapper {
|
|
|
40
49
|
const res = new Array(value.length);
|
|
41
50
|
this._cyclic.set(value, res);
|
|
42
51
|
for (let i = 0; i < value.length; i++) {
|
|
43
|
-
res[i] = this.
|
|
52
|
+
res[i] = this._map(value[i], i);
|
|
44
53
|
}
|
|
45
54
|
return res;
|
|
46
55
|
} else if (value !== null && typeof value === 'object') {
|
|
47
56
|
const res: any = {};
|
|
48
57
|
this._cyclic.set(value, res);
|
|
49
58
|
for (const key in value) {
|
|
50
|
-
res[key] = this.
|
|
59
|
+
res[key] = this._map(value[key], key);
|
|
51
60
|
}
|
|
52
61
|
return res;
|
|
53
62
|
} else {
|
|
@@ -63,7 +72,7 @@ class DeepMapper {
|
|
|
63
72
|
*/
|
|
64
73
|
export const deepMapValuesAsync = (
|
|
65
74
|
value: any,
|
|
66
|
-
fn: (value: any, recurse: (value: any) => Promise<any
|
|
75
|
+
fn: (value: any, recurse: (value: any) => Promise<any>, key: string | number | undefined) => Promise<any>,
|
|
67
76
|
): Promise<any> => {
|
|
68
77
|
return new DeepMapperAsync(fn).map(value);
|
|
69
78
|
};
|
|
@@ -71,14 +80,24 @@ export const deepMapValuesAsync = (
|
|
|
71
80
|
class DeepMapperAsync {
|
|
72
81
|
private readonly _cyclic = new Map<any, any>();
|
|
73
82
|
|
|
74
|
-
constructor(
|
|
83
|
+
constructor(
|
|
84
|
+
private readonly _fn: (
|
|
85
|
+
value: any,
|
|
86
|
+
recurse: (value: any) => Promise<any>,
|
|
87
|
+
key: string | number | undefined,
|
|
88
|
+
) => Promise<any>,
|
|
89
|
+
) {}
|
|
75
90
|
|
|
76
91
|
map(value: any): Promise<any> {
|
|
92
|
+
return this._map(value, undefined);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private _map(value: any, key: string | number | undefined): Promise<any> {
|
|
77
96
|
if (this._cyclic.has(value)) {
|
|
78
97
|
return this._cyclic.get(value);
|
|
79
98
|
}
|
|
80
99
|
|
|
81
|
-
return this._fn(value, this._recurse);
|
|
100
|
+
return this._fn(value, this._recurse, key);
|
|
82
101
|
}
|
|
83
102
|
|
|
84
103
|
private _recurse = async (value: any) => {
|
|
@@ -90,14 +109,14 @@ class DeepMapperAsync {
|
|
|
90
109
|
const res = new Array(value.length);
|
|
91
110
|
this._cyclic.set(value, res);
|
|
92
111
|
for (let i = 0; i < value.length; i++) {
|
|
93
|
-
res[i] = await this.
|
|
112
|
+
res[i] = await this._map(value[i], i);
|
|
94
113
|
}
|
|
95
114
|
return res;
|
|
96
115
|
} else if (value !== null && typeof value === 'object') {
|
|
97
116
|
const res: any = {};
|
|
98
117
|
this._cyclic.set(value, res);
|
|
99
118
|
for (const key in value) {
|
|
100
|
-
res[key] = await this.
|
|
119
|
+
res[key] = await this._map(value[key], key);
|
|
101
120
|
}
|
|
102
121
|
return res;
|
|
103
122
|
} else {
|
package/src/order.test.ts
CHANGED
package/src/random.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
// TODO(burdon): Random class utility.
|
|
6
6
|
// TODO(burdon): Make object { min, max }.
|
|
7
|
-
export const randomInt = (max: number, min
|
|
7
|
+
export const randomInt = (max: number, min = 0) => {
|
|
8
8
|
min = Math.ceil(min);
|
|
9
9
|
max = Math.floor(max);
|
|
10
10
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
package/src/reducers.test.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export const removeUndefinedProperties = <T extends {}>(object: T): T => {
|
|
6
|
+
for (const prop of [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)]) {
|
|
7
|
+
if ((object as any)[prop] === undefined) {
|
|
8
|
+
delete (object as any)[prop];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return object;
|
|
13
|
+
};
|
package/src/sort.test.ts
CHANGED
package/src/tracer.test.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
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
|
|
|
7
|
+
import { randomInt } from './random';
|
|
8
8
|
import { createBucketReducer, numericalValues, reduceGroupBy, reduceSeries, reduceSet } from './reducers';
|
|
9
9
|
import { Tracer } from './tracer';
|
|
10
10
|
|
|
@@ -22,7 +22,7 @@ describe('Tracer', () => {
|
|
|
22
22
|
const n = 20;
|
|
23
23
|
for (let i = 0; i < n; i++) {
|
|
24
24
|
tracer.emit(key);
|
|
25
|
-
await sleep(
|
|
25
|
+
await sleep(randomInt(10));
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const events = tracer.get('test')!;
|
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,22 +0,0 @@
|
|
|
1
|
-
import type * as S from '@effect/schema/Schema';
|
|
2
|
-
import { type Annotable } from '@effect/schema/Schema';
|
|
3
|
-
type ParamKeyAnnotationType = string;
|
|
4
|
-
export declare const ParamKeyAnnotation: (value: ParamKeyAnnotationType) => <S extends Annotable.All>(self: S) => Annotable.Self<S>;
|
|
5
|
-
/**
|
|
6
|
-
* HTTP params parser.
|
|
7
|
-
*/
|
|
8
|
-
export declare class Params<T extends Record<string, any>> {
|
|
9
|
-
private readonly _schema;
|
|
10
|
-
constructor(_schema: S.Struct<T>);
|
|
11
|
-
/**
|
|
12
|
-
* Parse URL params.
|
|
13
|
-
* @param url
|
|
14
|
-
*/
|
|
15
|
-
parse(url: URL): T;
|
|
16
|
-
/**
|
|
17
|
-
* Update URL with params.
|
|
18
|
-
*/
|
|
19
|
-
params(url: URL, values: T): URL;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=params.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../src/params.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,CAAC,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAMvD,KAAK,sBAAsB,GAAG,MAAM,CAAC;AAErC,eAAO,MAAM,kBAAkB,UACrB,sBAAsB,MAC7B,CAAC,SAAS,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CACC,CAAC;AAExD;;GAEG;AACH,qBAAa,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjD;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC;IAqBlB;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,GAAG,GAAG;CAYjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"params.test.d.ts","sourceRoot":"","sources":["../../../src/params.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platform.test.d.ts","sourceRoot":"","sources":["../../../src/platform.test.ts"],"names":[],"mappings":""}
|