export function createLocalStorage({ namespace, }) {
    const storageKeyPrefix = `${namespace}:`;
    const getStorageKey = (key) => `${storageKeyPrefix}${key}`;
    const storage = {
        setItem: (key, value) => localStorage.setItem(getStorageKey(key), value),
        getItem: key => localStorage.getItem(getStorageKey(key)),
        removeItem: key => localStorage.removeItem(getStorageKey(key)),
        get length() {
            let keys = 0;
            for (const key in localStorage) {
                if (key.indexOf(storageKeyPrefix) === 0) {
                    keys += 1;
                }
            }
            return keys;
        },
        clear() {
            for (const key in localStorage) {
                if (key.indexOf(storageKeyPrefix) === 0) {
                    localStorage.removeItem(key);
                }
            }
        },
    };
    return storage;
}
//# sourceMappingURL=custom.js.map