Given an map, tries to get the given key in that map. If the key is not in that map, then the
given createCallback is used to create a new value which is then stored in the given map and
returned. Automatically handles an async createCallback.
Example
// instead of doing this if (!myMap.get(myKey)) { myMap.set(myKey, {}); } myMap.get(myKey)![nextKey] = 'some value';
// do this getOrSetInObject(myMap, myKey, () => { return {}; });
Given an map, tries to get the given key in that map. If the key is not in that map, then the given
createCallback
is used to create a new value which is then stored in the given map and returned. Automatically handles an asynccreateCallback
.Example
Package
@augment-vir/common