@dxos/util 0.8.3 → 0.8.4-main.84f28bd

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/util",
3
- "version": "0.8.3",
3
+ "version": "0.8.4-main.84f28bd",
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",
@@ -29,15 +29,15 @@
29
29
  "dependencies": {
30
30
  "lodash.get": "^4.4.2",
31
31
  "lodash.set": "^4.3.2",
32
- "@dxos/invariant": "0.8.3",
33
- "@dxos/node-std": "0.8.3",
34
- "@dxos/debug": "0.8.3",
35
- "@dxos/keys": "0.8.3"
32
+ "@dxos/debug": "0.8.4-main.84f28bd",
33
+ "@dxos/invariant": "0.8.4-main.84f28bd",
34
+ "@dxos/keys": "0.8.4-main.84f28bd",
35
+ "@dxos/node-std": "0.8.4-main.84f28bd"
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.3"
40
+ "@dxos/crypto": "0.8.4-main.84f28bd"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  export * from './array-to-hex';
6
6
  export * from './array';
7
+ export * from './assume';
7
8
  export * from './binder';
8
9
  export * from './bitfield';
9
10
  export * from './callback-collection';
@@ -51,5 +52,5 @@ export * from './tracer';
51
52
  export * from './tree';
52
53
  export * from './types';
53
54
  export * from './uint8array';
55
+ export * from './url';
54
56
  export * from './weak';
55
- export * from './assume';
@@ -0,0 +1,22 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { describe, it } from 'vitest';
6
+
7
+ import { createUrl } from './url';
8
+
9
+ describe('url', () => {
10
+ it('should create a url', ({ expect }) => {
11
+ const url = createUrl('https://example.com', {
12
+ i1: undefined,
13
+ i2: null,
14
+ p1: true,
15
+ p2: false,
16
+ p3: 'dxos',
17
+ p4: 100,
18
+ });
19
+
20
+ expect(url.toString()).toBe('https://example.com/?p1=true&p2=false&p3=dxos&p4=100');
21
+ });
22
+ });
package/src/url.ts ADDED
@@ -0,0 +1,15 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ /**
6
+ * Normalize construction of URLs.
7
+ */
8
+ export const createUrl = (url: URL | string, search?: Record<string, any | undefined>): URL => {
9
+ const base = typeof url === 'string' ? new URL(url) : url;
10
+ if (search) {
11
+ base.search = new URLSearchParams(Object.entries(search).filter(([_, value]) => value != null)).toString();
12
+ }
13
+
14
+ return base;
15
+ };