diff --git a/.changeset/early-comics-shout.md b/.changeset/early-comics-shout.md new file mode 100644 index 00000000000..59090fad718 --- /dev/null +++ b/.changeset/early-comics-shout.md @@ -0,0 +1,7 @@ +--- +"@effect/platform": minor +"effect": minor +"@effect/schema": minor +--- + +add deno support to Inspectable diff --git a/packages/effect/src/BigDecimal.ts b/packages/effect/src/BigDecimal.ts index 360dd6de230..29ecd5e3f1e 100644 --- a/packages/effect/src/BigDecimal.ts +++ b/packages/effect/src/BigDecimal.ts @@ -18,7 +18,7 @@ import * as Equal from "./Equal.js" import * as equivalence from "./Equivalence.js" import { dual, pipe } from "./Function.js" import * as Hash from "./Hash.js" -import { type Inspectable, NodeInspectSymbol } from "./Inspectable.js" +import { DenoInspectSymbol, type Inspectable, NodeInspectSymbol } from "./Inspectable.js" import * as Option from "./Option.js" import * as order from "./Order.js" import type { Ordering } from "./Ordering.js" @@ -74,6 +74,9 @@ const BigDecimalProto: Omit = { scale: this.scale } }, + [DenoInspectSymbol](this: BigDecimal) { + return this.toJSON() + }, [NodeInspectSymbol](this: BigDecimal) { return this.toJSON() }, diff --git a/packages/effect/src/Chunk.ts b/packages/effect/src/Chunk.ts index ab7ddffab32..8d8c62dd8c6 100644 --- a/packages/effect/src/Chunk.ts +++ b/packages/effect/src/Chunk.ts @@ -9,7 +9,7 @@ import * as Equivalence from "./Equivalence.js" import { dual, identity, pipe } from "./Function.js" import * as Hash from "./Hash.js" import type { TypeLambda } from "./HKT.js" -import { format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" +import { DenoInspectSymbol, format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" import type { NonEmptyIterable } from "./NonEmptyIterable.js" import type { Option } from "./Option.js" import * as O from "./Option.js" @@ -135,6 +135,9 @@ const ChunkProto: Omit, "backing" | "depth" | "left" | "length" | values: toReadonlyArray(this).map(toJSON) } }, + [DenoInspectSymbol](this: Chunk) { + return this.toJSON() + }, [NodeInspectSymbol](this: Chunk) { return this.toJSON() }, diff --git a/packages/effect/src/Cron.ts b/packages/effect/src/Cron.ts index 856d6c0b443..7a75721896f 100644 --- a/packages/effect/src/Cron.ts +++ b/packages/effect/src/Cron.ts @@ -7,7 +7,7 @@ import * as Equal from "./Equal.js" import * as equivalence from "./Equivalence.js" import { dual, pipe } from "./Function.js" import * as Hash from "./Hash.js" -import { format, type Inspectable, NodeInspectSymbol } from "./Inspectable.js" +import { DenoInspectSymbol, format, type Inspectable, NodeInspectSymbol } from "./Inspectable.js" import * as N from "./Number.js" import { type Pipeable, pipeArguments } from "./Pipeable.js" import { hasProperty } from "./Predicate.js" @@ -67,6 +67,9 @@ const CronProto: Omit = { return { _id: "Duration", _tag: "Infinity" } } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/FiberHandle.ts b/packages/effect/src/FiberHandle.ts index 4392172a82c..50c648a1775 100644 --- a/packages/effect/src/FiberHandle.ts +++ b/packages/effect/src/FiberHandle.ts @@ -64,6 +64,9 @@ const Proto = { state: this.state } }, + [Inspectable.DenoInspectSymbol](this: FiberHandle) { + return this.toJSON() + }, [Inspectable.NodeInspectSymbol](this: FiberHandle) { return this.toJSON() }, diff --git a/packages/effect/src/FiberMap.ts b/packages/effect/src/FiberMap.ts index 57c0fff3732..4f9ba92e526 100644 --- a/packages/effect/src/FiberMap.ts +++ b/packages/effect/src/FiberMap.ts @@ -74,6 +74,9 @@ const Proto = { state: this.state } }, + [Inspectable.DenoInspectSymbol](this: FiberMap) { + return this.toJSON() + }, [Inspectable.NodeInspectSymbol](this: FiberMap) { return this.toJSON() }, diff --git a/packages/effect/src/FiberSet.ts b/packages/effect/src/FiberSet.ts index 53e0a50a8cc..16e8de49d0c 100644 --- a/packages/effect/src/FiberSet.ts +++ b/packages/effect/src/FiberSet.ts @@ -72,6 +72,9 @@ const Proto = { state: this.state } }, + [Inspectable.DenoInspectSymbol](this: FiberSet) { + return this.toJSON() + }, [Inspectable.NodeInspectSymbol](this: FiberSet) { return this.toJSON() }, diff --git a/packages/effect/src/Inspectable.ts b/packages/effect/src/Inspectable.ts index 95732771909..305432ef15a 100644 --- a/packages/effect/src/Inspectable.ts +++ b/packages/effect/src/Inspectable.ts @@ -16,6 +16,18 @@ export const NodeInspectSymbol = Symbol.for("nodejs.util.inspect.custom") */ export type NodeInspectSymbol = typeof NodeInspectSymbol +/** + * @since 3.9.0 + * @category symbols + */ +export const DenoInspectSymbol = Symbol.for("Deno.customInspect") + +/** + * @since 3.9.0 + * @category symbols + */ +export type DenoInspectSymbol = typeof DenoInspectSymbol + /** * @since 2.0.0 * @category models @@ -24,6 +36,7 @@ export interface Inspectable { toString(): string toJSON(): unknown [NodeInspectSymbol](): unknown + [DenoInspectSymbol](): unknown } /** @@ -56,6 +69,9 @@ export const BaseProto: Inspectable = { [NodeInspectSymbol]() { return this.toJSON() }, + [DenoInspectSymbol]() { + return this.toJSON() + }, toString() { return format(this.toJSON()) } @@ -75,6 +91,12 @@ export abstract class Class { [NodeInspectSymbol]() { return this.toJSON() } + /** + * @since 3.9.0 + */ + [DenoInspectSymbol]() { + return this.toJSON() + } /** * @since 2.0.0 */ diff --git a/packages/effect/src/List.ts b/packages/effect/src/List.ts index af65300bdb0..12d9bd78667 100644 --- a/packages/effect/src/List.ts +++ b/packages/effect/src/List.ts @@ -28,7 +28,7 @@ import * as Equal from "./Equal.js" import * as Equivalence from "./Equivalence.js" import { dual, identity, unsafeCoerce } from "./Function.js" import * as Hash from "./Hash.js" -import { format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" +import { DenoInspectSymbol, format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" import type { nonEmpty, NonEmptyIterable } from "./NonEmptyIterable.js" import * as Option from "./Option.js" import type { Pipeable } from "./Pipeable.js" @@ -110,6 +110,9 @@ const ConsProto: Omit, "head" | "tail" | typeof nonEmpty> = { values: toArray(this).map(toJSON) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, @@ -176,6 +179,9 @@ const NilProto: Nil = { _tag: "Nil" } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/Micro.ts b/packages/effect/src/Micro.ts index 6cf83213b31..1a1c80f2865 100644 --- a/packages/effect/src/Micro.ts +++ b/packages/effect/src/Micro.ts @@ -13,7 +13,7 @@ import { constTrue, constVoid, dual, identity, type LazyArg } from "./Function.j import { globalValue } from "./GlobalValue.js" import type { TypeLambda } from "./HKT.js" import type { Inspectable } from "./Inspectable.js" -import { NodeInspectSymbol, toStringUnknown } from "./Inspectable.js" +import { DenoInspectSymbol, NodeInspectSymbol, toStringUnknown } from "./Inspectable.js" import * as doNotation from "./internal/doNotation.js" import { StructuralPrototype } from "./internal/effectable.js" import { SingleShotGen } from "./internal/singleShotGen.js" @@ -323,6 +323,9 @@ abstract class MicroCauseImpl extends globalThis.Error im toString() { return this.stack } + [DenoInspectSymbol]() { + return this.stack + } [NodeInspectSymbol]() { return this.stack } @@ -4097,6 +4100,9 @@ const YieldableError: new(message?: string) => YieldableError = (function() { toJSON() { return { ...this } } + [DenoInspectSymbol](): string { + return this[NodeInspectSymbol]() + } [NodeInspectSymbol](): string { const stack = this.stack if (stack) { diff --git a/packages/effect/src/MutableHashMap.ts b/packages/effect/src/MutableHashMap.ts index 1b5e0cabbba..8ab81caca95 100644 --- a/packages/effect/src/MutableHashMap.ts +++ b/packages/effect/src/MutableHashMap.ts @@ -5,7 +5,7 @@ import type { NonEmptyArray } from "./Array.js" import * as Equal from "./Equal.js" import { dual } from "./Function.js" import * as Hash from "./Hash.js" -import { format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" +import { DenoInspectSymbol, format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" import * as Option from "./Option.js" import type { Pipeable } from "./Pipeable.js" import { pipeArguments } from "./Pipeable.js" @@ -46,6 +46,9 @@ const MutableHashMapProto: Omit, "referential" values: Array.from(this).map(toJSON) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/MutableHashSet.ts b/packages/effect/src/MutableHashSet.ts index d61e72660d4..0f7b2d21bfe 100644 --- a/packages/effect/src/MutableHashSet.ts +++ b/packages/effect/src/MutableHashSet.ts @@ -2,7 +2,7 @@ * @since 2.0.0 */ import * as Dual from "./Function.js" -import { format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" +import { DenoInspectSymbol, format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" import * as MutableHashMap from "./MutableHashMap.js" import type { Pipeable } from "./Pipeable.js" import { pipeArguments } from "./Pipeable.js" @@ -40,6 +40,9 @@ const MutableHashSetProto: Omit, "keyMap"> = { values: Array.from(this).map(toJSON) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/MutableList.ts b/packages/effect/src/MutableList.ts index 1027aaaa5c6..2c5e6d46e68 100644 --- a/packages/effect/src/MutableList.ts +++ b/packages/effect/src/MutableList.ts @@ -2,7 +2,7 @@ * @since 2.0.0 */ import * as Dual from "./Function.js" -import { format, NodeInspectSymbol, toJSON } from "./Inspectable.js" +import { DenoInspectSymbol, format, NodeInspectSymbol, toJSON } from "./Inspectable.js" import type { Inspectable } from "./Inspectable.js" import type { Pipeable } from "./Pipeable.js" import { pipeArguments } from "./Pipeable.js" @@ -63,6 +63,9 @@ const MutableListProto: Omit, "head" | "tail"> = { values: Array.from(this).map(toJSON) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/MutableQueue.ts b/packages/effect/src/MutableQueue.ts index bbd2326566e..5301e707af9 100644 --- a/packages/effect/src/MutableQueue.ts +++ b/packages/effect/src/MutableQueue.ts @@ -3,7 +3,7 @@ */ import * as Chunk from "./Chunk.js" import * as Dual from "./Function.js" -import { format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" +import { DenoInspectSymbol, format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" import * as MutableList from "./MutableList.js" import type { Pipeable } from "./Pipeable.js" import { pipeArguments } from "./Pipeable.js" @@ -59,6 +59,9 @@ const MutableQueueProto: Omit, "queue" | "capacity"> = { values: Array.from(this).map(toJSON) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/MutableRef.ts b/packages/effect/src/MutableRef.ts index 0a2949eab5f..c4088f7bb4a 100644 --- a/packages/effect/src/MutableRef.ts +++ b/packages/effect/src/MutableRef.ts @@ -3,7 +3,7 @@ */ import * as Equal from "./Equal.js" import * as Dual from "./Function.js" -import { format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" +import { DenoInspectSymbol, format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" import type { Pipeable } from "./Pipeable.js" import { pipeArguments } from "./Pipeable.js" @@ -37,6 +37,9 @@ const MutableRefProto: Omit, "current"> = { current: toJSON(this.current) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/SortedMap.ts b/packages/effect/src/SortedMap.ts index 61d23cbf85c..0d0e4aa1ebd 100644 --- a/packages/effect/src/SortedMap.ts +++ b/packages/effect/src/SortedMap.ts @@ -5,7 +5,7 @@ import * as Equal from "./Equal.js" import * as Dual from "./Function.js" import { pipe } from "./Function.js" import * as Hash from "./Hash.js" -import { format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" +import { DenoInspectSymbol, format, type Inspectable, NodeInspectSymbol, toJSON } from "./Inspectable.js" import * as Option from "./Option.js" import type { Order } from "./Order.js" import type { Pipeable } from "./Pipeable.js" @@ -62,6 +62,9 @@ const SortedMapProto: Omit, "tree"> = { values: Array.from(this).map(toJSON) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/SortedSet.ts b/packages/effect/src/SortedSet.ts index 2bc50e544ba..721f1bf563e 100644 --- a/packages/effect/src/SortedSet.ts +++ b/packages/effect/src/SortedSet.ts @@ -7,7 +7,7 @@ import * as Dual from "./Function.js" import { pipe } from "./Function.js" import * as Hash from "./Hash.js" import type { Inspectable } from "./Inspectable.js" -import { format, NodeInspectSymbol, toJSON } from "./Inspectable.js" +import { DenoInspectSymbol, format, NodeInspectSymbol, toJSON } from "./Inspectable.js" import type { Order } from "./Order.js" import type { Pipeable } from "./Pipeable.js" import { pipeArguments } from "./Pipeable.js" @@ -62,6 +62,9 @@ const SortedSetProto: Omit, "keyTree"> = { values: Array.from(this).map(toJSON) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/internal/cause.ts b/packages/effect/src/internal/cause.ts index bb705011d40..fef9126ffcd 100644 --- a/packages/effect/src/internal/cause.ts +++ b/packages/effect/src/internal/cause.ts @@ -8,7 +8,7 @@ import { constFalse, constTrue, dual, identity, pipe } from "../Function.js" import { globalValue } from "../GlobalValue.js" import * as Hash from "../Hash.js" import * as HashSet from "../HashSet.js" -import { NodeInspectSymbol, toJSON } from "../Inspectable.js" +import { DenoInspectSymbol, NodeInspectSymbol, toJSON } from "../Inspectable.js" import * as Option from "../Option.js" import { pipeArguments } from "../Pipeable.js" import type { Predicate, Refinement } from "../Predicate.js" @@ -69,6 +69,9 @@ const proto = { toString(this: Cause.Cause) { return pretty(this) }, + [DenoInspectSymbol](this: Cause.Cause) { + return this.toJSON() + }, [NodeInspectSymbol](this: Cause.Cause) { return this.toJSON() } diff --git a/packages/effect/src/internal/context.ts b/packages/effect/src/internal/context.ts index 1fe348d8a58..b3bb12a7f5c 100644 --- a/packages/effect/src/internal/context.ts +++ b/packages/effect/src/internal/context.ts @@ -3,7 +3,7 @@ import * as Equal from "../Equal.js" import type { LazyArg } from "../Function.js" import { dual } from "../Function.js" import * as Hash from "../Hash.js" -import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js" +import { DenoInspectSymbol, format, NodeInspectSymbol, toJSON } from "../Inspectable.js" import type * as O from "../Option.js" import { pipeArguments } from "../Pipeable.js" import { hasProperty } from "../Predicate.js" @@ -42,6 +42,9 @@ export const TagProto: any = { stack: this.stack } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, @@ -126,6 +129,9 @@ export const ContextProto: Omit, "unsafeMap"> = { services: Array.from(this.unsafeMap).map(toJSON) } }, + [DenoInspectSymbol]() { + return (this as any).toJSON() + }, [NodeInspectSymbol]() { return (this as any).toJSON() } diff --git a/packages/effect/src/internal/core.ts b/packages/effect/src/internal/core.ts index 4cb2e9bf4d0..110d3c8a9c0 100644 --- a/packages/effect/src/internal/core.ts +++ b/packages/effect/src/internal/core.ts @@ -21,7 +21,7 @@ import { globalValue } from "../GlobalValue.js" import * as Hash from "../Hash.js" import * as HashMap from "../HashMap.js" import type * as HashSet from "../HashSet.js" -import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js" +import { DenoInspectSymbol, format, NodeInspectSymbol, toJSON } from "../Inspectable.js" import * as List from "../List.js" import type * as LogLevel from "../LogLevel.js" import type * as LogSpan from "../LogSpan.js" @@ -177,6 +177,9 @@ class EffectPrimitive { toString() { return format(this.toJSON()) } + [DenoInspectSymbol]() { + return this.toJSON() + } [NodeInspectSymbol]() { return this.toJSON() } @@ -226,6 +229,9 @@ class EffectPrimitiveFailure { toString() { return format(this.toJSON()) } + [DenoInspectSymbol]() { + return this.toJSON() + } [NodeInspectSymbol]() { return this.toJSON() } @@ -275,6 +281,9 @@ class EffectPrimitiveSuccess { toString() { return format(this.toJSON()) } + [DenoInspectSymbol]() { + return this.toJSON() + } [NodeInspectSymbol]() { return this.toJSON() } @@ -2194,6 +2203,9 @@ export const YieldableError: new(message?: string, options?: ErrorOptions) => Ca toJSON() { return { ...this } } + [DenoInspectSymbol]() { + return this[NodeInspectSymbol]() + } [NodeInspectSymbol]() { if (this.toString !== globalThis.Error.prototype.toString) { return this.stack ? `${this.toString()}\n${this.stack.split("\n").slice(1).join("\n")}` : this.toString() diff --git a/packages/effect/src/internal/fiberId.ts b/packages/effect/src/internal/fiberId.ts index c2f16666678..11138ec3879 100644 --- a/packages/effect/src/internal/fiberId.ts +++ b/packages/effect/src/internal/fiberId.ts @@ -4,7 +4,7 @@ import { dual, pipe } from "../Function.js" import { globalValue } from "../GlobalValue.js" import * as Hash from "../Hash.js" import * as HashSet from "../HashSet.js" -import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js" +import { DenoInspectSymbol, format, NodeInspectSymbol, toJSON } from "../Inspectable.js" import * as MutableRef from "../MutableRef.js" import * as Option from "../Option.js" import { hasProperty } from "../Predicate.js" @@ -58,6 +58,9 @@ class None implements FiberId.None { _tag: this._tag } } + [DenoInspectSymbol]() { + return this.toJSON() + } [NodeInspectSymbol]() { return this.toJSON() } @@ -91,6 +94,9 @@ class Runtime implements FiberId.Runtime { startTimeMillis: this.startTimeMillis } } + [DenoInspectSymbol]() { + return this.toJSON() + } [NodeInspectSymbol]() { return this.toJSON() } @@ -131,6 +137,9 @@ class Composite implements FiberId.Composite { right: toJSON(this.right) } } + [DenoInspectSymbol]() { + return this.toJSON() + } [NodeInspectSymbol]() { return this.toJSON() } diff --git a/packages/effect/src/internal/hashMap.ts b/packages/effect/src/internal/hashMap.ts index f61e638da32..25393feae5c 100644 --- a/packages/effect/src/internal/hashMap.ts +++ b/packages/effect/src/internal/hashMap.ts @@ -3,7 +3,7 @@ import * as Dual from "../Function.js" import { identity, pipe } from "../Function.js" import * as Hash from "../Hash.js" import type * as HM from "../HashMap.js" -import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js" +import { DenoInspectSymbol, format, NodeInspectSymbol, toJSON } from "../Inspectable.js" import * as Option from "../Option.js" import { pipeArguments } from "../Pipeable.js" import { hasProperty } from "../Predicate.js" @@ -85,6 +85,9 @@ const HashMapProto: HM.HashMap = { values: Array.from(this).map(toJSON) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/internal/hashSet.ts b/packages/effect/src/internal/hashSet.ts index a60b87d0758..65cb0885326 100644 --- a/packages/effect/src/internal/hashSet.ts +++ b/packages/effect/src/internal/hashSet.ts @@ -3,7 +3,7 @@ import { dual } from "../Function.js" import * as Hash from "../Hash.js" import type { HashMap } from "../HashMap.js" import type * as HS from "../HashSet.js" -import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js" +import { DenoInspectSymbol, format, NodeInspectSymbol, toJSON } from "../Inspectable.js" import { pipeArguments } from "../Pipeable.js" import type { Predicate, Refinement } from "../Predicate.js" import { hasProperty } from "../Predicate.js" @@ -49,6 +49,9 @@ const HashSetProto: Omit, "_keyMap"> = { values: Array.from(this).map(toJSON) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/internal/mailbox.ts b/packages/effect/src/internal/mailbox.ts index 2fd91b25647..13514d5f975 100644 --- a/packages/effect/src/internal/mailbox.ts +++ b/packages/effect/src/internal/mailbox.ts @@ -287,6 +287,9 @@ class MailboxImpl extends Effectable.Class _ }, + [DenoInspectSymbol](this: Option.Option) { + return this.toJSON() + }, [NodeInspectSymbol](this: Option.Option) { return this.toJSON() }, diff --git a/packages/effect/src/internal/redBlackTree.ts b/packages/effect/src/internal/redBlackTree.ts index 9076ff9d3b6..c154be78163 100644 --- a/packages/effect/src/internal/redBlackTree.ts +++ b/packages/effect/src/internal/redBlackTree.ts @@ -2,7 +2,7 @@ import * as Chunk from "../Chunk.js" import * as Equal from "../Equal.js" import { dual, pipe } from "../Function.js" import * as Hash from "../Hash.js" -import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js" +import { DenoInspectSymbol, format, NodeInspectSymbol, toJSON } from "../Inspectable.js" import * as Option from "../Option.js" import type * as Order from "../Order.js" import type * as Ordering from "../Ordering.js" @@ -71,6 +71,9 @@ const RedBlackTreeProto: RBT.RedBlackTree = { values: Array.from(this).map(toJSON) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/effect/src/internal/runtime.ts b/packages/effect/src/internal/runtime.ts index 45f6284e207..373ccd624da 100644 --- a/packages/effect/src/internal/runtime.ts +++ b/packages/effect/src/internal/runtime.ts @@ -195,6 +195,9 @@ class FiberFailureImpl extends Error implements Runtime.FiberFailure { toString(): string { return "(FiberFailure) " + (this.stack ?? this.message) } + [Inspectable.DenoInspectSymbol](): unknown { + return this.toString() + } [Inspectable.NodeInspectSymbol](): unknown { return this.toString() } diff --git a/packages/effect/src/internal/trie.ts b/packages/effect/src/internal/trie.ts index b6c3033ed67..8e64223f940 100644 --- a/packages/effect/src/internal/trie.ts +++ b/packages/effect/src/internal/trie.ts @@ -1,7 +1,7 @@ import * as Equal from "../Equal.js" import { dual, identity, pipe } from "../Function.js" import * as Hash from "../Hash.js" -import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js" +import { DenoInspectSymbol, format, NodeInspectSymbol, toJSON } from "../Inspectable.js" import * as Option from "../Option.js" import type * as Ordering from "../Ordering.js" import { pipeArguments } from "../Pipeable.js" @@ -60,6 +60,9 @@ const TrieProto: TR.Trie = { values: Array.from(this).map(toJSON) } }, + [DenoInspectSymbol]() { + return this.toJSON() + }, [NodeInspectSymbol]() { return this.toJSON() }, diff --git a/packages/platform/src/internal/httpBody.ts b/packages/platform/src/internal/httpBody.ts index 4f43140a2aa..2530a104002 100644 --- a/packages/platform/src/internal/httpBody.ts +++ b/packages/platform/src/internal/httpBody.ts @@ -33,6 +33,9 @@ abstract class BodyBase implements Body.HttpBody.Proto { this[TypeId] = TypeId } abstract toJSON(): unknown + [Inspectable.DenoInspectSymbol](): unknown { + return this.toJSON() + } [Inspectable.NodeInspectSymbol](): unknown { return this.toJSON() } diff --git a/packages/platform/src/internal/httpMultiplex.ts b/packages/platform/src/internal/httpMultiplex.ts index 3c082766a99..5af3743b38a 100644 --- a/packages/platform/src/internal/httpMultiplex.ts +++ b/packages/platform/src/internal/httpMultiplex.ts @@ -52,6 +52,9 @@ class MultiplexImpl extends Effectable.Class< return this.execute } + [Inspectable.DenoInspectSymbol]() { + return Inspectable.toJSON(this) + } [Inspectable.NodeInspectSymbol]() { return Inspectable.toJSON(this) } diff --git a/packages/platform/src/internal/httpRouter.ts b/packages/platform/src/internal/httpRouter.ts index dd8954bb329..3dc1634380b 100644 --- a/packages/platform/src/internal/httpRouter.ts +++ b/packages/platform/src/internal/httpRouter.ts @@ -200,6 +200,9 @@ class RouterImpl extends Effectable.StructuralClass< toString() { return Inspectable.format(this) } + [Inspectable.DenoInspectSymbol]() { + return this.toJSON() + } [Inspectable.NodeInspectSymbol]() { return this.toJSON() } diff --git a/packages/platform/src/internal/httpServerResponse.ts b/packages/platform/src/internal/httpServerResponse.ts index 6648e665559..17cbb4e8d59 100644 --- a/packages/platform/src/internal/httpServerResponse.ts +++ b/packages/platform/src/internal/httpServerResponse.ts @@ -62,6 +62,9 @@ class ServerResponseImpl extends Effectable.StructuralClass { expect(Cause.pretty(Cause.fail(err), { renderErrorCause: true })).includes("[cause]: Error: child") // ensure node renders the error directly expect(err[Inspectable.NodeInspectSymbol]()).toEqual(err) + // ensure deno renders the error directly + expect(err[Inspectable.DenoInspectSymbol]()).toEqual(err) }) })