diff options
Diffstat (limited to 'src/ffi.js')
-rw-r--r-- | src/ffi.js | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -1,3 +1,5 @@ +import { Ok, Error } from "./gleam.js"; + export function toArray(list) { return list.toArray(); } @@ -17,3 +19,7 @@ export function reduce(thing, acc, fn) { export function reduceRight(thing, acc, fn) { return thing.reduceRight(fn, acc); } + +export function index(thing, index) { + return index in thing ? new Ok(thing[index]) : new Error(undefined); +} |