@upstash/redis 1.23.2 → 1.23.4

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.
@@ -1,23 +1,22 @@
1
1
  import { Command } from "./command.js";
2
2
  function deserialize(result) {
3
- if (result.length === 0) {
4
- return {};
5
- }
6
3
  const obj = {};
7
- while (result.length >= 2) {
8
- const streamId = result.shift();
9
- const entries = result.shift();
10
- if (!(streamId in obj)) {
11
- obj[streamId] = {};
12
- }
13
- while (entries.length >= 2) {
14
- const field = entries.shift();
15
- const value = entries.shift();
16
- try {
17
- obj[streamId][field] = JSON.parse(value);
4
+ for (const e of result) {
5
+ while (e.length >= 2) {
6
+ const streamId = e.shift();
7
+ const entries = e.shift();
8
+ if (!(streamId in obj)) {
9
+ obj[streamId] = {};
18
10
  }
19
- catch {
20
- obj[streamId][field] = value;
11
+ while (entries.length >= 2) {
12
+ const field = entries.shift();
13
+ const value = entries.shift();
14
+ try {
15
+ obj[streamId][field] = JSON.parse(value);
16
+ }
17
+ catch {
18
+ obj[streamId][field] = value;
19
+ }
21
20
  }
22
21
  }
23
22
  }
@@ -30,7 +29,7 @@ export class XRangeCommand extends Command {
30
29
  command.push("COUNT", count);
31
30
  }
32
31
  super(command, {
33
- deserialize: (result) => deserialize(result[0]),
32
+ deserialize: (result) => deserialize(result),
34
33
  ...opts,
35
34
  });
36
35
  }
@@ -1190,6 +1190,12 @@ export class Pipeline {
1190
1190
  this.commandOptions = opts.commandOptions;
1191
1191
  this.multiExec = opts.multiExec ?? false;
1192
1192
  }
1193
+ /**
1194
+ * Returns the length of pipeline before the execution
1195
+ */
1196
+ length() {
1197
+ return this.commands.length;
1198
+ }
1193
1199
  /**
1194
1200
  * Pushes a command into the pipeline and returns a chainable instance of the
1195
1201
  * pipeline
package/esm/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "v1.23.2";
1
+ export const VERSION = "v1.23.4";
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./script/platforms/nodejs.js",
4
4
  "types": "./types/platforms/nodejs.d.ts",
5
5
  "name": "@upstash/redis",
6
- "version": "v1.23.2",
6
+ "version": "v1.23.4",
7
7
  "description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
8
8
  "repository": {
9
9
  "type": "git",
@@ -3,24 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.XRangeCommand = void 0;
4
4
  const command_js_1 = require("./command.js");
5
5
  function deserialize(result) {
6
- if (result.length === 0) {
7
- return {};
8
- }
9
6
  const obj = {};
10
- while (result.length >= 2) {
11
- const streamId = result.shift();
12
- const entries = result.shift();
13
- if (!(streamId in obj)) {
14
- obj[streamId] = {};
15
- }
16
- while (entries.length >= 2) {
17
- const field = entries.shift();
18
- const value = entries.shift();
19
- try {
20
- obj[streamId][field] = JSON.parse(value);
7
+ for (const e of result) {
8
+ while (e.length >= 2) {
9
+ const streamId = e.shift();
10
+ const entries = e.shift();
11
+ if (!(streamId in obj)) {
12
+ obj[streamId] = {};
21
13
  }
22
- catch {
23
- obj[streamId][field] = value;
14
+ while (entries.length >= 2) {
15
+ const field = entries.shift();
16
+ const value = entries.shift();
17
+ try {
18
+ obj[streamId][field] = JSON.parse(value);
19
+ }
20
+ catch {
21
+ obj[streamId][field] = value;
22
+ }
24
23
  }
25
24
  }
26
25
  }
@@ -33,7 +32,7 @@ class XRangeCommand extends command_js_1.Command {
33
32
  command.push("COUNT", count);
34
33
  }
35
34
  super(command, {
36
- deserialize: (result) => deserialize(result[0]),
35
+ deserialize: (result) => deserialize(result),
37
36
  ...opts,
38
37
  });
39
38
  }
@@ -1193,6 +1193,12 @@ class Pipeline {
1193
1193
  this.commandOptions = opts.commandOptions;
1194
1194
  this.multiExec = opts.multiExec ?? false;
1195
1195
  }
1196
+ /**
1197
+ * Returns the length of pipeline before the execution
1198
+ */
1199
+ length() {
1200
+ return this.commands.length;
1201
+ }
1196
1202
  /**
1197
1203
  * Pushes a command into the pipeline and returns a chainable instance of the
1198
1204
  * pipeline
package/script/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "v1.23.2";
4
+ exports.VERSION = "v1.23.4";
@@ -66,6 +66,10 @@ export declare class Pipeline<TCommands extends Command<any, any>[] = []> {
66
66
  * ```
67
67
  */
68
68
  exec: <TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>() => Promise<TCommandResults>;
69
+ /**
70
+ * Returns the length of pipeline before the execution
71
+ */
72
+ length(): number;
69
73
  /**
70
74
  * Pushes a command into the pipeline and returns a chainable instance of the
71
75
  * pipeline
@@ -1 +1 @@
1
- export declare const VERSION = "v1.23.2";
1
+ export declare const VERSION = "v1.23.4";