Added Storage type export
This commit is contained in:
parent
24fcb15bf4
commit
2108dff997
1 changed files with 9 additions and 4 deletions
13
src/index.ts
13
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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue