Skip to content

Commit

Permalink
fix(deps): update dependency @upstash/redis to v1.34.0 (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored Sep 27, 2024
1 parent 8c8e6a7 commit 14bc82e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-teachers-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vercel/kv": major
---

BREAKING: Updates @upstash/redis to v1.34.0 which contains a small breaking change in the public API. The cursor field in scan commands is now returned as `string` instead of `number`.
10 changes: 5 additions & 5 deletions packages/kv/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import defaultKv, { kv, VercelKV, createClient } from '.';

let scanReturnValues: [number, string[]][] = [[0, []]];
let scanReturnValues: [string, string[]][] = [['0', []]];
jest.mock('@upstash/redis', () => ({
Redis: jest.fn(() => ({
get: jest.fn().mockResolvedValue('bar'),
Expand All @@ -14,7 +14,7 @@ jest.mock('@upstash/redis', () => ({

describe('@vercel/kv', () => {
beforeEach(() => {
scanReturnValues = [[0, []]];
scanReturnValues = [['0', []]];
jest.clearAllMocks();
});

Expand Down Expand Up @@ -78,9 +78,9 @@ describe('@vercel/kv', () => {

it('supports iteration', async () => {
scanReturnValues = [
[2, ['1', '2']],
[4, ['3', '4']],
[0, []],
['2', ['1', '2']],
['4', ['3', '4']],
['0', []],
];
const client = createClient({ url: 'foobar', token: 'foobar' });
const returnedKeys: string[] = [];
Expand Down
16 changes: 8 additions & 8 deletions packages/kv/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export class VercelKV extends Redis {
* Same as `scan` but returns an AsyncIterator to allow iteration via `for await`.
*/
async *scanIterator(options?: ScanCommandOptions): AsyncIterable<string> {
let cursor = 0;
let cursor = '0';
let keys: string[];
do {
// eslint-disable-next-line no-await-in-loop -- [@vercel/style-guide@5 migration]
[cursor, keys] = await this.scan(cursor, options);
for (const key of keys) {
yield key;
}
} while (cursor !== 0);
} while (cursor !== '0');
}

/**
Expand All @@ -28,15 +28,15 @@ export class VercelKV extends Redis {
key: string,
options?: ScanCommandOptions,
): AsyncIterable<string | number> {
let cursor = 0;
let cursor = '0';
let items: (number | string)[];
do {
// eslint-disable-next-line no-await-in-loop -- [@vercel/style-guide@5 migration]
[cursor, items] = await this.hscan(key, cursor, options);
for (const item of items) {
yield item;
}
} while (cursor !== 0);
} while (cursor !== '0');
}

/**
Expand All @@ -46,15 +46,15 @@ export class VercelKV extends Redis {
key: string,
options?: ScanCommandOptions,
): AsyncIterable<string | number> {
let cursor = 0;
let cursor = '0';
let items: (number | string)[];
do {
// eslint-disable-next-line no-await-in-loop -- [@vercel/style-guide@5 migration]
[cursor, items] = await this.sscan(key, cursor, options);
for (const item of items) {
yield item;
}
} while (cursor !== 0);
} while (cursor !== '0');
}

/**
Expand All @@ -64,15 +64,15 @@ export class VercelKV extends Redis {
key: string,
options?: ScanCommandOptions,
): AsyncIterable<string | number> {
let cursor = 0;
let cursor = '0';
let items: (number | string)[];
do {
// eslint-disable-next-line no-await-in-loop -- [@vercel/style-guide@5 migration]
[cursor, items] = await this.zscan(key, cursor, options);
for (const item of items) {
yield item;
}
} while (cursor !== 0);
} while (cursor !== '0');
}
}

Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 14bc82e

Please sign in to comment.