diff options
-rw-r--r-- | src/gleam_stdlib.mjs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs index 2a1a6cf..a7405f2 100644 --- a/src/gleam_stdlib.mjs +++ b/src/gleam_stdlib.mjs @@ -796,6 +796,7 @@ export function inspect(v) { if (v instanceof UtfCodepoint) return inspectUtfCodepoint(v); if (v instanceof BitArray) return inspectBitArray(v); if (v instanceof CustomType) return inspectCustomType(v); + if (v instanceof PMap) return inspectMap(v); if (v instanceof Set) return `//js(Set(${[...v].map(inspect).join(", ")}))`; if (v instanceof RegExp) return `//js(${v})`; if (v instanceof Date) return `//js(Date("${v.toISOString()}"))`; @@ -808,6 +809,17 @@ export function inspect(v) { return inspectObject(v); } +function inspectMap(map) { + let body = "map.from_list(["; + let first = true; + map.forEach((value, key) => { + if (!first) body = body + ", "; + body = body + "#(" + inspect(key) + ", " + inspect(value) + ")"; + first = false; + }); + return body + "])"; +} + function inspectObject(v) { const name = Object.getPrototypeOf(v)?.constructor?.name || "Object"; const props = []; |