From 2108dff9976b61166f1b91858a93a268a645c787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Thu, 14 Nov 2019 18:21:44 +0100 Subject: [PATCH] Added Storage type export --- src/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index f39440b..268aea8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,9 +3,14 @@ import { BrowserLocalStorage } from "./browser"; import { NodeDirectoryStorage } from "./node"; /** - * Récupère le meilleur stockage "local" disponible + * Base type for storage usage */ -export function getLocalStorage(appname: string): KeyValueStorage { +export type Storage = KeyValueStorage + +/** + * Get the best "local" storage available + */ +export function getLocalStorage(appname: string): Storage { try { return new ScopedStorage(new BrowserLocalStorage(), appname); } catch { @@ -19,8 +24,8 @@ export function getLocalStorage(appname: string): KeyValueStorage { } /** - * Récupère un stockage "mémoire" + * Get a in-memory volatile storage */ -export function getMemoryStorage(): KeyValueStorage { +export function getMemoryStorage(): Storage { return new MemoryStorage(); }