@fedify/vocab-tools 2.4.0-dev.2245 → 2.4.0-dev.2253
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/deno.json +1 -1
- package/dist/mod.cjs +11 -5
- package/dist/mod.js +11 -5
- package/package.json +1 -1
- package/src/__snapshots__/class.test.ts.deno.snap +608 -602
- package/src/__snapshots__/class.test.ts.node.snap +608 -602
- package/src/__snapshots__/class.test.ts.snap +608 -602
- package/src/class.ts +6 -0
- package/src/inspector.ts +4 -4
package/src/class.ts
CHANGED
|
@@ -313,6 +313,12 @@ function decodeIri(iri: string): URL {
|
|
|
313
313
|
? new URL("at://" + encodeURIComponent(iri.substring(5)))
|
|
314
314
|
: parseIri(iri);
|
|
315
315
|
}
|
|
316
|
+
|
|
317
|
+
function inspectIri(iri: URL): string {
|
|
318
|
+
// Inspecting an object must not throw, even for a URL that cannot be
|
|
319
|
+
// formatted as an IRI, e.g., a malformed portable ID:
|
|
320
|
+
try { return formatIri(iri); } catch { return iri.href; }
|
|
321
|
+
}
|
|
316
322
|
`;
|
|
317
323
|
yield `
|
|
318
324
|
function isValidLanguageTag(language: string): boolean {
|
package/src/inspector.ts
CHANGED
|
@@ -21,12 +21,12 @@ export async function* generateInspector(
|
|
|
21
21
|
[Symbol.for("Deno.customInspect")]: (
|
|
22
22
|
inspect: typeof Deno.inspect,
|
|
23
23
|
options: Deno.InspectOptions,
|
|
24
|
-
): string => "URL " + inspect(this.id
|
|
24
|
+
): string => "URL " + inspect(inspectIri(this.id!), options),
|
|
25
25
|
[Symbol.for("nodejs.util.inspect.custom")]: (
|
|
26
26
|
_depth: number,
|
|
27
27
|
options: unknown,
|
|
28
28
|
inspect: (value: unknown, options: unknown) => string,
|
|
29
|
-
): string => "URL " + inspect(this.id
|
|
29
|
+
): string => "URL " + inspect(inspectIri(this.id!), options),
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
`;
|
|
@@ -44,12 +44,12 @@ export async function* generateInspector(
|
|
|
44
44
|
[Symbol.for("Deno.customInspect")]: (
|
|
45
45
|
inspect: typeof Deno.inspect,
|
|
46
46
|
options: Deno.InspectOptions,
|
|
47
|
-
): string => "URL " + inspect(v
|
|
47
|
+
): string => "URL " + inspect(inspectIri(v), options),
|
|
48
48
|
[Symbol.for("nodejs.util.inspect.custom")]: (
|
|
49
49
|
_depth: number,
|
|
50
50
|
options: unknown,
|
|
51
51
|
inspect: (value: unknown, options: unknown) => string,
|
|
52
|
-
): string => "URL " + inspect(v
|
|
52
|
+
): string => "URL " + inspect(inspectIri(v), options),
|
|
53
53
|
}
|
|
54
54
|
: v);
|
|
55
55
|
`;
|