simple-storage
Advanced tools
Comparing version 3.2.0 to 4.0.0
export declare type SimpleStorageType = "session" | "local"; | ||
export interface SimpleStorageItem { | ||
key: string; | ||
value: any; | ||
} | ||
export interface StringDictionary { | ||
@@ -14,3 +18,3 @@ [key: string]: string; | ||
readonly length: number; | ||
getAllItems(): any[]; | ||
getAllItems(): SimpleStorageItem[]; | ||
getAllItemsAsync(): Promise<any[]>; | ||
@@ -17,0 +21,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
; | ||
; | ||
/** Fallback storage provider for environments where the Storage API isn't available */ | ||
@@ -88,4 +89,4 @@ var AltStorage = /** @class */ (function () { | ||
if (key !== null) { | ||
item[key] = this.getItem(key); | ||
items.push(item); | ||
var value = this.getItem(key); | ||
items.push({ key: key, value: value }); | ||
} | ||
@@ -92,0 +93,0 @@ } |
{ | ||
"name": "simple-storage", | ||
"version": "3.2.0", | ||
"version": "4.0.0", | ||
"description": "Simple localStorage / sessionStorage supporting objects and arrays", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/tuxracer/simple-storage", |
@@ -23,7 +23,7 @@ # simple-storage | ||
const items = simpleSessionStorage.getAllItems(); | ||
console.log(items); // [{ pets: {dogs: 3, cats: 1} }] | ||
console.log(items); // [{ key: "pets", value: {dogs: 3, cats: 1} }] | ||
// get all items async | ||
const i = await simpleSessionStorage.getAllItemsAsync(); | ||
console.log(i); // [{ pets: {dogs: 3, cats: 1} }] | ||
console.log(i); // [{ key: "pets", value: {dogs: 3, cats: 1} }] | ||
@@ -55,7 +55,7 @@ // remove item | ||
const items = simpleLocalStorage.getAllItems(); | ||
console.log(items); // [{ pets: {dogs: 3, cats: 1} }] | ||
console.log(items); // [{ key: "pets", value: {dogs: 3, cats: 1} }] | ||
// get all items async | ||
const i = await simpleLocalStorage.getAllItemsAsync(); | ||
console.log(i); // [{ pets: {dogs: 3, cats: 1} }] | ||
console.log(i); // [{ key: "pets", value: {dogs: 3, cats: 1} }] | ||
@@ -62,0 +62,0 @@ // remove item |
export type SimpleStorageType = "session" | "local"; | ||
export interface SimpleStorageItem { | ||
key: string; | ||
value: any; | ||
}; | ||
export interface StringDictionary { | ||
@@ -95,3 +100,3 @@ [key: string]: string; | ||
getAllItems() { | ||
const items: any[] = []; | ||
const items: SimpleStorageItem[] = []; | ||
@@ -103,4 +108,4 @@ for(let i = this.length - 1; i >= 0; i--) { | ||
if (key !== null) { | ||
item[key] = this.getItem(key); | ||
items.push(item); | ||
const value = this.getItem(key); | ||
items.push({ key, value }); | ||
} | ||
@@ -107,0 +112,0 @@ } |
10752
235