webext-storage 1.3.0 → 1.3.2
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.
|
@@ -12,10 +12,11 @@ Return = Base | undefined> {
|
|
|
12
12
|
readonly defaultValue?: Return;
|
|
13
13
|
constructor(key: string, { area, defaultValue, }?: StorageItemMapOptions<Exclude<Return, undefined>>);
|
|
14
14
|
has: (secondaryKey: string) => Promise<boolean>;
|
|
15
|
-
delete: (secondaryKey: string) => Promise<void>;
|
|
16
15
|
get: (secondaryKey: string) => Promise<Return>;
|
|
17
16
|
set: (secondaryKey: string, value: Exclude<Return, undefined>) => Promise<void>;
|
|
18
17
|
remove: (secondaryKey: string) => Promise<void>;
|
|
18
|
+
/** @deprecated Only here to match the Map API; use `remove` instead */
|
|
19
|
+
delete: (secondaryKey: string) => Promise<void>;
|
|
19
20
|
onChanged(callback: (key: string, value: Exclude<Return, undefined>) => void, signal?: AbortSignal): void;
|
|
20
21
|
private getRawStorageKey;
|
|
21
22
|
private getSecondaryStorageKey;
|
|
@@ -11,11 +11,7 @@ export class StorageItemMap {
|
|
|
11
11
|
has = async (secondaryKey) => {
|
|
12
12
|
const rawStorageKey = this.getRawStorageKey(secondaryKey);
|
|
13
13
|
const result = await chromeP.storage[this.areaName].get(rawStorageKey);
|
|
14
|
-
return Object.hasOwn(result,
|
|
15
|
-
};
|
|
16
|
-
delete = async (secondaryKey) => {
|
|
17
|
-
const rawStorageKey = this.getRawStorageKey(secondaryKey);
|
|
18
|
-
await chromeP.storage[this.areaName].remove(rawStorageKey);
|
|
14
|
+
return Object.hasOwn(result, rawStorageKey);
|
|
19
15
|
};
|
|
20
16
|
get = async (secondaryKey) => {
|
|
21
17
|
const rawStorageKey = this.getRawStorageKey(secondaryKey);
|
|
@@ -34,6 +30,9 @@ export class StorageItemMap {
|
|
|
34
30
|
const rawStorageKey = this.getRawStorageKey(secondaryKey);
|
|
35
31
|
await chromeP.storage[this.areaName].remove(rawStorageKey);
|
|
36
32
|
};
|
|
33
|
+
/** @deprecated Only here to match the Map API; use `remove` instead */
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering -- invalid
|
|
35
|
+
delete = this.remove;
|
|
37
36
|
onChanged(callback, signal) {
|
|
38
37
|
const changeHandler = (changes, area) => {
|
|
39
38
|
if (area !== this.areaName) {
|
|
@@ -15,6 +15,7 @@ Return = Base | undefined> {
|
|
|
15
15
|
constructor(key: string, { area, defaultValue, }?: StorageItemOptions<Exclude<Return, undefined>>);
|
|
16
16
|
get: () => Promise<Return>;
|
|
17
17
|
set: (value: Exclude<Return, undefined>) => Promise<void>;
|
|
18
|
+
has: () => Promise<boolean>;
|
|
18
19
|
remove: () => Promise<void>;
|
|
19
20
|
onChanged(callback: (value: Exclude<Return, undefined>) => void, signal?: AbortSignal): void;
|
|
20
21
|
}
|
|
@@ -21,6 +21,10 @@ export class StorageItem {
|
|
|
21
21
|
set = async (value) => {
|
|
22
22
|
await chromeP.storage[this.area].set({ [this.key]: value });
|
|
23
23
|
};
|
|
24
|
+
has = async () => {
|
|
25
|
+
const result = await chromeP.storage[this.area].get(this.key);
|
|
26
|
+
return Object.hasOwn(result, this.key);
|
|
27
|
+
};
|
|
24
28
|
remove = async () => {
|
|
25
29
|
await chromeP.storage[this.area].remove(this.key);
|
|
26
30
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webext-storage",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "A more usable typed storage API for Web Extensions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"browser",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"xo": "^0.60.0"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
|
-
"node": ">=
|
|
57
|
+
"node": ">=20"
|
|
58
58
|
},
|
|
59
59
|
"tsd": {
|
|
60
60
|
"directory": "source"
|