@choksheak/ts-utils 0.3.3 → 0.3.5

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.
Files changed (131) hide show
  1. package/README.md +9 -3
  2. package/asNumber.cjs +6 -6
  3. package/asNumber.d.mts +1 -1
  4. package/asNumber.d.ts +1 -1
  5. package/asNumber.min.cjs +1 -1
  6. package/asNumber.min.cjs.map +1 -1
  7. package/asNumber.min.mjs +1 -1
  8. package/asNumber.min.mjs.map +1 -1
  9. package/asNumber.mjs +6 -6
  10. package/capLength.cjs +80 -0
  11. package/capLength.d.mts +3 -0
  12. package/capLength.d.ts +3 -0
  13. package/capLength.min.cjs +6 -0
  14. package/capLength.min.cjs.map +1 -0
  15. package/capLength.min.mjs +6 -0
  16. package/capLength.min.mjs.map +1 -0
  17. package/capLength.mjs +53 -0
  18. package/{iterators.cjs → concatIterators.cjs} +4 -4
  19. package/{iterators.min.cjs → concatIterators.min.cjs} +1 -1
  20. package/concatIterators.min.cjs.map +1 -0
  21. package/{iterators.min.mjs → concatIterators.min.mjs} +1 -1
  22. package/concatIterators.min.mjs.map +1 -0
  23. package/{iterators.mjs → concatIterators.mjs} +1 -1
  24. package/duration.min.cjs +1 -1
  25. package/duration.min.mjs +1 -1
  26. package/kvStore.cjs +230 -239
  27. package/kvStore.d.mts +142 -44
  28. package/kvStore.d.ts +142 -44
  29. package/kvStore.min.cjs +1 -1
  30. package/kvStore.min.cjs.map +1 -1
  31. package/kvStore.min.mjs +1 -1
  32. package/kvStore.min.mjs.map +1 -1
  33. package/kvStore.mjs +229 -237
  34. package/localStore.cjs +187 -186
  35. package/localStore.d.mts +135 -34
  36. package/localStore.d.ts +135 -34
  37. package/localStore.min.cjs +1 -1
  38. package/localStore.min.cjs.map +1 -1
  39. package/localStore.min.mjs +1 -1
  40. package/localStore.min.mjs.map +1 -1
  41. package/localStore.mjs +186 -184
  42. package/mean.cjs +6 -6
  43. package/mean.min.cjs +1 -1
  44. package/mean.min.cjs.map +1 -1
  45. package/mean.min.mjs +1 -1
  46. package/mean.min.mjs.map +1 -1
  47. package/mean.mjs +6 -6
  48. package/median.cjs +7 -7
  49. package/median.min.cjs +1 -1
  50. package/median.min.cjs.map +1 -1
  51. package/median.min.mjs +1 -1
  52. package/median.min.mjs.map +1 -1
  53. package/median.mjs +7 -7
  54. package/package.json +67 -82
  55. package/round.cjs +2 -10
  56. package/round.d.mts +2 -8
  57. package/round.d.ts +2 -8
  58. package/round.min.cjs +1 -1
  59. package/round.min.cjs.map +1 -1
  60. package/round.min.mjs +1 -1
  61. package/round.min.mjs.map +1 -1
  62. package/round.mjs +1 -8
  63. package/{safeParseInt.cjs → roundToString.cjs} +19 -9
  64. package/roundToString.d.mts +8 -0
  65. package/roundToString.d.ts +8 -0
  66. package/roundToString.min.cjs +2 -0
  67. package/roundToString.min.cjs.map +1 -0
  68. package/roundToString.min.mjs +2 -0
  69. package/roundToString.min.mjs.map +1 -0
  70. package/roundToString.mjs +16 -0
  71. package/safeBtoa.d.mts +7 -0
  72. package/safeBtoa.d.ts +7 -0
  73. package/safeBtoa.min.cjs.map +1 -1
  74. package/safeBtoa.min.mjs.map +1 -1
  75. package/sum.cjs +6 -6
  76. package/sum.min.cjs +1 -1
  77. package/sum.min.cjs.map +1 -1
  78. package/sum.min.mjs +1 -1
  79. package/sum.min.mjs.map +1 -1
  80. package/sum.mjs +6 -6
  81. package/timer.cjs +19 -24
  82. package/timer.d.mts +9 -6
  83. package/timer.d.ts +9 -6
  84. package/timer.min.cjs +1 -1
  85. package/timer.min.cjs.map +1 -1
  86. package/timer.min.mjs +1 -1
  87. package/timer.min.mjs.map +1 -1
  88. package/timer.mjs +19 -23
  89. package/toReadableString.cjs +69 -0
  90. package/toReadableString.d.mts +10 -0
  91. package/toReadableString.d.ts +10 -0
  92. package/toReadableString.min.cjs +6 -0
  93. package/toReadableString.min.cjs.map +1 -0
  94. package/toReadableString.min.mjs +6 -0
  95. package/toReadableString.min.mjs.map +1 -0
  96. package/toReadableString.mjs +44 -0
  97. package/average.cjs +0 -55
  98. package/average.d.mts +0 -7
  99. package/average.d.ts +0 -7
  100. package/average.min.cjs +0 -2
  101. package/average.min.cjs.map +0 -1
  102. package/average.min.mjs +0 -2
  103. package/average.min.mjs.map +0 -1
  104. package/average.mjs +0 -28
  105. package/iterators.min.cjs.map +0 -1
  106. package/iterators.min.mjs.map +0 -1
  107. package/logging.cjs +0 -47
  108. package/logging.d.mts +0 -4
  109. package/logging.d.ts +0 -4
  110. package/logging.min.cjs +0 -2
  111. package/logging.min.cjs.map +0 -1
  112. package/logging.min.mjs +0 -2
  113. package/logging.min.mjs.map +0 -1
  114. package/logging.mjs +0 -21
  115. package/safeParseFloat.cjs +0 -33
  116. package/safeParseFloat.d.mts +0 -6
  117. package/safeParseFloat.d.ts +0 -6
  118. package/safeParseFloat.min.cjs +0 -2
  119. package/safeParseFloat.min.cjs.map +0 -1
  120. package/safeParseFloat.min.mjs +0 -2
  121. package/safeParseFloat.min.mjs.map +0 -1
  122. package/safeParseFloat.mjs +0 -8
  123. package/safeParseInt.d.mts +0 -6
  124. package/safeParseInt.d.ts +0 -6
  125. package/safeParseInt.min.cjs +0 -2
  126. package/safeParseInt.min.cjs.map +0 -1
  127. package/safeParseInt.min.mjs +0 -2
  128. package/safeParseInt.min.mjs.map +0 -1
  129. package/safeParseInt.mjs +0 -8
  130. /package/{iterators.d.mts → concatIterators.d.mts} +0 -0
  131. /package/{iterators.d.ts → concatIterators.d.ts} +0 -0
