Js_dict
Dictionary type (ie an '{ }' JS object). However it is restricted to hold a single type; therefore values must have the same type.
This Dictionary type is mostly used with the Js_json.t
type.
get dict key
returns None
if the key
is not found in the dictionary, Some value
otherwise
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)
let keys: t('a) => array(string);
keys dict
returns all the keys in the dictionary dict
let empty: unit => t('a);
empty ()
returns an empty dictionary
let unsafeDeleteKey: Js.Fn.arity2((t(string) => string => unit));
Experimental internal function
let values: t('a) => array('a);
values dict
returns the values in dict
(ES2017)
fromList entries
creates a new dictionary containing each (key, value)
pair in entries
fromArray entries
creates a new dictionary containing each (key, value)
pair in entries
let map: Js.Fn.arity1(('a => 'b)) => t('a) => t('b);
map f dict
maps dict
to a new dictionary with the same keys, using f
to map each value