@dxos/util 0.8.4-main.c1de068 → 0.8.4-main.fd6878d
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 +46 -17
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +46 -17
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/di-key.d.ts +3 -3
- package/dist/types/src/di-key.d.ts.map +1 -1
- package/dist/types/src/string.d.ts +1 -1
- package/dist/types/src/string.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/array.test.ts +1 -1
- package/src/circular-buffer.test.ts +1 -1
- package/src/complex.test.ts +1 -1
- package/src/human-hash.test.ts +1 -1
- package/src/position.test.ts +2 -2
- package/src/sort.test.ts +1 -1
- package/src/string.test.ts +1 -1
- package/src/string.ts +25 -6
- package/src/tree.test.ts +1 -1
- package/src/uint8array.test.ts +1 -1
- package/src/weak.test.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/util",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.fd6878d",
|
|
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",
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"types": "./dist/types/src/index.d.ts",
|
|
13
14
|
"browser": "./dist/lib/browser/index.mjs",
|
|
14
15
|
"node": {
|
|
15
16
|
"require": "./dist/lib/node/index.cjs",
|
|
16
17
|
"default": "./dist/lib/node-esm/index.mjs"
|
|
17
|
-
}
|
|
18
|
-
"types": "./dist/types/src/index.d.ts"
|
|
18
|
+
}
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"lodash.get": "^4.4.2",
|
|
31
31
|
"lodash.set": "^4.3.2",
|
|
32
|
-
"@dxos/debug": "0.8.4-main.
|
|
33
|
-
"@dxos/invariant": "0.8.4-main.
|
|
34
|
-
"@dxos/keys": "0.8.4-main.
|
|
35
|
-
"@dxos/node-std": "0.8.4-main.
|
|
32
|
+
"@dxos/debug": "0.8.4-main.fd6878d",
|
|
33
|
+
"@dxos/invariant": "0.8.4-main.fd6878d",
|
|
34
|
+
"@dxos/keys": "0.8.4-main.fd6878d",
|
|
35
|
+
"@dxos/node-std": "0.8.4-main.fd6878d"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/lodash.get": "^4.4.9",
|
|
39
39
|
"@types/lodash.set": "^4.3.9",
|
|
40
|
-
"@dxos/crypto": "0.8.4-main.
|
|
40
|
+
"@dxos/crypto": "0.8.4-main.fd6878d"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
package/src/array.test.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import { diff,
|
|
7
|
+
import { diff, distinctBy, intersection, partition } from './array';
|
|
8
8
|
|
|
9
9
|
describe('diff', () => {
|
|
10
10
|
test('returns the difference between two sets', () => {
|
package/src/complex.test.ts
CHANGED
package/src/human-hash.test.ts
CHANGED
package/src/position.test.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { describe,
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { type Position, byPosition } from './position';
|
|
8
8
|
|
|
9
9
|
type TestItem = {
|
|
10
10
|
id: number;
|
package/src/sort.test.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import { compareMulti,
|
|
7
|
+
import { compareMulti, compareObject, compareScalar, compareString } from './sort';
|
|
8
8
|
|
|
9
9
|
const data = [
|
|
10
10
|
{ i: 0, idx: 1, label: 'apple' },
|
package/src/string.test.ts
CHANGED
package/src/string.ts
CHANGED
|
@@ -16,9 +16,28 @@ export const capitalize = (str: string): string => {
|
|
|
16
16
|
/**
|
|
17
17
|
* Remove leading space from multi-line strings.
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
export function trim(strings: TemplateStringsArray, ...values: any[]) {
|
|
20
|
+
// First, build the raw result with relative indentation.
|
|
21
|
+
const raw = strings.reduce((out, str, i) => {
|
|
22
|
+
out += str;
|
|
23
|
+
if (i < values.length) {
|
|
24
|
+
const match = str.match(/(^|\n)([ \t]*)$/);
|
|
25
|
+
const baseIndent = match ? match[2] : '';
|
|
26
|
+
const val = String(values[i]).replace(/\r?\n/g, '\n' + baseIndent);
|
|
27
|
+
out += val;
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}, '');
|
|
31
|
+
|
|
32
|
+
// Split into lines and trim leading/trailing blank lines.
|
|
33
|
+
const lines = raw.split('\n');
|
|
34
|
+
|
|
35
|
+
while (lines.length && !lines[0].trim()) lines.shift();
|
|
36
|
+
while (lines.length && !lines[lines.length - 1].trim()) lines.pop();
|
|
37
|
+
|
|
38
|
+
// Find smallest indent across all non-blank lines.
|
|
39
|
+
const minIndent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.match(/^[ \t]*/)?.[0].length ?? 0));
|
|
40
|
+
|
|
41
|
+
// Remove that indent from all lines.
|
|
42
|
+
return lines.map((l) => l.slice(minIndent)).join('\n');
|
|
43
|
+
}
|
package/src/tree.test.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { describe, test } from 'vitest';
|
|
|
6
6
|
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { type TreeNode, stringifyTree } from './tree';
|
|
10
10
|
|
|
11
11
|
describe('Tree logging', () => {
|
|
12
12
|
test('simple', () => {
|
package/src/uint8array.test.ts
CHANGED