@bypixeltv/kvstore 1.2.0 → 1.2.1

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/index.d.ts CHANGED
@@ -103,7 +103,9 @@ export declare class KVStoreClient {
103
103
  loadNamespaceCache(namespace: string, signal?: AbortSignal): Promise<NamespaceCache>;
104
104
  private readForTransaction;
105
105
  private transactWithRetry;
106
- getJson<T>(namespace: string, key: string): Promise<T | undefined>;
106
+ getJson<T>(namespace: string, key: string, options?: {
107
+ emptyAsMissing?: boolean;
108
+ }): Promise<T | undefined>;
107
109
  setJson<T>(namespace: string, key: string, value: T, expiresAtUnixMs?: number): Promise<SetResult>;
108
110
  head(signal?: AbortSignal): Promise<Head>;
109
111
  scan(namespace: string, signal?: AbortSignal): AsyncGenerator<ScanRecord>;
package/dist/index.js CHANGED
@@ -168,9 +168,11 @@ export class KVStoreClient {
168
168
  throw error;
169
169
  }
170
170
  }
171
- async getJson(namespace, key) {
171
+ async getJson(namespace, key, options = {}) {
172
172
  const result = await this.get(namespace, key);
173
- return result.found ? JSON.parse(result.value.toString("utf8")) : undefined;
173
+ if (!result.found || (options.emptyAsMissing && result.value.length === 0))
174
+ return undefined;
175
+ return JSON.parse(result.value.toString("utf8"));
174
176
  }
175
177
  async setJson(namespace, key, value, expiresAtUnixMs = 0) {
176
178
  const json = JSON.stringify(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bypixeltv/kvstore",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Node.js and TypeScript gRPC client for KVStore",
5
5
  "license": "MIT",
6
6
  "type": "module",