Unverified Commit 0d511416 authored by Hong Minhee's avatar Hong Minhee
Browse files

Compact inspection strings of URL objects

parent fabad8fe
Loading
Loading
Loading
Loading
+2246 −994

File changed.

Preview size limit exceeded, changes collapsed.

+17 −20
Original line number Diff line number Diff line
import { getFieldName } from "./field.ts";
import type { TypeSchema } from "./schema.ts";
import { areAllScalarTypes } from "./type.ts";

export async function* generateInspector(
  typeUri: string,
@@ -33,11 +32,10 @@ export async function* generateInspector(
  for (const property of type.properties) {
    const fieldName = await getFieldName(property.uri);
    const localName = await getFieldName(property.uri, "");
    if (areAllScalarTypes(property.range, types)) {
      yield `const ${localName} = this.${fieldName};`;
    } else {
    yield `
      const ${localName} = this.${fieldName}.map(v => v instanceof URL
      const ${localName} = this.${fieldName}
        // deno-lint-ignore no-explicit-any
        .map((v: any) => v instanceof URL
          ? {
              [Symbol.for("Deno.customInspect")]: (
                inspect: typeof Deno.inspect,
@@ -51,7 +49,6 @@ export async function* generateInspector(
            }
          : v);
    `;
    }
    if (property.functional || property.singularAccessor) {
      yield `
      if (${localName}.length == 1) {
+138 −2592

File changed.

Preview size limit exceeded, changes collapsed.