diff options
author | Louis Pilfold <louis@lpil.uk> | 2021-08-29 15:28:05 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2021-08-29 15:28:05 +0100 |
commit | d7cf6c9a27487b182c1e6d832a58e01d022b97fa (patch) | |
tree | a97b848a5ac4b98ca844ba9f58492bd71603204b /src/ffi.js | |
parent | efc54b447788d325ec38222d3cb1ec5e98c1c030 (diff) | |
download | javascript-d7cf6c9a27487b182c1e6d832a58e01d022b97fa.tar.gz javascript-d7cf6c9a27487b182c1e6d832a58e01d022b97fa.zip |
Array index
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); +} |