The Runes module provides enhanced Map and Array implementations that return Option types instead of undefined or -1 for operations that might not find a value.
Creates a RunicMap instance with Option-returning methods.
Copy import { $map } from ' funkcia/runes ' ;
const map = $map ([
[ ' key1 ' , ' value1 ' ] ,
[ ' key2 ' , ' value2 ' ] ,
]) ;
// Returns Option<string> instead of string | undefined
const value = map . get ( ' key1 ' ) ;
// Some('value1')
const missing = map . get ( ' key3 ' ) ;
// None Creates a RunicArray instance with Option-returning methods.
An Array subclass with Option-returning methods for safer array operations.
Returns Some with the item at the specified index if it exists, otherwise None.
Returns Some with the first element matching the predicate, otherwise None.
Returns Some with the index of the first element matching the predicate, otherwise None.
Returns Some with the index of the first occurrence of a value, otherwise None.
Returns Some with the index of the last occurrence of a value, otherwise None.
Removes and returns Some with the last element if it exists, otherwise None.
Removes and returns Some with the first element if it exists, otherwise None.
Last updated 3 minutes ago