module Dict: Js_dict
type 'a
t
This Dictionary type is mostly use with the Js_json.t
type.
typekey =
string
val get : 'a t -> key -> 'a option
get dict key
returns None
if the key
is not found in the
dictionary, Some value
otherwiseval unsafeGet : 'a t -> key -> 'a
unsafeGet dict key
return the value if the key
exists,
otherwise an undefined value is returned. Must be used only
when the existence of a key is certain. (i.e. when having called keys
function previously.Array.iter (fun key -> Js.log (Js_dict.unsafeGet dic key)) (Js_dict.keys dict)
val set : 'a t -> key -> 'a -> unit
set dict key value
sets the key
/value
in dict
val keys : 'a t -> string array
keys dict
returns all the keys in the dictionary dict
val empty : unit -> 'a t
empty ()
returns en empty dictionaryval unsafeDeleteKey : ([ `Arity_2 of string t * string ], unit) Js.Internal.fn
val entries : 'a t -> (key * 'a) array
entries dict
returns the key value pairs in dict
(ES2017)val values : 'a t -> 'a array
entries dict
returns the values in dict
(ES2017)val fromList : (key * 'a) list -> 'a t
fromList entries
creates a new dictionary using with containing each
(key, value)
pair in entries
val fromArray : (key * 'a) array -> 'a t
fromArray entries
creates a new dictionary using with containing each
(key, value)
pair in entries
val map : ([ `Arity_1 of 'a ], 'b) Js.Internal.fn -> 'a t -> 'b t
map f dict
maps dict
to a new dictionary with the same keys,
using f
to map each value