rxdb
Version:
A local-first realtime NoSQL Database for JavaScript applications - https://rxdb.info/
18 lines • 479 B
JavaScript
export function getFromMapOrThrow(map, key) {
var val = map.get(key);
if (typeof val === 'undefined') {
throw new Error('missing value from map ' + key);
}
return val;
}
export function getFromMapOrCreate(map, index, creator, ifWasThere) {
var value = map.get(index);
if (typeof value === 'undefined') {
value = creator();
map.set(index, value);
} else if (ifWasThere) {
ifWasThere(value);
}
return value;
}
//# sourceMappingURL=utils-map.js.map