diff options
Diffstat (limited to 'src/gleam_stdlib.js')
-rw-r--r-- | src/gleam_stdlib.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gleam_stdlib.js b/src/gleam_stdlib.js index 37f071a..b7173c2 100644 --- a/src/gleam_stdlib.js +++ b/src/gleam_stdlib.js @@ -473,6 +473,8 @@ export function decode64(sBase64) { export function classify_dynamic(data) { if (typeof data === "string") { return "String"; + } else if (Result.isResult(data)) { + return "Result"; } else if (List.isList(data)) { return "List"; } else if (Number.isInteger(data)) { @@ -552,3 +554,9 @@ export function decode_option(data, decoder) { return result; } } + +export function decode_field(value, name) { + return name in value + ? new Ok(value[name]) + : decoder_error(`Value with field ${inspect(name)}`, value); +} |