aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gleam_stdlib_decode_ffi.mjs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gleam_stdlib_decode_ffi.mjs b/src/gleam_stdlib_decode_ffi.mjs
index 86c9c60..58291b5 100644
--- a/src/gleam_stdlib_decode_ffi.mjs
+++ b/src/gleam_stdlib_decode_ffi.mjs
@@ -64,5 +64,18 @@ export function dict(data) {
if (data instanceof Dict) {
return new Ok(data);
}
- return new Error();
+ if (data instanceof Map || data instanceof WeakMap) {
+ return new Ok(Dict.fromMap(data));
+ }
+ if (data == null) {
+ return new Error("Dict");
+ }
+ if (typeof data !== "object") {
+ return new Error("Dict");
+ }
+ const proto = Object.getPrototypeOf(data);
+ if (proto === Object.prototype || proto === null) {
+ return new Ok(Dict.fromObject(data));
+ }
+ return new Error("Dict");
}