@moq/net 0.1.6 → 0.1.8
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/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +4 -1
- package/connection/accept.js.map +1 -1
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +25 -11
- package/connection/connect.js.map +1 -1
- package/ietf/connection.js +1 -1
- package/ietf/connection.js.map +1 -1
- package/ietf/control.d.ts.map +1 -1
- package/ietf/control.js +6 -2
- package/ietf/control.js.map +1 -1
- package/ietf/ietf.test.js +7 -0
- package/ietf/ietf.test.js.map +1 -1
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +10 -5
- package/ietf/namespace.js.map +1 -1
- package/ietf/subscriber.d.ts +1 -1
- package/ietf/subscriber.d.ts.map +1 -1
- package/ietf/subscriber.js +3 -4
- package/ietf/subscriber.js.map +1 -1
- package/ietf/version.d.ts +7 -1
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +7 -0
- package/ietf/version.js.map +1 -1
- package/integration.test.js +3 -0
- package/integration.test.js.map +1 -1
- package/lite/announce.js +6 -6
- package/lite/announce.js.map +1 -1
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +32 -4
- package/lite/connection.js.map +1 -1
- package/lite/fetch.js +2 -2
- package/lite/fetch.js.map +1 -1
- package/lite/publisher.d.ts +7 -0
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +50 -6
- package/lite/publisher.js.map +1 -1
- package/lite/setup.d.ts +18 -0
- package/lite/setup.d.ts.map +1 -0
- package/lite/setup.js +55 -0
- package/lite/setup.js.map +1 -0
- package/lite/stream.d.ts +5 -0
- package/lite/stream.d.ts.map +1 -1
- package/lite/stream.js +8 -0
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +24 -4
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +78 -5
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +24 -3
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +38 -0
- package/lite/track.d.ts.map +1 -0
- package/lite/track.js +81 -0
- package/lite/track.js.map +1 -0
- package/lite/track.test.d.ts +2 -0
- package/lite/track.test.d.ts.map +1 -0
- package/lite/track.test.js +53 -0
- package/lite/track.test.js.map +1 -0
- package/lite/version.d.ts +2 -0
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +10 -0
- package/lite/version.js.map +1 -1
- package/package.json +2 -2
- package/path.d.ts +22 -0
- package/path.d.ts.map +1 -1
- package/path.js +32 -0
- package/path.js.map +1 -1
- package/path.test.js +15 -0
- package/path.test.js.map +1 -1
- package/time.d.ts +28 -4
- package/time.d.ts.map +1 -1
- package/time.js +28 -4
- package/time.js.map +1 -1
package/path.js
CHANGED
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
/* @ts-self-types="./path.d.ts" */
|
|
2
|
+
/**
|
|
3
|
+
* Maximum number of slash-separated parts in a path.
|
|
4
|
+
*
|
|
5
|
+
* Matches the IETF moq-transport limit of 32 fields in a namespace tuple.
|
|
6
|
+
* moq-lite enforces the same bound when decoding paths off the wire.
|
|
7
|
+
*/
|
|
8
|
+
export const MAX_PARTS = 32;
|
|
2
9
|
/** Build a path from one or more components, joining with "/" and trimming redundant slashes. */
|
|
3
10
|
export function from(...paths) {
|
|
4
11
|
// Join paths with "/" and then remove leading and trailing slashes, and collapse multiple slashes into one.
|
|
5
12
|
const joined = paths.join("/");
|
|
6
13
|
return joined.replace(/\/+/g, "/").replace(/^\/+/, "").replace(/\/+$/, "");
|
|
7
14
|
}
|
|
15
|
+
/** Split a path into its slash-separated parts. The empty path has no parts. */
|
|
16
|
+
export function parts(path) {
|
|
17
|
+
return path === "" ? [] : path.split("/");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validate an untrusted wire string as a path, enforcing {@link MAX_PARTS}.
|
|
21
|
+
*
|
|
22
|
+
* Throws when the path has too many parts; use at wire decode sites.
|
|
23
|
+
*/
|
|
24
|
+
export function decode(raw) {
|
|
25
|
+
const path = from(raw);
|
|
26
|
+
return encode(path);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validate a path before writing it to the wire, enforcing {@link MAX_PARTS}.
|
|
30
|
+
*
|
|
31
|
+
* Throws when the path has too many parts; use at wire encode sites so we never
|
|
32
|
+
* emit a path the remote side is required to reject.
|
|
33
|
+
*/
|
|
34
|
+
export function encode(path) {
|
|
35
|
+
if (parts(path).length > MAX_PARTS) {
|
|
36
|
+
throw new Error(`path exceeds ${MAX_PARTS} parts`);
|
|
37
|
+
}
|
|
38
|
+
return path;
|
|
39
|
+
}
|
|
8
40
|
/**
|
|
9
41
|
* Check if a path has the given prefix, respecting path boundaries.
|
|
10
42
|
*
|
package/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAgCA,iGAAiG;AACjG,MAAM,UAAU,IAAI,CAAC,GAAG,KAAe;IACtC,4GAA4G;IAC5G,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAU,CAAC;AACrF,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,SAAS,CAAC,MAAa,EAAE,IAAW;IACnD,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,yCAAyC;IACzC,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,kEAAkE;IAClE,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,WAAW,CAAC,MAAa,EAAE,IAAW;IACrD,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,2BAA2B;IAC3B,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,0CAA0C;IAC1C,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,EAAW,CAAC;IACpB,CAAC;IAED,+EAA+E;IAC/E,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAU,CAAC;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,IAAI,CAAC,IAAW,EAAE,KAAY;IAC7C,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACd,CAAC;SAAM,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;SAAM,CAAC;QACP,yDAAyD;QACzD,OAAO,GAAG,IAAI,IAAI,KAAK,EAAW,CAAC;IACpC,CAAC;AACF,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,KAAK;IACpB,OAAO,EAAW,CAAC;AACpB,CAAC","sourcesContent":["/**\n * A broadcast path that provides safe prefix matching operations.\n *\n * This module provides path-aware operations that respect delimiter boundaries,\n * preventing issues like \"foo\" matching \"foobar\".\n *\n * Paths are automatically trimmed of leading and trailing slashes on creation,\n * making all slashes implicit at boundaries.\n * All paths are RELATIVE; you cannot join with a leading slash to make an absolute path.\n *\n * @example\n * ```typescript\n * // Creation automatically trims slashes\n * const path1 = Path.from(\"/foo/bar/\");\n * const path2 = Path.from(\"foo/bar\");\n * console.log(path1 === path2); // true\n *\n * // Multiple arguments are joined with \"/\"\n * const path3 = Path.from(\"api\", \"v1\", \"users\");\n * console.log(path3); // \"api/v1/users\"\n *\n * // Safe prefix matching\n * const base = Path.from(\"api/v1\");\n * console.log(Path.hasPrefix(Path.from(\"api\"), base)); // true\n * console.log(Path.hasPrefix(Path.from(\"api/v1\"), base)); // true\n *\n * const joined = Path.join(base, Path.from(\"users\"));\n * console.log(joined); // \"api/v1/users\"\n * ```\n */\nexport type Valid = string & { __brand: \"Name\" };\n\n/** Build a path from one or more components, joining with \"/\" and trimming redundant slashes. */\nexport function from(...paths: string[]): Valid {\n\t// Join paths with \"/\" and then remove leading and trailing slashes, and collapse multiple slashes into one.\n\tconst joined = paths.join(\"/\");\n\treturn joined.replace(/\\/+/g, \"/\").replace(/^\\/+/, \"\").replace(/\\/+$/, \"\") as Valid;\n}\n\n/**\n * Check if a path has the given prefix, respecting path boundaries.\n *\n * Unlike String.startsWith, this ensures that \"foo\" does not match \"foobar\".\n * The prefix must either:\n * - Be exactly equal to the path\n * - Be followed by a '/' delimiter in the original path\n * - Be empty (matches everything)\n *\n * @example\n * ```typescript\n * const path = Path.from(\"foo/bar\");\n * console.log(Path.hasPrefix(Path.from(\"foo\"), path)); // true\n * console.log(Path.hasPrefix(Path.from(\"foo/\"), path)); // true (trailing slash ignored)\n * console.log(Path.hasPrefix(Path.from(\"fo\"), path)); // false\n *\n * const path2 = Path.from(\"foobar\");\n * console.log(Path.hasPrefix(Path.from(\"foo\"), path2)); // false\n * ```\n */\nexport function hasPrefix(prefix: Valid, path: Valid): boolean {\n\tif (prefix === \"\") {\n\t\treturn true;\n\t}\n\n\tif (!path.startsWith(prefix)) {\n\t\treturn false;\n\t}\n\n\t// Check if the prefix is the exact match\n\tif (path.length === prefix.length) {\n\t\treturn true;\n\t}\n\n\t// Otherwise, ensure the character after the prefix is a delimiter\n\treturn path[prefix.length] === \"/\";\n}\n\n/**\n * Strip the given prefix from a path, returning the suffix.\n *\n * Returns null if the prefix doesn't match according to hasPrefix rules.\n *\n * @example\n * ```typescript\n * const path = Path.from(\"foo/bar/baz\");\n * const suffix = Path.stripPrefix(Path.from(\"foo\"), path);\n * console.log(suffix); // \"bar/baz\"\n *\n * const suffix2 = Path.stripPrefix(Path.from(\"foo/\"), path);\n * console.log(suffix2); // \"bar/baz\"\n *\n * const noMatch = Path.stripPrefix(Path.from(\"notfound\"), path);\n * console.log(noMatch); // null\n * ```\n */\nexport function stripPrefix(prefix: Valid, path: Valid): Valid | null {\n\tif (!hasPrefix(prefix, path)) {\n\t\treturn null;\n\t}\n\n\t// Handle empty prefix case\n\tif (prefix === \"\") {\n\t\treturn path;\n\t}\n\n\t// If prefix matches exactly, return empty\n\tif (path.length === prefix.length) {\n\t\treturn \"\" as Valid;\n\t}\n\n\t// For non-empty prefix that's shorter, skip the prefix and the following slash\n\treturn path.slice(prefix.length + 1) as Valid;\n}\n\n/**\n * Join two path components together.\n *\n * @example\n * ```typescript\n * const base = Path.from(\"foo\");\n * const joined = Path.join(base, Path.from(\"bar\"));\n * console.log(joined); // \"foo/bar\"\n * ```\n */\nexport function join(path: Valid, other: Valid): Valid {\n\tif (path === \"\") {\n\t\treturn other;\n\t} else if (other === \"\") {\n\t\treturn path;\n\t} else {\n\t\t// Since paths are trimmed, we always need to add a slash\n\t\treturn `${path}/${other}` as Valid;\n\t}\n}\n\n/** The empty path, which is a prefix of every path. */\nexport function empty(): Valid {\n\treturn \"\" as Valid;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAgCA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAE5B,iGAAiG;AACjG,MAAM,UAAU,IAAI,CAAC,GAAG,KAAe;IACtC,4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,CAAC,KAAK,GAAG,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,WAAW,CAAC,MAAa,EAAE,IAAW;IACrD,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,2BAA2B;IAC3B,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,0CAA0C;IAC1C,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,EAAW,CAAC;IACpB,CAAC;IAED,+EAA+E;IAC/E,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAU,CAAC;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,IAAI,CAAC,IAAW,EAAE,KAAY;IAC7C,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACd,CAAC;SAAM,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;SAAM,CAAC;QACP,yDAAyD;QACzD,OAAO,GAAG,IAAI,IAAI,KAAK,EAAW,CAAC;IACpC,CAAC;AACF,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,KAAK;IACpB,OAAO,EAAW,CAAC;AACpB,CAAC","sourcesContent":["/**\n * A broadcast path that provides safe prefix matching operations.\n *\n * This module provides path-aware operations that respect delimiter boundaries,\n * preventing issues like \"foo\" matching \"foobar\".\n *\n * Paths are automatically trimmed of leading and trailing slashes on creation,\n * making all slashes implicit at boundaries.\n * All paths are RELATIVE; you cannot join with a leading slash to make an absolute path.\n *\n * @example\n * ```typescript\n * // Creation automatically trims slashes\n * const path1 = Path.from(\"/foo/bar/\");\n * const path2 = Path.from(\"foo/bar\");\n * console.log(path1 === path2); // true\n *\n * // Multiple arguments are joined with \"/\"\n * const path3 = Path.from(\"api\", \"v1\", \"users\");\n * console.log(path3); // \"api/v1/users\"\n *\n * // Safe prefix matching\n * const base = Path.from(\"api/v1\");\n * console.log(Path.hasPrefix(Path.from(\"api\"), base)); // true\n * console.log(Path.hasPrefix(Path.from(\"api/v1\"), base)); // true\n *\n * const joined = Path.join(base, Path.from(\"users\"));\n * console.log(joined); // \"api/v1/users\"\n * ```\n */\nexport type Valid = string & { __brand: \"Name\" };\n\n/**\n * Maximum number of slash-separated parts in a path.\n *\n * Matches the IETF moq-transport limit of 32 fields in a namespace tuple.\n * moq-lite enforces the same bound when decoding paths off the wire.\n */\nexport const MAX_PARTS = 32;\n\n/** Build a path from one or more components, joining with \"/\" and trimming redundant slashes. */\nexport function from(...paths: string[]): Valid {\n\t// Join paths with \"/\" and then remove leading and trailing slashes, and collapse multiple slashes into one.\n\tconst joined = paths.join(\"/\");\n\treturn joined.replace(/\\/+/g, \"/\").replace(/^\\/+/, \"\").replace(/\\/+$/, \"\") as Valid;\n}\n\n/** Split a path into its slash-separated parts. The empty path has no parts. */\nexport function parts(path: Valid): string[] {\n\treturn path === \"\" ? [] : path.split(\"/\");\n}\n\n/**\n * Validate an untrusted wire string as a path, enforcing {@link MAX_PARTS}.\n *\n * Throws when the path has too many parts; use at wire decode sites.\n */\nexport function decode(raw: string): Valid {\n\tconst path = from(raw);\n\treturn encode(path);\n}\n\n/**\n * Validate a path before writing it to the wire, enforcing {@link MAX_PARTS}.\n *\n * Throws when the path has too many parts; use at wire encode sites so we never\n * emit a path the remote side is required to reject.\n */\nexport function encode(path: Valid): Valid {\n\tif (parts(path).length > MAX_PARTS) {\n\t\tthrow new Error(`path exceeds ${MAX_PARTS} parts`);\n\t}\n\treturn path;\n}\n\n/**\n * Check if a path has the given prefix, respecting path boundaries.\n *\n * Unlike String.startsWith, this ensures that \"foo\" does not match \"foobar\".\n * The prefix must either:\n * - Be exactly equal to the path\n * - Be followed by a '/' delimiter in the original path\n * - Be empty (matches everything)\n *\n * @example\n * ```typescript\n * const path = Path.from(\"foo/bar\");\n * console.log(Path.hasPrefix(Path.from(\"foo\"), path)); // true\n * console.log(Path.hasPrefix(Path.from(\"foo/\"), path)); // true (trailing slash ignored)\n * console.log(Path.hasPrefix(Path.from(\"fo\"), path)); // false\n *\n * const path2 = Path.from(\"foobar\");\n * console.log(Path.hasPrefix(Path.from(\"foo\"), path2)); // false\n * ```\n */\nexport function hasPrefix(prefix: Valid, path: Valid): boolean {\n\tif (prefix === \"\") {\n\t\treturn true;\n\t}\n\n\tif (!path.startsWith(prefix)) {\n\t\treturn false;\n\t}\n\n\t// Check if the prefix is the exact match\n\tif (path.length === prefix.length) {\n\t\treturn true;\n\t}\n\n\t// Otherwise, ensure the character after the prefix is a delimiter\n\treturn path[prefix.length] === \"/\";\n}\n\n/**\n * Strip the given prefix from a path, returning the suffix.\n *\n * Returns null if the prefix doesn't match according to hasPrefix rules.\n *\n * @example\n * ```typescript\n * const path = Path.from(\"foo/bar/baz\");\n * const suffix = Path.stripPrefix(Path.from(\"foo\"), path);\n * console.log(suffix); // \"bar/baz\"\n *\n * const suffix2 = Path.stripPrefix(Path.from(\"foo/\"), path);\n * console.log(suffix2); // \"bar/baz\"\n *\n * const noMatch = Path.stripPrefix(Path.from(\"notfound\"), path);\n * console.log(noMatch); // null\n * ```\n */\nexport function stripPrefix(prefix: Valid, path: Valid): Valid | null {\n\tif (!hasPrefix(prefix, path)) {\n\t\treturn null;\n\t}\n\n\t// Handle empty prefix case\n\tif (prefix === \"\") {\n\t\treturn path;\n\t}\n\n\t// If prefix matches exactly, return empty\n\tif (path.length === prefix.length) {\n\t\treturn \"\" as Valid;\n\t}\n\n\t// For non-empty prefix that's shorter, skip the prefix and the following slash\n\treturn path.slice(prefix.length + 1) as Valid;\n}\n\n/**\n * Join two path components together.\n *\n * @example\n * ```typescript\n * const base = Path.from(\"foo\");\n * const joined = Path.join(base, Path.from(\"bar\"));\n * console.log(joined); // \"foo/bar\"\n * ```\n */\nexport function join(path: Valid, other: Valid): Valid {\n\tif (path === \"\") {\n\t\treturn other;\n\t} else if (other === \"\") {\n\t\treturn path;\n\t} else {\n\t\t// Since paths are trimmed, we always need to add a slash\n\t\treturn `${path}/${other}` as Valid;\n\t}\n}\n\n/** The empty path, which is a prefix of every path. */\nexport function empty(): Valid {\n\treturn \"\" as Valid;\n}\n"]}
|
package/path.test.js
CHANGED
|
@@ -151,4 +151,19 @@ test("from sanitizes multiple arguments with slashes", () => {
|
|
|
151
151
|
expect(Path.from("/foo/", "/bar/", "/baz/")).toBe("foo/bar/baz");
|
|
152
152
|
expect(Path.from("foo//", "//bar", "baz")).toBe("foo/bar/baz");
|
|
153
153
|
});
|
|
154
|
+
test("parts splits a path into its components", () => {
|
|
155
|
+
expect(Path.parts(Path.from(""))).toEqual([]);
|
|
156
|
+
expect(Path.parts(Path.from("foo"))).toEqual(["foo"]);
|
|
157
|
+
expect(Path.parts(Path.from("/foo//bar/"))).toEqual(["foo", "bar"]);
|
|
158
|
+
});
|
|
159
|
+
test("decode enforces the max part count", () => {
|
|
160
|
+
const atLimit = Array.from({ length: Path.MAX_PARTS }, (_, i) => `${i}`).join("/");
|
|
161
|
+
expect(Path.decode(atLimit)).toBe(atLimit);
|
|
162
|
+
expect(() => Path.decode(`${atLimit}/extra`)).toThrow();
|
|
163
|
+
});
|
|
164
|
+
test("encode enforces the max part count", () => {
|
|
165
|
+
const atLimit = Array.from({ length: Path.MAX_PARTS }, (_, i) => `${i}`).join("/");
|
|
166
|
+
expect(Path.encode(atLimit)).toBe(atLimit);
|
|
167
|
+
expect(() => Path.encode(`${atLimit}/extra`)).toThrow();
|
|
168
|
+
});
|
|
154
169
|
//# sourceMappingURL=path.test.js.map
|
package/path.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.test.js","sourceRoot":"","sources":["../src/path.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IA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EAAE,GAAG,EAAE;IAC5C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,aAA2B,CAAC,CAAC;IACzE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,cAA4B,CAAC,CAAC;AAC5E,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACpD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAuB,CAAC,CAAC;IAClE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAuB,CAAC,CAAC;AACvE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAC3D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,aAA2B,CAAC,CAAC;IAC/E,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,aAA2B,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"bun:test\";\nimport * as Path from \"./path.ts\";\n\ntest(\"Path constructor trims leading and trailing slashes\", () => {\n\texpect(Path.from(\"/foo/bar/\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"///foo/bar///\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"foo/bar\")).toBe(\"foo/bar\" as Path.Valid);\n});\n\ntest(\"Path constructor handles empty paths\", () => {\n\texpect(Path.from(\"\")).toBe(\"\" as Path.Valid);\n\texpect(Path.from(\"/\")).toBe(\"\" as Path.Valid);\n\texpect(Path.from(\"///\")).toBe(\"\" as Path.Valid);\n});\n\ntest(\"hasPrefix matches exact paths\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\texpect(Path.hasPrefix(Path.from(\"foo/bar\"), path)).toBe(true);\n});\n\ntest(\"hasPrefix matches proper prefixes\", () => {\n\tconst path = Path.from(\"foo/bar/baz\");\n\texpect(Path.hasPrefix(Path.from(\"foo\"), path)).toBe(true);\n\texpect(Path.hasPrefix(Path.from(\"foo/bar\"), path)).toBe(true);\n});\n\ntest(\"hasPrefix does not match partial segment prefixes\", () => {\n\tconst path = Path.from(\"foobar\");\n\texpect(Path.hasPrefix(Path.from(\"foo\"), path)).toBe(false);\n\n\tconst path2 = Path.from(\"foo/bar\");\n\texpect(Path.hasPrefix(Path.from(\"fo\"), path2)).toBe(false);\n});\n\ntest(\"hasPrefix handles empty prefix\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\texpect(Path.hasPrefix(Path.empty(), path)).toBe(true);\n});\n\ntest(\"hasPrefix ignores trailing slashes in prefix\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\texpect(Path.hasPrefix(Path.from(\"foo/\"), path)).toBe(true);\n\texpect(Path.hasPrefix(Path.from(\"foo/bar/\"), path)).toBe(true);\n});\n\ntest(\"stripPrefix strips valid prefixes\", () => {\n\tconst path = Path.from(\"foo/bar/baz\");\n\n\tconst suffix1 = Path.stripPrefix(Path.from(\"foo\"), path);\n\texpect(suffix1).toBe(\"bar/baz\" as Path.Valid);\n\n\tconst suffix2 = Path.stripPrefix(Path.from(\"foo/bar\"), path);\n\texpect(suffix2).toBe(\"baz\" as Path.Valid);\n\n\tconst suffix3 = Path.stripPrefix(Path.from(\"foo/bar/baz\"), path);\n\texpect(suffix3).toBe(\"\" as Path.Valid);\n});\n\ntest(\"stripPrefix returns null for invalid prefixes\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\texpect(Path.stripPrefix(Path.from(\"notfound\"), path)).toBe(null);\n\texpect(Path.stripPrefix(Path.from(\"fo\"), path)).toBe(null);\n});\n\ntest(\"stripPrefix handles empty prefix\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\tconst result = Path.stripPrefix(Path.empty(), path);\n\texpect(result).toBe(\"foo/bar\" as Path.Valid);\n});\n\ntest(\"stripPrefix accepts Path instances\", () => {\n\tconst path = Path.from(\"foo/bar/baz\");\n\tconst prefix = Path.from(\"foo/bar\");\n\tconst result = Path.stripPrefix(prefix, path);\n\texpect(result).toBe(\"baz\" as Path.Valid);\n});\n\ntest(\"join paths with slashes\", () => {\n\tconst base = Path.from(\"foo\");\n\tconst joined = Path.join(base, Path.from(\"bar\"));\n\texpect(joined).toBe(\"foo/bar\" as Path.Valid);\n});\n\ntest(\"join handles empty base\", () => {\n\tconst base = Path.empty();\n\tconst joined = Path.join(base, Path.from(\"bar\"));\n\texpect(joined).toBe(\"bar\" as Path.Valid);\n});\n\ntest(\"join handles empty suffix\", () => {\n\tconst base = Path.from(\"foo\");\n\tconst joined = Path.join(base, Path.empty());\n\texpect(joined).toBe(\"foo\" as Path.Valid);\n});\n\ntest(\"join accepts Path instances\", () => {\n\tconst base = Path.from(\"foo\");\n\tconst suffix = Path.from(\"bar\");\n\tconst joined = Path.join(base, suffix);\n\texpect(joined).toBe(\"foo/bar\" as Path.Valid);\n});\n\ntest(\"join handles multiple joins\", () => {\n\tconst path = Path.join(\n\t\tPath.join(Path.join(Path.from(\"api\"), Path.from(\"v1\")), Path.from(\"users\")),\n\t\tPath.from(\"123\"),\n\t);\n\texpect(path).toBe(\"api/v1/users/123\" as Path.Valid);\n});\n\ntest(\"isEmpty checks correctly\", () => {\n\texpect(Path.from(\"\") === \"\").toBe(true);\n\texpect(Path.from(\"foo\") === \"\").toBe(false);\n\texpect(Path.empty() === \"\").toBe(true);\n});\n\ntest(\"length property works correctly\", () => {\n\texpect(Path.from(\"foo\").length).toBe(3);\n\texpect(Path.from(\"foo/bar\").length).toBe(7);\n\texpect(Path.empty().length).toBe(0);\n});\n\ntest(\"equals checks correctly\", () => {\n\tconst path1 = Path.from(\"foo/bar\");\n\tconst path2 = Path.from(\"/foo/bar/\");\n\tconst path3 = Path.from(\"foo/baz\");\n\n\texpect(path1 === path2).toBe(true);\n\texpect(path1 === path3).toBe(false);\n});\n\ntest(\"JSON serialization works\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\texpect(JSON.stringify(path)).toBe('\"foo/bar\"');\n});\n\ntest(\"handles paths with multiple consecutive slashes\", () => {\n\tconst path = Path.from(\"foo//bar///baz\");\n\t// Multiple consecutive slashes are collapsed to single slashes\n\texpect(path).toBe(\"foo/bar/baz\" as Path.Valid);\n});\n\ntest(\"removes multiple slashes comprehensively\", () => {\n\t// Test various multiple slash scenarios\n\texpect(Path.from(\"foo//bar\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"foo///bar\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"foo////bar\")).toBe(\"foo/bar\" as Path.Valid);\n\n\t// Multiple occurrences of double slashes\n\texpect(Path.from(\"foo//bar//baz\")).toBe(\"foo/bar/baz\" as Path.Valid);\n\texpect(Path.from(\"a//b//c//d\")).toBe(\"a/b/c/d\" as Path.Valid);\n\n\t// Mixed slash counts\n\texpect(Path.from(\"foo//bar///baz////qux\")).toBe(\"foo/bar/baz/qux\" as Path.Valid);\n\n\t// With leading and trailing slashes\n\texpect(Path.from(\"//foo//bar//\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"///foo///bar///\")).toBe(\"foo/bar\" as Path.Valid);\n\n\t// Edge case: only slashes\n\texpect(Path.from(\"//\")).toBe(\"\" as Path.Valid);\n\texpect(Path.from(\"////\")).toBe(\"\" as Path.Valid);\n\n\t// Test that operations work correctly with normalized paths\n\tconst pathWithSlashes = Path.from(\"foo//bar///baz\");\n\texpect(Path.hasPrefix(Path.from(\"foo/bar\"), pathWithSlashes)).toBe(true);\n\texpect(Path.stripPrefix(Path.from(\"foo\"), pathWithSlashes)).toBe(\"bar/baz\" as Path.Valid);\n\texpect(Path.join(pathWithSlashes, Path.from(\"qux\"))).toBe(\"foo/bar/baz/qux\" as Path.Valid);\n});\n\ntest(\"handles special characters\", () => {\n\tconst path = Path.from(\"foo-bar_baz.txt\");\n\texpect(path).toBe(\"foo-bar_baz.txt\" as Path.Valid);\n\texpect(Path.hasPrefix(Path.from(\"foo-bar\"), path)).toBe(false);\n\texpect(Path.hasPrefix(Path.from(\"foo-bar_baz.txt\"), path)).toBe(true);\n});\n\ntest(\"from accepts multiple arguments\", () => {\n\texpect(Path.from(\"foo\", \"bar\", \"baz\")).toBe(\"foo/bar/baz\" as Path.Valid);\n\texpect(Path.from(\"api\", \"v1\", \"users\")).toBe(\"api/v1/users\" as Path.Valid);\n});\n\ntest(\"from handles empty strings in arguments\", () => {\n\texpect(Path.from(\"foo\", \"\", \"bar\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"\", \"foo\", \"bar\", \"\")).toBe(\"foo/bar\" as Path.Valid);\n});\n\ntest(\"from sanitizes multiple arguments with slashes\", () => {\n\texpect(Path.from(\"/foo/\", \"/bar/\", \"/baz/\")).toBe(\"foo/bar/baz\" as Path.Valid);\n\texpect(Path.from(\"foo//\", \"//bar\", \"baz\")).toBe(\"foo/bar/baz\" as Path.Valid);\n});\n"]}
|
|
1
|
+
{"version":3,"file":"path.test.js","sourceRoot":"","sources":["../src/path.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,IAAI,CAAC,qDAAqD,EAAE,GAAG,EAAE;IAChE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,SAAuB,CAAC,CAAC;IAC7D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAA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C,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnF,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAqB,CAAC,CAAC;IACzD,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AACzD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAC/C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAe,CAAC;IACjG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,QAAsB,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AACvE,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"bun:test\";\nimport * as Path from \"./path.ts\";\n\ntest(\"Path constructor trims leading and trailing slashes\", () => {\n\texpect(Path.from(\"/foo/bar/\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"///foo/bar///\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"foo/bar\")).toBe(\"foo/bar\" as Path.Valid);\n});\n\ntest(\"Path constructor handles empty paths\", () => {\n\texpect(Path.from(\"\")).toBe(\"\" as Path.Valid);\n\texpect(Path.from(\"/\")).toBe(\"\" as Path.Valid);\n\texpect(Path.from(\"///\")).toBe(\"\" as Path.Valid);\n});\n\ntest(\"hasPrefix matches exact paths\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\texpect(Path.hasPrefix(Path.from(\"foo/bar\"), path)).toBe(true);\n});\n\ntest(\"hasPrefix matches proper prefixes\", () => {\n\tconst path = Path.from(\"foo/bar/baz\");\n\texpect(Path.hasPrefix(Path.from(\"foo\"), path)).toBe(true);\n\texpect(Path.hasPrefix(Path.from(\"foo/bar\"), path)).toBe(true);\n});\n\ntest(\"hasPrefix does not match partial segment prefixes\", () => {\n\tconst path = Path.from(\"foobar\");\n\texpect(Path.hasPrefix(Path.from(\"foo\"), path)).toBe(false);\n\n\tconst path2 = Path.from(\"foo/bar\");\n\texpect(Path.hasPrefix(Path.from(\"fo\"), path2)).toBe(false);\n});\n\ntest(\"hasPrefix handles empty prefix\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\texpect(Path.hasPrefix(Path.empty(), path)).toBe(true);\n});\n\ntest(\"hasPrefix ignores trailing slashes in prefix\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\texpect(Path.hasPrefix(Path.from(\"foo/\"), path)).toBe(true);\n\texpect(Path.hasPrefix(Path.from(\"foo/bar/\"), path)).toBe(true);\n});\n\ntest(\"stripPrefix strips valid prefixes\", () => {\n\tconst path = Path.from(\"foo/bar/baz\");\n\n\tconst suffix1 = Path.stripPrefix(Path.from(\"foo\"), path);\n\texpect(suffix1).toBe(\"bar/baz\" as Path.Valid);\n\n\tconst suffix2 = Path.stripPrefix(Path.from(\"foo/bar\"), path);\n\texpect(suffix2).toBe(\"baz\" as Path.Valid);\n\n\tconst suffix3 = Path.stripPrefix(Path.from(\"foo/bar/baz\"), path);\n\texpect(suffix3).toBe(\"\" as Path.Valid);\n});\n\ntest(\"stripPrefix returns null for invalid prefixes\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\texpect(Path.stripPrefix(Path.from(\"notfound\"), path)).toBe(null);\n\texpect(Path.stripPrefix(Path.from(\"fo\"), path)).toBe(null);\n});\n\ntest(\"stripPrefix handles empty prefix\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\tconst result = Path.stripPrefix(Path.empty(), path);\n\texpect(result).toBe(\"foo/bar\" as Path.Valid);\n});\n\ntest(\"stripPrefix accepts Path instances\", () => {\n\tconst path = Path.from(\"foo/bar/baz\");\n\tconst prefix = Path.from(\"foo/bar\");\n\tconst result = Path.stripPrefix(prefix, path);\n\texpect(result).toBe(\"baz\" as Path.Valid);\n});\n\ntest(\"join paths with slashes\", () => {\n\tconst base = Path.from(\"foo\");\n\tconst joined = Path.join(base, Path.from(\"bar\"));\n\texpect(joined).toBe(\"foo/bar\" as Path.Valid);\n});\n\ntest(\"join handles empty base\", () => {\n\tconst base = Path.empty();\n\tconst joined = Path.join(base, Path.from(\"bar\"));\n\texpect(joined).toBe(\"bar\" as Path.Valid);\n});\n\ntest(\"join handles empty suffix\", () => {\n\tconst base = Path.from(\"foo\");\n\tconst joined = Path.join(base, Path.empty());\n\texpect(joined).toBe(\"foo\" as Path.Valid);\n});\n\ntest(\"join accepts Path instances\", () => {\n\tconst base = Path.from(\"foo\");\n\tconst suffix = Path.from(\"bar\");\n\tconst joined = Path.join(base, suffix);\n\texpect(joined).toBe(\"foo/bar\" as Path.Valid);\n});\n\ntest(\"join handles multiple joins\", () => {\n\tconst path = Path.join(\n\t\tPath.join(Path.join(Path.from(\"api\"), Path.from(\"v1\")), Path.from(\"users\")),\n\t\tPath.from(\"123\"),\n\t);\n\texpect(path).toBe(\"api/v1/users/123\" as Path.Valid);\n});\n\ntest(\"isEmpty checks correctly\", () => {\n\texpect(Path.from(\"\") === \"\").toBe(true);\n\texpect(Path.from(\"foo\") === \"\").toBe(false);\n\texpect(Path.empty() === \"\").toBe(true);\n});\n\ntest(\"length property works correctly\", () => {\n\texpect(Path.from(\"foo\").length).toBe(3);\n\texpect(Path.from(\"foo/bar\").length).toBe(7);\n\texpect(Path.empty().length).toBe(0);\n});\n\ntest(\"equals checks correctly\", () => {\n\tconst path1 = Path.from(\"foo/bar\");\n\tconst path2 = Path.from(\"/foo/bar/\");\n\tconst path3 = Path.from(\"foo/baz\");\n\n\texpect(path1 === path2).toBe(true);\n\texpect(path1 === path3).toBe(false);\n});\n\ntest(\"JSON serialization works\", () => {\n\tconst path = Path.from(\"foo/bar\");\n\texpect(JSON.stringify(path)).toBe('\"foo/bar\"');\n});\n\ntest(\"handles paths with multiple consecutive slashes\", () => {\n\tconst path = Path.from(\"foo//bar///baz\");\n\t// Multiple consecutive slashes are collapsed to single slashes\n\texpect(path).toBe(\"foo/bar/baz\" as Path.Valid);\n});\n\ntest(\"removes multiple slashes comprehensively\", () => {\n\t// Test various multiple slash scenarios\n\texpect(Path.from(\"foo//bar\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"foo///bar\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"foo////bar\")).toBe(\"foo/bar\" as Path.Valid);\n\n\t// Multiple occurrences of double slashes\n\texpect(Path.from(\"foo//bar//baz\")).toBe(\"foo/bar/baz\" as Path.Valid);\n\texpect(Path.from(\"a//b//c//d\")).toBe(\"a/b/c/d\" as Path.Valid);\n\n\t// Mixed slash counts\n\texpect(Path.from(\"foo//bar///baz////qux\")).toBe(\"foo/bar/baz/qux\" as Path.Valid);\n\n\t// With leading and trailing slashes\n\texpect(Path.from(\"//foo//bar//\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"///foo///bar///\")).toBe(\"foo/bar\" as Path.Valid);\n\n\t// Edge case: only slashes\n\texpect(Path.from(\"//\")).toBe(\"\" as Path.Valid);\n\texpect(Path.from(\"////\")).toBe(\"\" as Path.Valid);\n\n\t// Test that operations work correctly with normalized paths\n\tconst pathWithSlashes = Path.from(\"foo//bar///baz\");\n\texpect(Path.hasPrefix(Path.from(\"foo/bar\"), pathWithSlashes)).toBe(true);\n\texpect(Path.stripPrefix(Path.from(\"foo\"), pathWithSlashes)).toBe(\"bar/baz\" as Path.Valid);\n\texpect(Path.join(pathWithSlashes, Path.from(\"qux\"))).toBe(\"foo/bar/baz/qux\" as Path.Valid);\n});\n\ntest(\"handles special characters\", () => {\n\tconst path = Path.from(\"foo-bar_baz.txt\");\n\texpect(path).toBe(\"foo-bar_baz.txt\" as Path.Valid);\n\texpect(Path.hasPrefix(Path.from(\"foo-bar\"), path)).toBe(false);\n\texpect(Path.hasPrefix(Path.from(\"foo-bar_baz.txt\"), path)).toBe(true);\n});\n\ntest(\"from accepts multiple arguments\", () => {\n\texpect(Path.from(\"foo\", \"bar\", \"baz\")).toBe(\"foo/bar/baz\" as Path.Valid);\n\texpect(Path.from(\"api\", \"v1\", \"users\")).toBe(\"api/v1/users\" as Path.Valid);\n});\n\ntest(\"from handles empty strings in arguments\", () => {\n\texpect(Path.from(\"foo\", \"\", \"bar\")).toBe(\"foo/bar\" as Path.Valid);\n\texpect(Path.from(\"\", \"foo\", \"bar\", \"\")).toBe(\"foo/bar\" as Path.Valid);\n});\n\ntest(\"from sanitizes multiple arguments with slashes\", () => {\n\texpect(Path.from(\"/foo/\", \"/bar/\", \"/baz/\")).toBe(\"foo/bar/baz\" as Path.Valid);\n\texpect(Path.from(\"foo//\", \"//bar\", \"baz\")).toBe(\"foo/bar/baz\" as Path.Valid);\n});\n\ntest(\"parts splits a path into its components\", () => {\n\texpect(Path.parts(Path.from(\"\"))).toEqual([]);\n\texpect(Path.parts(Path.from(\"foo\"))).toEqual([\"foo\"]);\n\texpect(Path.parts(Path.from(\"/foo//bar/\"))).toEqual([\"foo\", \"bar\"]);\n});\n\ntest(\"decode enforces the max part count\", () => {\n\tconst atLimit = Array.from({ length: Path.MAX_PARTS }, (_, i) => `${i}`).join(\"/\");\n\texpect(Path.decode(atLimit)).toBe(atLimit as Path.Valid);\n\texpect(() => Path.decode(`${atLimit}/extra`)).toThrow();\n});\n\ntest(\"encode enforces the max part count\", () => {\n\tconst atLimit = Array.from({ length: Path.MAX_PARTS }, (_, i) => `${i}`).join(\"/\") as Path.Valid;\n\texpect(Path.encode(atLimit)).toBe(atLimit);\n\texpect(() => Path.encode(`${atLimit}/extra` as Path.Valid)).toThrow();\n});\n"]}
|
package/time.d.ts
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
export type Nano = number & {
|
|
3
3
|
readonly _brand: "nano";
|
|
4
4
|
};
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Constructors, conversions, and arithmetic for {@link Nano} values.
|
|
7
|
+
*
|
|
8
|
+
* Calling `Nano(x)` brands a raw number as nanoseconds. The unit is the caller's
|
|
9
|
+
* assertion: no conversion happens, so reach for `fromMicro`/`fromMilli`/`fromSecond`
|
|
10
|
+
* when the source has a unit.
|
|
11
|
+
*/
|
|
6
12
|
export declare const Nano: {
|
|
7
13
|
readonly zero: Nano;
|
|
8
14
|
readonly fromMicro: (us: Micro) => Nano;
|
|
@@ -23,7 +29,13 @@ export declare const Nano: {
|
|
|
23
29
|
export type Micro = number & {
|
|
24
30
|
readonly _brand: "micro";
|
|
25
31
|
};
|
|
26
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Constructors, conversions, and arithmetic for {@link Micro} values.
|
|
34
|
+
*
|
|
35
|
+
* Calling `Micro(x)` brands a raw number as microseconds. This asserts the unit
|
|
36
|
+
* rather than converting, so use `fromNano`/`fromMilli`/`fromSecond` to convert
|
|
37
|
+
* from another unit.
|
|
38
|
+
*/
|
|
27
39
|
export declare const Micro: {
|
|
28
40
|
readonly zero: Micro;
|
|
29
41
|
readonly fromNano: (ns: Nano) => Micro;
|
|
@@ -44,7 +56,13 @@ export declare const Micro: {
|
|
|
44
56
|
export type Milli = number & {
|
|
45
57
|
readonly _brand: "milli";
|
|
46
58
|
};
|
|
47
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Constructors, conversions, and arithmetic for {@link Milli} values.
|
|
61
|
+
*
|
|
62
|
+
* Calling `Milli(x)` brands a raw number as milliseconds. This asserts the unit
|
|
63
|
+
* rather than converting, so use `fromNano`/`fromMicro`/`fromSecond` to convert
|
|
64
|
+
* from another unit.
|
|
65
|
+
*/
|
|
48
66
|
export declare const Milli: {
|
|
49
67
|
readonly zero: Milli;
|
|
50
68
|
readonly fromNano: (ns: Nano) => Milli;
|
|
@@ -65,7 +83,13 @@ export declare const Milli: {
|
|
|
65
83
|
export type Second = number & {
|
|
66
84
|
readonly _brand: "second";
|
|
67
85
|
};
|
|
68
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Constructors, conversions, and arithmetic for {@link Second} values.
|
|
88
|
+
*
|
|
89
|
+
* Calling `Second(x)` brands a raw number as seconds. This asserts the unit
|
|
90
|
+
* rather than converting, so use `fromNano`/`fromMicro`/`fromMilli` to convert
|
|
91
|
+
* from another unit.
|
|
92
|
+
*/
|
|
69
93
|
export declare const Second: {
|
|
70
94
|
readonly zero: Second;
|
|
71
95
|
readonly fromNano: (ns: Nano) => Second;
|
package/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,IAAI;aAChB,IAAI,EAAO,IAAI;aACf,SAAS,OAAO,KAAK,KAAG,IAAI;aAC5B,SAAS,OAAO,KAAK,KAAG,IAAI;aAC5B,UAAU,MAAM,MAAM,KAAG,IAAI;aAC7B,OAAO,OAAO,IAAI,KAAG,KAAK;aAC1B,OA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MAAM;aACnC,GAAG,MAAM,MAAM,KAAK,MAAM,KAAG,MAAM;aACnC,GAAG,MAAM,MAAM,KAAK,MAAM,KAAG,MAAM;CAC1B,CAAC"}
|
package/time.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/* @ts-self-types="./time.d.ts" */
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Constructors, conversions, and arithmetic for {@link Nano} values.
|
|
4
|
+
*
|
|
5
|
+
* Calling `Nano(x)` brands a raw number as nanoseconds. The unit is the caller's
|
|
6
|
+
* assertion: no conversion happens, so reach for `fromMicro`/`fromMilli`/`fromSecond`
|
|
7
|
+
* when the source has a unit.
|
|
8
|
+
*/
|
|
3
9
|
export const Nano = {
|
|
4
10
|
zero: 0,
|
|
5
11
|
fromMicro: (us) => (us * 1_000),
|
|
@@ -16,7 +22,13 @@ export const Nano = {
|
|
|
16
22
|
max: (a, b) => Math.max(a, b),
|
|
17
23
|
min: (a, b) => Math.min(a, b),
|
|
18
24
|
};
|
|
19
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Constructors, conversions, and arithmetic for {@link Micro} values.
|
|
27
|
+
*
|
|
28
|
+
* Calling `Micro(x)` brands a raw number as microseconds. This asserts the unit
|
|
29
|
+
* rather than converting, so use `fromNano`/`fromMilli`/`fromSecond` to convert
|
|
30
|
+
* from another unit.
|
|
31
|
+
*/
|
|
20
32
|
export const Micro = {
|
|
21
33
|
zero: 0,
|
|
22
34
|
fromNano: (ns) => (ns / 1_000),
|
|
@@ -33,7 +45,13 @@ export const Micro = {
|
|
|
33
45
|
max: (a, b) => Math.max(a, b),
|
|
34
46
|
min: (a, b) => Math.min(a, b),
|
|
35
47
|
};
|
|
36
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Constructors, conversions, and arithmetic for {@link Milli} values.
|
|
50
|
+
*
|
|
51
|
+
* Calling `Milli(x)` brands a raw number as milliseconds. This asserts the unit
|
|
52
|
+
* rather than converting, so use `fromNano`/`fromMicro`/`fromSecond` to convert
|
|
53
|
+
* from another unit.
|
|
54
|
+
*/
|
|
37
55
|
export const Milli = {
|
|
38
56
|
zero: 0,
|
|
39
57
|
fromNano: (ns) => (ns / 1_000_000),
|
|
@@ -50,7 +68,13 @@ export const Milli = {
|
|
|
50
68
|
max: (a, b) => Math.max(a, b),
|
|
51
69
|
min: (a, b) => Math.min(a, b),
|
|
52
70
|
};
|
|
53
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Constructors, conversions, and arithmetic for {@link Second} values.
|
|
73
|
+
*
|
|
74
|
+
* Calling `Second(x)` brands a raw number as seconds. This asserts the unit
|
|
75
|
+
* rather than converting, so use `fromNano`/`fromMicro`/`fromMilli` to convert
|
|
76
|
+
* from another unit.
|
|
77
|
+
*/
|
|
54
78
|
export const Second = {
|
|
55
79
|
zero: 0,
|
|
56
80
|
fromNano: (ns) => (ns / 1_000_000_000),
|
package/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IACnB,IAAI,EAAE,CAAS;IACf,SAAS,EAAE,CAAC,EAAS,EAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,CAAS;IACpD,SAAS,EAAE,CAAC,EAAS,EAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,CAAS;IACxD,UAAU,EAAE,CAAC,CAAS,EAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,aAAa,CAAS;IAC5D,OAAO,EAAE,CAAC,EAAQ,EAAS,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,CAAU;IACnD,OAAO,EAAE,CAAC,EAAQ,EAAS,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,CAAU;IACvD,Q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O,EAAE,CAAC,CAAS,EAAS,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAU;IACnD,GAAG,EAAE,GAAW,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW;IACxD,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAW;IAC/D,GAAG,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAW;CACtD,CAAC","sourcesContent":["/** A duration in nanoseconds, branded so it can't be mixed with other units. */\nexport type Nano = number & { readonly _brand: \"nano\" };\n\n/**\n * Constructors, conversions, and arithmetic for {@link Nano} values.\n *\n * Calling `Nano(x)` brands a raw number as nanoseconds. The unit is the caller's\n * assertion: no conversion happens, so reach for `fromMicro`/`fromMilli`/`fromSecond`\n * when the source has a unit.\n */\nexport const Nano = {\n\tzero: 0 as Nano,\n\tfromMicro: (us: Micro): Nano => (us * 1_000) as Nano,\n\tfromMilli: (ms: Milli): Nano => (ms * 1_000_000) as Nano,\n\tfromSecond: (s: Second): Nano => (s * 1_000_000_000) as Nano,\n\ttoMicro: (ns: Nano): Micro => (ns / 1_000) as Micro,\n\ttoMilli: (ns: Nano): Milli => (ns / 1_000_000) as Milli,\n\ttoSecond: (ns: Nano): Second => (ns / 1_000_000_000) as Second,\n\tnow: (): Nano => (performance.now() * 1_000_000) as Nano,\n\tadd: (a: Nano, b: Nano): Nano => (a + b) as Nano,\n\tsub: (a: Nano, b: Nano): Nano => (a - b) as Nano,\n\tmul: (a: Nano, b: number): Nano => (a * b) as Nano,\n\tdiv: (a: Nano, b: number): Nano => (a / b) as Nano,\n\tmax: (a: Nano, b: Nano): Nano => Math.max(a, b) as Nano,\n\tmin: (a: Nano, b: Nano): Nano => Math.min(a, b) as Nano,\n} as const;\n\n/** A duration in microseconds, branded so it can't be mixed with other units. */\nexport type Micro = number & { readonly _brand: \"micro\" };\n\n/**\n * Constructors, conversions, and arithmetic for {@link Micro} values.\n *\n * Calling `Micro(x)` brands a raw number as microseconds. This asserts the unit\n * rather than converting, so use `fromNano`/`fromMilli`/`fromSecond` to convert\n * from another unit.\n */\nexport const Micro = {\n\tzero: 0 as Micro,\n\tfromNano: (ns: Nano): Micro => (ns / 1_000) as Micro,\n\tfromMilli: (ms: Milli): Micro => (ms * 1_000) as Micro,\n\tfromSecond: (s: Second): Micro => (s * 1_000_000) as Micro,\n\ttoNano: (us: Micro): Nano => (us * 1_000) as Nano,\n\ttoMilli: (us: Micro): Milli => (us / 1_000) as Milli,\n\ttoSecond: (us: Micro): Second => (us / 1_000_000) as Second,\n\tnow: (): Micro => (performance.now() * 1_000) as Micro,\n\tadd: (a: Micro, b: Micro): Micro => (a + b) as Micro,\n\tsub: (a: Micro, b: Micro): Micro => (a - b) as Micro,\n\tmul: (a: Micro, b: number): Micro => (a * b) as Micro,\n\tdiv: (a: Micro, b: number): Micro => (a / b) as Micro,\n\tmax: (a: Micro, b: Micro): Micro => Math.max(a, b) as Micro,\n\tmin: (a: Micro, b: Micro): Micro => Math.min(a, b) as Micro,\n} as const;\n\n/** A duration in milliseconds, branded so it can't be mixed with other units. */\nexport type Milli = number & { readonly _brand: \"milli\" };\n\n/**\n * Constructors, conversions, and arithmetic for {@link Milli} values.\n *\n * Calling `Milli(x)` brands a raw number as milliseconds. This asserts the unit\n * rather than converting, so use `fromNano`/`fromMicro`/`fromSecond` to convert\n * from another unit.\n */\nexport const Milli = {\n\tzero: 0 as Milli,\n\tfromNano: (ns: Nano): Milli => (ns / 1_000_000) as Milli,\n\tfromMicro: (us: Micro): Milli => (us / 1_000) as Milli,\n\tfromSecond: (s: Second): Milli => (s * 1_000) as Milli,\n\ttoNano: (ms: Milli): Nano => (ms * 1_000_000) as Nano,\n\ttoMicro: (ms: Milli): Micro => (ms * 1_000) as Micro,\n\ttoSecond: (ms: Milli): Second => (ms / 1_000) as Second,\n\tnow: (): Milli => performance.now() as Milli,\n\tadd: (a: Milli, b: Milli): Milli => (a + b) as Milli,\n\tsub: (a: Milli, b: Milli): Milli => (a - b) as Milli,\n\tmul: (a: Milli, b: number): Milli => (a * b) as Milli,\n\tdiv: (a: Milli, b: number): Milli => (a / b) as Milli,\n\tmax: (a: Milli, b: Milli): Milli => Math.max(a, b) as Milli,\n\tmin: (a: Milli, b: Milli): Milli => Math.min(a, b) as Milli,\n} as const;\n\n/** A duration in seconds, branded so it can't be mixed with other units. */\nexport type Second = number & { readonly _brand: \"second\" };\n\n/**\n * Constructors, conversions, and arithmetic for {@link Second} values.\n *\n * Calling `Second(x)` brands a raw number as seconds. This asserts the unit\n * rather than converting, so use `fromNano`/`fromMicro`/`fromMilli` to convert\n * from another unit.\n */\nexport const Second = {\n\tzero: 0 as Second,\n\tfromNano: (ns: Nano): Second => (ns / 1_000_000_000) as Second,\n\tfromMicro: (us: Micro): Second => (us / 1_000_000) as Second,\n\tfromMilli: (ms: Milli): Second => (ms / 1_000) as Second,\n\ttoNano: (s: Second): Nano => (s * 1_000_000_000) as Nano,\n\ttoMicro: (s: Second): Micro => (s * 1_000_000) as Micro,\n\ttoMilli: (s: Second): Milli => (s * 1_000) as Milli,\n\tnow: (): Second => (performance.now() / 1_000) as Second,\n\tadd: (a: Second, b: Second): Second => (a + b) as Second,\n\tsub: (a: Second, b: Second): Second => (a - b) as Second,\n\tmul: (a: Second, b: number): Second => (a * b) as Second,\n\tdiv: (a: Second, b: number): Second => (a / b) as Second,\n\tmax: (a: Second, b: Second): Second => Math.max(a, b) as Second,\n\tmin: (a: Second, b: Second): Second => Math.min(a, b) as Second,\n} as const;\n"]}
|