Skip to content

Commit

Permalink
feat(@kvs/memorystorage): migrate to Schema type
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Aug 8, 2020
1 parent ec143e2 commit 84d75f4
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/memorystorage/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { JsonValue, KvsStorage, kvsStorage, KVSStorageKey } from "@kvs/storage";
import { JsonValue, KvsStorage, kvsStorage } from "@kvs/storage";
import { KVS, KVSOptions } from "@kvs/types";
// @ts-ignore
import localstorage from "localstorage-memory";

export type KvsLocalStorage<K extends KVSStorageKey, V extends JsonValue> = KVS<K, V>;
export type KvsLocalStorageOptions<K extends KVSStorageKey, V extends JsonValue> = KVSOptions<K, V> & {
export type KvsMemoryStorageSchema = {
[index: string]: JsonValue;
};
export type KvsMemoryStorage<Schema extends KvsMemoryStorageSchema> = KVS<Schema>;
export type KvsMemoryStorageOptions<Schema extends KvsMemoryStorageSchema> = KVSOptions<Schema> & {
kvsVersionKey?: string;
};
export const kvsMemoryStorage = async <K extends KVSStorageKey, V extends JsonValue>(
options: KvsLocalStorageOptions<K, V>
): Promise<KvsStorage<K, V>> => {
export const kvsMemoryStorage = async <Schema extends KvsMemoryStorageSchema>(
options: KvsMemoryStorageOptions<Schema>
): Promise<KvsStorage<Schema>> => {
return kvsStorage({
...options,
storage: localstorage
Expand Down

0 comments on commit 84d75f4

Please sign in to comment.