Skip to content

Commit

Permalink
馃 Merge PR #57521 [ioredis] add lindexBuffer by @Naeemo
Browse files Browse the repository at this point in the history
  • Loading branch information
Naeemo committed Dec 3, 2021
1 parent 9551b73 commit c359539
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions types/ioredis/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ declare namespace IORedis {
lindex(key: KeyType, index: number, callback: Callback<string>): void;
lindex(key: KeyType, index: number): Promise<string>;

lindexBuffer(key: KeyType, index: number, callback: Callback<Buffer>): void;
lindexBuffer(key: KeyType, index: number): Promise<Buffer>;

lset(key: KeyType, index: number, value: ValueType, callback: Callback<Ok>): void;
lset(key: KeyType, index: number, value: ValueType): Promise<Ok>;

Expand Down
9 changes: 9 additions & 0 deletions types/ioredis/ioredis-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ const listData = ['foo', 'bar', 'baz'];
listData.forEach(value => {
redis.rpushBuffer('bufferlist', Buffer.from(value));
});

redis.lindexBuffer('bufferlist', 0, (err, result) => {
if (result.toString() !== listData[0]) {
console.log(result.toString());
}
});

redis.lindexBuffer('bufferlist', 0).then(console.log);

redis.lpopBuffer('bufferlist', (err, result) => {
if (result.toString() !== listData[0]) {
console.log(result.toString());
Expand Down

0 comments on commit c359539

Please sign in to comment.