Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency @upstash/redis to v1.34.0 #713

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading