@cripty2001/utils 0.0.178 → 0.0.179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Appstorage.d.ts +11 -19
- package/dist/Appstorage.js +2 -2
- package/package.json +1 -1
package/dist/Appstorage.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JSONEncodable } from '@cripty2001/utils';
|
|
2
1
|
import { Whispr } from '@cripty2001/whispr';
|
|
2
|
+
import { JSONEncodable } from './index';
|
|
3
3
|
export type AppstorageData = Record<string, JSONEncodable>;
|
|
4
4
|
export type AppstorageItemData<T extends AppstorageData> = {
|
|
5
5
|
key: string;
|
|
@@ -7,31 +7,23 @@ export type AppstorageItemData<T extends AppstorageData> = {
|
|
|
7
7
|
rev: number;
|
|
8
8
|
deleted: boolean;
|
|
9
9
|
};
|
|
10
|
+
export interface IAppstorageItem<T extends AppstorageData> {
|
|
11
|
+
readonly PREFIX: string;
|
|
12
|
+
readonly key: string;
|
|
13
|
+
readonly data: Whispr<AppstorageItemData<T>>;
|
|
14
|
+
readonly update: (data: T) => void;
|
|
15
|
+
readonly remove: () => void;
|
|
16
|
+
}
|
|
10
17
|
export declare class Appstorage {
|
|
11
18
|
private static readonly instances;
|
|
12
19
|
static getInstance(key: string): Appstorage;
|
|
13
20
|
readonly PREFIX: string;
|
|
14
|
-
index: Whispr<Record<string,
|
|
21
|
+
index: Whispr<Record<string, IAppstorageItem<any>>>;
|
|
15
22
|
private _setIndex;
|
|
16
23
|
private readonly refreshInterval;
|
|
17
24
|
private constructor();
|
|
18
|
-
add<T extends AppstorageData>(key: string, data: T):
|
|
19
|
-
get<T extends AppstorageData>(key: string):
|
|
25
|
+
add<T extends AppstorageData>(key: string, data: T): IAppstorageItem<T>;
|
|
26
|
+
get<T extends AppstorageData>(key: string): IAppstorageItem<T>;
|
|
20
27
|
private listData;
|
|
21
28
|
private refresh;
|
|
22
29
|
}
|
|
23
|
-
declare class AppstorageItem<T extends AppstorageData> {
|
|
24
|
-
readonly PREFIX: string;
|
|
25
|
-
private static readonly instances;
|
|
26
|
-
private static readonly refreshInterval;
|
|
27
|
-
readonly key: string;
|
|
28
|
-
readonly data: Whispr<AppstorageItemData<T>>;
|
|
29
|
-
readonly update: (data: T) => void;
|
|
30
|
-
readonly remove: () => void;
|
|
31
|
-
private _setData;
|
|
32
|
-
static get(PREFIX: string, key: string): AppstorageItem<any>;
|
|
33
|
-
private constructor();
|
|
34
|
-
private refresh;
|
|
35
|
-
private loadData;
|
|
36
|
-
}
|
|
37
|
-
export {};
|
package/dist/Appstorage.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Appstorage = void 0;
|
|
4
|
-
const dispatcher_1 = require("@cripty2001/utils/dispatcher");
|
|
5
4
|
const whispr_1 = require("@cripty2001/whispr");
|
|
5
|
+
const Dispatcher_1 = require("./Dispatcher");
|
|
6
6
|
class Appstorage {
|
|
7
7
|
static instances = new Map();
|
|
8
8
|
static getInstance(key) {
|
|
@@ -103,7 +103,7 @@ class AppstorageItem {
|
|
|
103
103
|
data: {}
|
|
104
104
|
});
|
|
105
105
|
};
|
|
106
|
-
new
|
|
106
|
+
new Dispatcher_1.Dispatcher(this.data, async () => {
|
|
107
107
|
const curr = this.loadData();
|
|
108
108
|
if (this.data.value.rev > curr.rev) {
|
|
109
109
|
localStorage.setItem(`${this.PREFIX}${this.key}`, JSON.stringify(this.data.value));
|
package/package.json
CHANGED