This library contains two objects
Map k v from
BigInt) as keys. The former can be used with every key that is an instance of the class
Both objects have efficient lookups but inefficient insertion performance ( O(n) time complexity ).
However, both objects have a mutable version
STMap that can be used via the
ST monad. In this case, insertions (via
poke) are also efficient.
Documentation is published on Pursuit
spago install js-maps
import Control.Monad.ST (for) import JS.Map.Primitive (Map) import JS.Map.Primitive.ST as STM sample :: Map Int String sample = STM.run do m <- STM.new for 1 10000 \i -> do STM.poke_ i (show i) m pure m
Js.Map.Primitive is faster than other alternatives on lookup and insertion (via
poke) using Int (30000 lookups and 30000 insertions).
|JS.Map.Primitive||1.38 ms||2.11 ms|
|JS.Map||2.76 ms||3.08 ms|
|Data.ObjectMap||10.57 ms||17.11 ms|
|Data.Map||8.84 ms||27.92 ms|
|Data.HashMap||3.16 ms||8.04 ms|