Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@azu
Copy link
Owner

@azu azu commented Aug 8, 2020

Useful interface.

  • Add limitation to IndexedDB : key is string, value is JsonValue
import assert from "assert";
import { kvsStorage } from "@kvs/storage";
(async () => {
    type StorageSchema = {
        a1: string;
        b2: number;
        c3: boolean;
    };
    const storage = await kvsStorage<StorageSchema>({
        name: "test",
        version: 1,
        storage: localStorage
    });
    await storage.set("a1", "string");
    await storage.set("b2", 42);
    await storage.set("c3", false);
    const a1 = await storage.get("a1");
    const b2 = await storage.get("b2");
    const c3 = await storage.get("c3");
    assert.strictEqual(a1, "string");
    assert.strictEqual(b2, 42);
    assert.strictEqual(c3, false);
})();

fix #1

@azu azu merged commit 28460dc into master Aug 8, 2020
@azu azu deleted the schema branch August 8, 2020 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript: Schema instead of <K,V>

1 participant