@ekhein/lamda-node-sdk 2.1.6 → 2.1.7

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/main.d.ts CHANGED
@@ -41,7 +41,7 @@ export declare class Storage {
41
41
  setex(key: string, data: any, ttl: number): Promise<boolean>;
42
42
  setnx(key: string, data: any): Promise<boolean>;
43
43
  expire(key: string, ttl: number): Promise<boolean>;
44
- get<T = any>(key: string): Promise<T>;
44
+ get<T = any>(key: string, defaultValue?: any): Promise<T>;
45
45
  ttl(key: string): Promise<number>;
46
46
  exists(key: string): Promise<boolean>;
47
47
  delete(key: string): Promise<boolean>;
package/dist/main.js CHANGED
@@ -184,10 +184,14 @@ class Storage {
184
184
  .expire({ container: this.container, key, ttl })
185
185
  .then(async (r) => r.value);
186
186
  }
187
- async get(key) {
187
+ async get(key, defaultValue) {
188
188
  return this.$.Storage
189
189
  .get({ container: this.container, key })
190
- .then(async (r) => (0, msgpackr_1.unpack)(r.value));
190
+ .then(async (r) => {
191
+ if (r.value.length)
192
+ return (0, msgpackr_1.unpack)(r.value);
193
+ return defaultValue;
194
+ });
191
195
  }
192
196
  async ttl(key) {
193
197
  return this.$.Storage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekhein/lamda-node-sdk",
3
- "version": "2.1.6",
3
+ "version": "2.1.7",
4
4
  "author": "ekhein",
5
5
  "license": "MIT",
6
6
  "main": "./dist/main.js",