package/kvStore.mjs CHANGED
@@ -54,33 +54,20 @@ function withOnError(request, reject) {
54
54
  };
55
55
  return request;
56
56
  }
57
- var KvStore = class {
58
- constructor(dbName, options) {
59
- this.dbName = dbName;
60
- this.dbVersion = options?.dbVersion ?? KvStoreConfig.dbVersion;
61
- this.storeName = options?.storeName ?? KvStoreConfig.storeName;
62
- this.defaultExpiryMs = options?.defaultExpiryMs ? durationOrMsToMs(options.defaultExpiryMs) : KvStoreConfig.expiryMs;
63
- this.gcIntervalMs = options?.gcIntervalMs ? durationOrMsToMs(options.gcIntervalMs) : KvStoreConfig.gcIntervalMs;
64
- this.gcMsStorageKey = `__kvStore:lastGcMs:${dbName}:v${this.dbVersion}:${this.storeName}`;
65
- }
66
- /** We'll init the DB only on first use. */
67
- db;
68
- /** Local storage key name for the last GC completed timestamp. */
69
- gcMsStorageKey;
70
- dbVersion;
71
- storeName;
72
- defaultExpiryMs;
73
- gcIntervalMs;
74
- async getOrCreateDb() {
75
- if (!this.db) {
76
- this.db = await new Promise((resolve, reject) => {
77
- const request = withOnError(
78
- globalThis.indexedDB.open(this.dbName, this.dbVersion),
79
- reject
80
- );
57
+ function createKvStore(dbName, options) {
58
+ let db;
59
+ const dbVersion = options?.dbVersion ?? KvStoreConfig.dbVersion;
60
+ const storeName = options?.storeName ?? KvStoreConfig.storeName;
61
+ const defaultExpiryMs = options?.defaultExpiryMs ? durationOrMsToMs(options.defaultExpiryMs) : KvStoreConfig.expiryMs;
62
+ const gcIntervalMs = options?.gcIntervalMs ? durationOrMsToMs(options.gcIntervalMs) : KvStoreConfig.gcIntervalMs;
63
+ const gcMsStorageKey = `__kvStore:lastGcMs:${dbName}:v${dbVersion}:${storeName}`;
64
+ async function getOrCreateDb() {
65
+ if (!db) {
66
+ db = await new Promise((resolve, reject) => {
67
+ const request = withOnError(indexedDB.open(dbName, dbVersion), reject);
81
68
  request.onupgradeneeded = (event) => {
82
- const db = event.target.result;
83
- const objectStore = db.createObjectStore(this.storeName, {
69
+ const db2 = event.target.result;
70
+ const objectStore = db2.createObjectStore(storeName, {
84
71
  keyPath: "key"
85
72
  });
86
73
  objectStore.createIndex("key", "key", {
@@ -88,247 +75,252 @@ var KvStore = class {
88
75
  });
89
76
  };
90
77
  request.onsuccess = (event) => {
91
- const db = event.target.result;
92
- resolve(db);
78
+ const db2 = event.target.result;
79
+ resolve(db2);
93
80
  };
94
81
  });
95
82
  }
96
- return this.db;
83
+ return db;
97
84
  }
98
- async transact(mode, callback) {
99
- const db = await this.getOrCreateDb();
85
+ async function transact(mode, callback) {
86
+ const db2 = await getOrCreateDb();
100
87
  return await new Promise((resolve, reject) => {
101
- const transaction = withOnError(
102
- db.transaction(this.storeName, mode),
103
- reject
104
- );
88
+ const transaction = withOnError(db2.transaction(storeName, mode), reject);
105
89
  transaction.onabort = (event) => {
106
90
  reject(event);
107
91
  };
108
- const objectStore = transaction.objectStore(this.storeName);
92
+ const objectStore = transaction.objectStore(storeName);
109
93
  callback(objectStore, resolve, reject);
110
94
  });
111
95
  }
112
- /** Set a value in the store. */
113
- async set(key, value, expiryDeltaMs = this.defaultExpiryMs) {
114
- const nowMs = Date.now();
115
- const obj = {
116
- key,
117
- value,
118
- storedMs: nowMs,
119
- expiryMs: nowMs + durationOrMsToMs(expiryDeltaMs)
120
- };
121
- return await this.transact(
122
- "readwrite",
123
- (objectStore, resolve, reject) => {
124
- const request = withOnError(objectStore.put(obj), reject);
96
+ const obj = {
97
+ /** Input name for the DB. */
98
+ dbName,
99
+ /** Input version for the DB. */
100
+ dbVersion,
101
+ /** Input name for the DB store. */
102
+ storeName,
103
+ /** Default expiry to use if not specified in set(). */
104
+ defaultExpiryMs,
105
+ /** Time interval for when GC's occur. */
106
+ gcIntervalMs,
107
+ /** Local storage key name for the last GC completed timestamp. */
108
+ gcMsStorageKey,
109
+ /** Set a value in the store. */
110
+ async set(key, value, expiryDeltaMs) {
111
+ const nowMs = Date.now();
112
+ const stored = {
113
+ key,
114
+ value,
115
+ storedMs: nowMs,
116
+ expiryMs: nowMs + durationOrMsToMs(expiryDeltaMs ?? defaultExpiryMs)
117
+ };
118
+ return await transact("readwrite", (objectStore, resolve, reject) => {
119
+ const request = withOnError(objectStore.put(stored), reject);
125
120
  request.onsuccess = () => {
126
121
  resolve(value);
127
- this.gc();
128
- };
129
- }
130
- );
131
- }
132
- /** Delete one or multiple keys. */
133
- async delete(key) {
134
- return await this.transact(
135
- "readwrite",
136
- (objectStore, resolve, reject) => {
137
- objectStore.transaction.oncomplete = () => {
138
- resolve();
122
+ obj.gc();
139
123
  };
140
- if (typeof key === "string") {
141
- withOnError(objectStore.delete(key), reject);
142
- } else {
143
- for (const k of key) {
144
- withOnError(objectStore.delete(k), reject);
124
+ });
125
+ },
126
+ /** Delete one or multiple keys. */
127
+ async delete(key) {
128
+ return await transact(
129
+ "readwrite",
130
+ (objectStore, resolve, reject) => {
131
+ objectStore.transaction.oncomplete = () => {
132
+ resolve();
133
+ };
134
+ if (typeof key === "string") {
135
+ withOnError(objectStore.delete(key), reject);
136
+ } else {
137
+ for (const k of key) {
138
+ withOnError(objectStore.delete(k), reject);
139
+ }
145
140
  }
146
141
  }
142
+ );
143
+ },
144
+ /** Mainly used to get the expiration timestamp of an object. */
145
+ async getStoredObject(key) {
146
+ const stored = await transact(
147
+ "readonly",
148
+ (objectStore, resolve, reject) => {
149
+ const request = withOnError(objectStore.get(key), reject);
150
+ request.onsuccess = () => {
151
+ resolve(request.result);
152
+ };
153
+ }
154
+ );
155
+ if (!stored) {
156
+ return void 0;
147
157
  }
148
- );
149
- }
150
- /** Mainly used to get the expiration timestamp of an object. */
151
- async getStoredObject(key) {
152
- const stored = await this.transact(
153
- "readonly",
154
- (objectStore, resolve, reject) => {
155
- const request = withOnError(objectStore.get(key), reject);
156
- request.onsuccess = () => {
157
- resolve(request.result);
158
- };
159
- }
160
- );
161
- if (!stored) {
162
- return void 0;
163
- }
164
- try {
165
- const obj = validateStoredObject(stored);
166
- if (!obj) {
167
- await this.delete(key);
168
- this.gc();
158
+ try {
159
+ const valid = validateStoredObject(stored);
160
+ if (!valid) {
161
+ await obj.delete(key);
162
+ obj.gc();
163
+ return void 0;
164
+ }
165
+ return valid;
166
+ } catch (e) {
167
+ console.error(`Invalid kv value: ${key}=${JSON.stringify(stored)}:`, e);
168
+ await obj.delete(key);
169
+ obj.gc();
169
170
  return void 0;
170
171
  }
171
- return obj;
172
- } catch (e) {
173
- console.error(`Invalid kv value: ${key}=${JSON.stringify(stored)}:`, e);
174
- await this.delete(key);
175
- this.gc();
176
- return void 0;
177
- }
178
- }
179
- /** Get a value by key, or undefined if it does not exist. */
180
- async get(key) {
181
- const obj = await this.getStoredObject(key);
182
- return obj?.value;
183
- }
184
- /** Generic way to iterate through all entries. */
185
- async forEach(callback) {
186
- await this.transact("readonly", (objectStore, resolve, reject) => {
187
- const request = withOnError(objectStore.openCursor(), reject);
188
- request.onsuccess = async (event) => {
189
- const cursor = event.target.result;
190
- if (cursor) {
191
- if (cursor.key) {
192
- const obj = validateStoredObject(cursor.value);
193
- if (obj !== void 0) {
194
- await callback(
195
- String(cursor.key),
196
- obj.value,
197
- obj.expiryMs,
198
- obj.storedMs
199
- );
172
+ },
173
+ /** Get a value by key, or undefined if it does not exist. */
174
+ async get(key) {
175
+ const stored = await obj.getStoredObject(key);
176
+ return stored?.value;
177
+ },
178
+ /** Generic way to iterate through all entries. */
179
+ async forEach(callback) {
180
+ await transact("readonly", (objectStore, resolve, reject) => {
181
+ const request = withOnError(objectStore.openCursor(), reject);
182
+ request.onsuccess = async (event) => {
183
+ const cursor = event.target.result;
184
+ if (cursor) {
185
+ if (cursor.key) {
186
+ const valid = validateStoredObject(cursor.value);
187
+ if (valid !== void 0) {
188
+ await callback(
189
+ String(cursor.key),
190
+ valid.value,
191
+ valid.expiryMs,
192
+ valid.storedMs
193
+ );
194
+ }
200
195
  }
196
+ cursor.continue();
197
+ } else {
198
+ resolve();
201
199
  }
202
- cursor.continue();
203
- } else {
200
+ };
201
+ });
202
+ },
203
+ /**
204
+ * Returns the number of items in the store. Note that getting the size
205
+ * requires iterating through the entire store because the items could expire
206
+ * at any time, and hence the size is a dynamic number.
207
+ */
208
+ async size() {
209
+ let count = 0;
210
+ await obj.forEach(() => {
211
+ count++;
212
+ });
213
+ return count;
214
+ },
215
+ /** Remove all items from the store. */
216
+ async clear() {
217
+ await transact("readwrite", (objectStore, resolve, reject) => {
218
+ const request = withOnError(objectStore.clear(), reject);
219
+ request.onsuccess = () => {
204
220
  resolve();
221
+ };
222
+ });
223
+ },
224
+ /**
225
+ * Returns all items as map of key to value, mainly used for debugging dumps.
226
+ * The type T is applied to all values, even though they might not be of type
227
+ * T (in the case when you store different data types in the same store).
228
+ */
229
+ async asMap() {
230
+ const map = /* @__PURE__ */ new Map();
231
+ await obj.forEach((key, value, expiryMs, storedMs) => {
232
+ map.set(key, { value, expiryMs, storedMs });
233
+ });
234
+ return map;
235
+ },
236
+ /** Returns the ms timestamp for the last GC (garbage collection). */
237
+ getLastGcMs() {
238
+ const lastGcMsStr = localStorage.getItem(gcMsStorageKey);
239
+ if (!lastGcMsStr) return 0;
240
+ const ms = Number(lastGcMsStr);
241
+ return isNaN(ms) ? 0 : ms;
242
+ },
243
+ /** Set the ms timestamp for the last GC (garbage collection). */
244
+ setLastGcMs(ms) {
245
+ localStorage.setItem(gcMsStorageKey, String(ms));
246
+ },
247
+ /** Perform garbage-collection if due, else do nothing. */
248
+ async gc() {
249
+ const lastGcMs = obj.getLastGcMs();
250
+ if (!lastGcMs) {
251
+ obj.setLastGcMs(Date.now());
252
+ return;
253
+ }
254
+ if (Date.now() < lastGcMs + gcIntervalMs) {
255
+ return;
256
+ }
257
+ await obj.gcNow();
258
+ },
259
+ /**
260
+ * Perform garbage collection immediately without checking whether we are
261
+ * due for the next GC or not.
262
+ */
263
+ async gcNow() {
264
+ console.log(`Starting kvStore GC on ${dbName} v${dbVersion}...`);
265
+ obj.setLastGcMs(Date.now());
266
+ const keysToDelete = [];
267
+ await obj.forEach(
268
+ async (key, value, expiryMs) => {
269
+ if (value === void 0 || Date.now() >= expiryMs) {
270
+ keysToDelete.push(key);
271
+ }
205
272
  }
206
- };
207
- });
208
- }
209
- /**
210
- * Returns the number of items in the store. Note that getting the size
211
- * requires iterating through the entire store because the items could expire
212
- * at any time, and hence the size is a dynamic number.
213
- */
214
- async size() {
215
- let count = 0;
216
- await this.forEach(() => {
217
- count++;
218
- });
219
- return count;
220
- }
221
- /** Remove all items from the store. */
222
- async clear() {
223
- await this.transact("readwrite", (objectStore, resolve, reject) => {
224
- const request = withOnError(objectStore.clear(), reject);
225
- request.onsuccess = () => {
226
- resolve();
227
- };
228
- });
229
- }
230
- /**
231
- * Returns all items as map of key to value, mainly used for debugging dumps.
232
- * The type T is applied to all values, even though they might not be of type
233
- * T (in the case when you store different data types in the same store).
234
- */
235
- async asMap() {
236
- const map = /* @__PURE__ */ new Map();
237
- await this.forEach((key, value, expiryMs, storedMs) => {
238
- map.set(key, { value, expiryMs, storedMs });
239
- });
240
- return map;
241
- }
242
- /** Returns the ms timestamp for the last GC (garbage collection). */
243
- get lastGcMs() {
244
- const lastGcMsStr = globalThis.localStorage.getItem(this.gcMsStorageKey);
245
- if (!lastGcMsStr) return 0;
246
- const ms = Number(lastGcMsStr);
247
- return isNaN(ms) ? 0 : ms;
248
- }
249
- /** Set the ms timestamp for the last GC (garbage collection). */
250
- set lastGcMs(ms) {
251
- globalThis.localStorage.setItem(this.gcMsStorageKey, String(ms));
252
- }
253
- /** Perform garbage-collection if due, else do nothing. */
254
- async gc() {
255
- const lastGcMs = this.lastGcMs;
256
- if (!lastGcMs) {
257
- this.lastGcMs = Date.now();
258
- return;
259
- }
260
- if (Date.now() < lastGcMs + this.gcIntervalMs) {
261
- return;
262
- }
263
- await this.gcNow();
264
- }
265
- /**
266
- * Perform garbage collection immediately without checking whether we are
267
- * due for the next GC or not.
268
- */
269
- async gcNow() {
270
- console.log(`Starting kvStore GC on ${this.dbName} v${this.dbVersion}...`);
271
- this.lastGcMs = Date.now();
272
- const keysToDelete = [];
273
- await this.forEach(
274
- async (key, value, expiryMs) => {
275
- if (value === void 0 || Date.now() >= expiryMs) {
276
- keysToDelete.push(key);
277
- }
273
+ );
274
+ if (keysToDelete.length) {
275
+ await obj.delete(keysToDelete);
278
276
  }
279
- );
280
- if (keysToDelete.length) {
281
- await this.delete(keysToDelete);
277
+ console.log(
278
+ `Finished kvStore GC on ${dbName} v${dbVersion} - deleted ${keysToDelete.length} keys`
279
+ );
280
+ obj.setLastGcMs(Date.now());
281
+ },
282
+ /** Returns `this` casted into a StorageAdapter<T>. */
283
+ asStorageAdapter() {
284
+ return obj;
282
285
  }
283
- console.log(
284
- `Finished kvStore GC on ${this.dbName} v${this.dbVersion} - deleted ${keysToDelete.length} keys`
285
- );
286
- this.lastGcMs = Date.now();
287
- }
288
- /** Returns `this` casted into a StorageAdapter<T>. */
289
- asStorageAdapter() {
290
- return this;
291
- }
292
- };
293
- var kvStore = new KvStore(KvStoreConfig.dbName);
294
- var KvStoreItem = class {
295
- constructor(key, defaultExpiryMs = KvStoreConfig.expiryMs, store = kvStore) {
296
- this.key = key;
297
- this.store = store;
298
- this.defaultExpiryMs = defaultExpiryMs && durationOrMsToMs(defaultExpiryMs);
299
- }
300
- defaultExpiryMs;
301
- /** Set a value in the store. */
302
- async set(value, expiryDeltaMs = this.defaultExpiryMs) {
303
- await this.store.set(this.key, value, expiryDeltaMs);
304
- }
305
- /**
306
- * Example usage:
307
- *
308
- * const { value, storedMs, expiryMs, storedMs } =
309
- * await myKvItem.getStoredObject();
310
- */
311
- async getStoredObject() {
312
- return await this.store.getStoredObject(this.key);
313
- }
314
- /** Get a value by key, or undefined if it does not exist. */
315
- async get() {
316
- return await this.store.get(this.key);
317
- }
318
- /** Delete this key from the store. */
319
- async delete() {
320
- await this.store.delete(this.key);
321
- }
322
- };
286
+ };
287
+ return obj;
288
+ }
289
+ var kvStore = createKvStore(KvStoreConfig.dbName);
323
290
  function kvStoreItem(key, expiryMs, store = kvStore) {
324
- expiryMs = expiryMs && durationOrMsToMs(expiryMs);
325
- return new KvStoreItem(key, expiryMs, store);
291
+ const defaultExpiryMs = expiryMs && durationOrMsToMs(expiryMs);
292
+ const obj = {
293
+ key,
294
+ defaultExpiryMs,
295
+ store,
296
+ /** Set a value in the store. */
297
+ async set(value, expiryDeltaMs) {
298
+ await store.set(key, value, expiryDeltaMs ?? defaultExpiryMs);
299
+ },
300
+ /**
301
+ * Example usage:
302
+ *
303
+ * const { value, storedMs, expiryMs, storedMs } =
304
+ * await myKvItem.getStoredObject();
305
+ */
306
+ async getStoredObject() {
307
+ return await store.getStoredObject(key);
308
+ },
309
+ /** Get a value by key, or undefined if it does not exist. */
310
+ async get() {
311
+ return await store.get(key);
312
+ },
313
+ /** Delete this key from the store. */
314
+ async delete() {
315
+ await store.delete(key);
316
+ }
317
+ };
318
+ return obj;
326
319
  }
327
320
  export {
328
- KvStore,
329
321
  KvStoreConfig,
330
- KvStoreItem,
331
322
  configureKvStore,
323
+ createKvStore,
332
324
  kvStore,
333
325
  kvStoreItem
334
326
  };