Skip to content

Commit f5072bb

Browse files
authored
Merge 50da0d3 into ac7d50c
2 parents ac7d50c + 50da0d3 commit f5072bb

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

packages/client/lib/cluster/commands.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import * as APPEND from '../commands/APPEND';
33
import * as BITCOUNT from '../commands/BITCOUNT';
44
import * as BITFIELD from '../commands/BITFIELD';
5+
import * as BITFIELD_RO from '../commands/BITFIELD_RO';
56
import * as BITOP from '../commands/BITOP';
67
import * as BITPOS from '../commands/BITPOS';
78
import * as BLMOVE from '../commands/BLMOVE';
@@ -183,6 +184,8 @@ export default {
183184
bitCount: BITCOUNT,
184185
BITFIELD,
185186
bitField: BITFIELD,
187+
BITFIELD_RO,
188+
bitFieldReadOnly: BITFIELD_RO,
186189
BITOP,
187190
bitOp: BITOP,
188191
BITPOS,

packages/client/lib/commands/BITFIELD.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface BitFieldOperation<S extends string> {
88
operation: S;
99
}
1010

11-
interface BitFieldGetOperation extends BitFieldOperation<'GET'> {
11+
export interface BitFieldGetOperation extends BitFieldOperation<'GET'> {
1212
type: BitFieldType;
1313
offset: number | string;
1414
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments } from './BITFIELD_RO';
4+
5+
describe('BITFIELD_RO', () => {
6+
it('transformArguments', () => {
7+
assert.deepEqual(
8+
transformArguments('key', {
9+
operation: 'GET',
10+
type: 'i8',
11+
offset: 0
12+
}),
13+
['BITFIELD_RO', 'key', 'GET', 'i8', '0']
14+
);
15+
});
16+
17+
testUtils.testWithClient('client.bitFieldReadOnly', async client => {
18+
assert.deepEqual(
19+
await client.bitFieldReadOnly('key', {
20+
operation: 'GET',
21+
type: 'i8',
22+
offset: 0
23+
}),
24+
[0]
25+
);
26+
}, GLOBAL.SERVERS.OPEN);
27+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { BitFieldGetOperation } from './BITFIELD';
2+
3+
export const FIRST_KEY_INDEX = 1;
4+
5+
export const IS_READ_ONLY = true;
6+
7+
export function transformArguments(key: string, getOperation: BitFieldGetOperation): Array<string> {
8+
const args = ['BITFIELD_RO', key];
9+
10+
args.push(
11+
'GET',
12+
getOperation.type,
13+
getOperation.offset.toString()
14+
);
15+
return args;
16+
}
17+
18+
export declare function transformReply(): Array<number | null>;

0 commit comments

Comments
 (0)