1/**
2 * Deno-backed `KeyValueStore` layers using Web Storage APIs.
3 *
4 * @since 4.0.0
5 */
6
7import type * as Layer from "effect/Layer"
8import * as KeyValueStore from "effect/persistence/KeyValueStore"
9
10/**
11 * Creates a `KeyValueStore` layer backed by `localStorage`, with values stored between sessions.
12 *
13 * @category layers
14 * @since 4.0.0
15 */
16export const layerLocalStorage: Layer.Layer<KeyValueStore.KeyValueStore> = KeyValueStore.layerStorage(() =>
17 localStorage
18)
19
20/**
21 * Creates a `KeyValueStore` layer backed by `sessionStorage`, with values stored only for the current session.
22 *
23 * @category layers
24 * @since 4.0.0
25 */
26export const layerSessionStorage: Layer.Layer<KeyValueStore.KeyValueStore> = KeyValueStore.layerStorage(() =>
27 sessionStorage
28)