Current section
Files
Jump to
Current section
Files
src/gleam@javascript@array.erl
-module(gleam@javascript@array).
-compile(no_auto_import).
-export([to_list/1, from_list/1, length/1, map/2, fold/3, fold_right/3, get/2]).
-export_type([array/1]).
-type array(Element) :: any() | {gleam_phantom, Element}.
-spec to_list(array(I)) -> list(I).
to_list(A) ->
'../../gleam.mjs':'toList'(A).
-spec from_list(list(L)) -> array(L).
from_list(A) ->
'../../ffi.mjs':'toArray'(A).
-spec length(array(any())) -> integer().
length(A) ->
'../../ffi.mjs':length(A).
-spec map(array(S), fun((S) -> Q)) -> array(Q).
map(A, B) ->
'../../ffi.mjs':map(A, B).
-spec fold(array(V), U, fun((U, V) -> U)) -> U.
fold(A, B, C) ->
'../../ffi.mjs':reduce(A, B, C).
-spec fold_right(array(Y), X, fun((X, Y) -> X)) -> X.
fold_right(A, B, C) ->
'../../ffi.mjs':'reduceRight'(A, B, C).
-spec get(array(AA), integer()) -> {ok, AA} | {error, nil}.
get(A, B) ->
'../../ffi.mjs':index(A, B).