···1+# `#/storage`
2+3+## Usage
4+5+Import the correctly scoped store from `#/storage`. Each instance of `Storage`
6+(the base class, not to be used directly), has the following interface:
7+8+- `set([...scope, key], value)`
9+- `get([...scope, key])`
10+- `remove([...scope, key])`
11+- `removeMany([...scope], [...keys])`
12+13+For example, using our `device` store looks like this, since it's scoped to the
14+device (the most base level scope):
15+16+```typescript
17+import { device } from '#/storage';
18+19+device.set(['foobar'], true);
20+device.get(['foobar']);
21+device.remove(['foobar']);
22+device.removeMany([], ['foobar']);
23+```
24+25+## TypeScript
26+27+Stores are strongly typed, and when setting a given value, it will need to
28+conform to the schemas defined in `#/storage/schema`. When getting a value, it
29+will be returned to you as the type defined in its schema.
30+31+## Scoped Stores
32+33+Some stores are (or might be) scoped to an account or other identifier. In this
34+case, storage instances are created with type-guards, like this:
35+36+```typescript
37+type AccountSchema = {
38+ language: `${string}-${string}`;
39+};
40+41+type DID = `did:${string}`;
42+43+const account = new Storage<
44+ [DID],
45+ AccountSchema
46+>({
47+ id: 'account',
48+});
49+50+account.set(
51+ ['did:plc:abc', 'language'],
52+ 'en-US',
53+);
54+55+const language = account.get([
56+ 'did:plc:abc',
57+ 'language',
58+]);
59+```
60+61+Here, if `['did:plc:abc']` is not supplied along with the key of
62+`language`, the `get` will return undefined (and TS will yell at you).