/**
 * In-memory cache store for evaluated values.
 */
const cache = new WeakMap();
/**
 * Removes cached values from the store.
 * @param target The cache target, element or object extending the mixin
 */
export function clear(target) {
    if (cache.has(target)) {
        cache.delete(target);
    }
}
/**
 * Finds a cached group.
 *
 * @param target The cache target, element or object extending the mixin
 * @param key A key where a function keeps cached objects
 * @param group Group name. Defined by user as an argument.
 * @return Cached value.
 */
export function find(target, key, group) {
    const value = cache.get(target);
    if (!value) {
        return null;
    }
    if (!value[key]) {
        return null;
    }
    return value[key][group];
}
/**
 * Stores value in cache.
 *
 * @param target The cache target, element or object extending the mixin
 * @param key A key where a function keeps cached objects
 * @param group Group name. Defined by user as an argument.
 * @param value Cached value.
 */
export function store(target, key, group, value) {
    let cacheValue = cache.get(target);
    if (!cacheValue) {
        cacheValue = {};
        cache.set(target, cacheValue);
    }
    if (!cacheValue[key]) {
        cacheValue[key] = {};
    }
    cacheValue[key][group] = value;
}
//# sourceMappingURL=Cache.js.map