Added Storage type export

This commit is contained in:
Michaël Lemaire 2019-11-14 18:21:44 +01:00
parent 24fcb15bf4
commit 2108dff997

View file

@ -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();
}