@esportsplus/web-storage 0.1.2 → 0.1.3

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.
@@ -38,6 +38,9 @@ class Store {
38
38
  return this.instance.clear();
39
39
  }
40
40
  delete(...keys) {
41
+ if (!keys.length) {
42
+ return;
43
+ }
41
44
  this.promises.push(async () => {
42
45
  for (let i = 0, n = keys.length; i < n; i++) {
43
46
  await this.instance.removeItem(keys[i]);
@@ -102,6 +105,9 @@ class Store {
102
105
  return value;
103
106
  }
104
107
  push(key, ...values) {
108
+ if (!values.length) {
109
+ return;
110
+ }
105
111
  this.promises.push(async () => {
106
112
  let data = (await this.get(key)) || [];
107
113
  data.push(...values);
@@ -109,6 +115,9 @@ class Store {
109
115
  });
110
116
  }
111
117
  replace(values) {
118
+ if (!Object.keys(values).length) {
119
+ return;
120
+ }
112
121
  this.promises.push(async () => {
113
122
  for (let key in values) {
114
123
  await this.instance.setItem(key, values[key]);
@@ -128,6 +137,9 @@ class Store {
128
137
  await Promise.allSettled(this.promises.splice(0));
129
138
  }
130
139
  unshift(key, ...values) {
140
+ if (!values.length) {
141
+ return;
142
+ }
131
143
  this.promises.push(async () => {
132
144
  let data = (await this.get(key)) || [];
133
145
  data.unshift(...values);
package/package.json CHANGED
@@ -23,5 +23,5 @@
23
23
  "prepublishOnly": "npm run build"
24
24
  },
25
25
  "types": "./build/index.d.ts",
26
- "version": "0.1.2"
26
+ "version": "0.1.3"
27
27
  }
@@ -49,6 +49,10 @@ class Store {
49
49
  }
50
50
 
51
51
  delete(...keys: string[]): void {
52
+ if (!keys.length) {
53
+ return;
54
+ }
55
+
52
56
  this.promises.push(async () => {
53
57
  for (let i = 0, n = keys.length; i < n; i++) {
54
58
  await this.instance.removeItem(keys[i]);
@@ -138,6 +142,10 @@ class Store {
138
142
  }
139
143
 
140
144
  push(key: string, ...values: any[]): void {
145
+ if (!values.length) {
146
+ return;
147
+ }
148
+
141
149
  this.promises.push(async () => {
142
150
  let data = (await this.get(key)) || [];
143
151
 
@@ -148,6 +156,10 @@ class Store {
148
156
  }
149
157
 
150
158
  replace(values: { [key: string]: any }): void {
159
+ if (!Object.keys(values).length) {
160
+ return;
161
+ }
162
+
151
163
  this.promises.push(async () => {
152
164
  for (let key in values) {
153
165
  await this.instance.setItem(key, values[key])
@@ -175,6 +187,10 @@ class Store {
175
187
  }
176
188
 
177
189
  unshift(key: string, ...values: any[]): void {
190
+ if (!values.length) {
191
+ return;
192
+ }
193
+
178
194
  this.promises.push(async () => {
179
195
  let data = (await this.get(key)) || [];
180
196