diff --git a/packages/client/lib/client/index.ts b/packages/client/lib/client/index.ts index fb86908bd2f..35ad7d040ed 100644 --- a/packages/client/lib/client/index.ts +++ b/packages/client/lib/client/index.ts @@ -621,7 +621,7 @@ export default class RedisClient< } async* scanIterator(options?: ScanCommandOptions): AsyncIterable { - let cursor = 0; + let cursor = (options && options.CURSOR) || 0; do { const reply = await (this as any).scan(cursor, options); cursor = reply.cursor; @@ -632,7 +632,7 @@ export default class RedisClient< } async* hScanIterator(key: string, options?: ScanOptions): AsyncIterable> { - let cursor = 0; + let cursor = (options && options.CURSOR) || 0; do { const reply = await (this as any).hScan(key, cursor, options); cursor = reply.cursor; @@ -643,7 +643,7 @@ export default class RedisClient< } async* sScanIterator(key: string, options?: ScanOptions): AsyncIterable { - let cursor = 0; + let cursor = (options && options.CURSOR) || 0; do { const reply = await (this as any).sScan(key, cursor, options); cursor = reply.cursor; @@ -654,7 +654,7 @@ export default class RedisClient< } async* zScanIterator(key: string, options?: ScanOptions): AsyncIterable> { - let cursor = 0; + let cursor = (options && options.CURSOR) || 0; do { const reply = await (this as any).zScan(key, cursor, options); cursor = reply.cursor;