/**
 * If key exists returns the existing value. Otherwise factory is called and the resulting value is added
 * to the key.
 * @param key Key to check for value
 * @param factory Factory which creates value if key does not exist in map.
 * @returns value for key
 */
Map.prototype.getOrAdd = function (key, factory) {
    let val = this.get(key);
    if (val === undefined) {
        val = factory(key);
        this.set(key, val);
    }
    return val;
};
export {};
//# sourceMappingURL=MapExtensions.js.map