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