mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-04 07:52:51 +00:00
Add types to allow string array argument for hmset (#33835)
* add missing type * update test * add name to Definitions By * add missing types and update test * regularize formatting * remove string[] * remove duplicate typing * organized formatting * Merge branch 'master' of https://github.com/OpesanyaAdebayo/DefinitelyTyped * remove duplicate typing * add types and tests for typescript 3.0 upwards * resolve version conflicts * resolve version conflict * resolve formatting * remove new types from older version * remove header from submodule
This commit is contained in:
parent
0a509d5fb5
commit
c00200d2ad
1
types/redis/index.d.ts
vendored
1
types/redis/index.d.ts
vendored
@ -10,6 +10,7 @@
|
||||
// Pirasis Leelatanon <https://github.com/1pete>
|
||||
// Stanislav Dzhus <https://github.com/blablapolicja>
|
||||
// Jake Ferrante <https://github.com/ferrantejake>
|
||||
// Adebayo Opesanya <https://github.com/OpesanyaAdebayo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Imported from: https://github.com/types/npm-redis
|
||||
|
||||
11
types/redis/package.json
Normal file
11
types/redis/package.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"private": true,
|
||||
"types": "index",
|
||||
"typesVersions": {
|
||||
">=3.1.0-0": {
|
||||
"*": [
|
||||
"ts3.1/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -20,8 +20,8 @@ redis.print(err, value);
|
||||
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
|
||||
|
||||
const options: redis.ClientOpts = {
|
||||
host: "localhost",
|
||||
port: 6379,
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
};
|
||||
let client: redis.RedisClient = redis.createClient(num, str, options);
|
||||
|
||||
@ -90,6 +90,8 @@ client.incr(str, resCallback);
|
||||
client.hgetall(str, resCallback);
|
||||
client.hmset(str, value, okCallback);
|
||||
client.hmset(str, str, str, str, str, okCallback);
|
||||
client.hmset(str, [str, str, str, str]);
|
||||
client.hmset(str, [str, value, str, value], okCallback);
|
||||
|
||||
// Publish / Subscribe
|
||||
client.publish(str, value);
|
||||
@ -115,8 +117,8 @@ client.duplicate();
|
||||
|
||||
// Pipeline
|
||||
client.cork();
|
||||
client.set("abc", "fff", strCallback);
|
||||
client.get("abc", resCallback);
|
||||
client.set('abc', 'fff', strCallback);
|
||||
client.get('abc', resCallback);
|
||||
client.uncork();
|
||||
|
||||
// Add command
|
||||
|
||||
1235
types/redis/ts3.1/index.d.ts
vendored
Normal file
1235
types/redis/ts3.1/index.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
142
types/redis/ts3.1/redis-tests.ts
Normal file
142
types/redis/ts3.1/redis-tests.ts
Normal file
@ -0,0 +1,142 @@
|
||||
import redis = require('redis');
|
||||
|
||||
const value: any = 'any value';
|
||||
const commandArr: any[][] = [];
|
||||
const num = 0;
|
||||
const str = 'any string';
|
||||
const err: Error = new Error();
|
||||
const args: any[] = [];
|
||||
const resCallback: (err: Error | null, res: any) => void = () => {};
|
||||
const numCallback: (err: Error | null, res: number) => void = () => {};
|
||||
const strCallback: (err: Error | null, res: string) => void = () => {};
|
||||
const okCallback: (err: Error | null, res: 'OK') => void = () => {};
|
||||
const messageHandler: (channel: string, message: any) => void = () => {};
|
||||
|
||||
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
|
||||
|
||||
const debug_mode: boolean = redis.debug_mode;
|
||||
redis.print(err, value);
|
||||
|
||||
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
|
||||
|
||||
const options: redis.ClientOpts = {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
};
|
||||
let client: redis.RedisClient = redis.createClient(num, str, options);
|
||||
|
||||
// Test the `retry_strategy` property
|
||||
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
|
||||
function retryStrategyNumber(options: redis.RetryStrategyOptions): number {
|
||||
// Ensure that the properties of RetryStrategyOptions are resilient to breaking change.
|
||||
// If the properties of the interface changes, the variables below will also need to be adapted.
|
||||
const error: Error = options.error;
|
||||
const total_retry_time: number = options.total_retry_time;
|
||||
const times_connected: number = options.times_connected;
|
||||
const attempt: number = options.attempt;
|
||||
return 5000;
|
||||
}
|
||||
function retryStrategyError(options: redis.RetryStrategyOptions): Error {
|
||||
return new Error('Foo');
|
||||
}
|
||||
client = redis.createClient({
|
||||
retry_strategy: retryStrategyNumber
|
||||
});
|
||||
client = redis.createClient({
|
||||
retry_strategy: retryStrategyError
|
||||
});
|
||||
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
|
||||
|
||||
const connected: boolean = client.connected;
|
||||
const retry_delay: number = client.retry_delay;
|
||||
const retry_backoff: number = client.retry_backoff;
|
||||
const command_queue: any[] = client.command_queue;
|
||||
const offline_queue: any[] = client.offline_queue;
|
||||
const info: redis.ServerInfo = client.server_info;
|
||||
|
||||
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
|
||||
|
||||
client.end(true);
|
||||
|
||||
// Connection (http://redis.io/commands#connection)
|
||||
client.auth(str, resCallback);
|
||||
client.ping(strCallback);
|
||||
client.unref();
|
||||
|
||||
// Strings (http://redis.io/commands#strings)
|
||||
client.append(str, str, numCallback);
|
||||
client.bitcount(str, numCallback);
|
||||
client.bitcount(str, num, num, numCallback);
|
||||
client.set(str, str, okCallback);
|
||||
client.get(str, strCallback);
|
||||
client.exists(str, numCallback);
|
||||
|
||||
// Event handlers
|
||||
client.on(str, messageHandler);
|
||||
client.once(str, messageHandler);
|
||||
|
||||
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
|
||||
|
||||
// some of the bulk methods
|
||||
client.get('test');
|
||||
client.get('test', resCallback);
|
||||
client.set('test', 'test');
|
||||
client.set('test', 'test', okCallback);
|
||||
client.mset(args, resCallback);
|
||||
|
||||
client.incr(str, resCallback);
|
||||
|
||||
// Friendlier hash commands
|
||||
client.hgetall(str, resCallback);
|
||||
client.hmset(str, value, okCallback);
|
||||
client.hmset(str, str, str, str, str, okCallback);
|
||||
client.hmset([str, str, str, str, str], okCallback);
|
||||
client.hmset([str, str, str, str, str]);
|
||||
client.hmset(str, [str, str, str, str]);
|
||||
client.hmset(str, [str, value, str, value], okCallback);
|
||||
|
||||
// Publish / Subscribe
|
||||
client.publish(str, value);
|
||||
client.subscribe(str);
|
||||
|
||||
// Multi
|
||||
client.multi()
|
||||
.scard(str)
|
||||
.smembers(str)
|
||||
.keys('*', resCallback)
|
||||
.dbsize()
|
||||
.exec(resCallback);
|
||||
|
||||
client.multi([['get', 'test']]).exec();
|
||||
|
||||
// Monitor mode
|
||||
client.monitor(resCallback);
|
||||
|
||||
// Send command
|
||||
client.send_command(str, args, resCallback);
|
||||
// Duplicate
|
||||
client.duplicate();
|
||||
|
||||
// Pipeline
|
||||
client.cork();
|
||||
client.set('abc', 'fff', strCallback);
|
||||
client.get('abc', resCallback);
|
||||
client.uncork();
|
||||
|
||||
// Add command
|
||||
client.add_command('my command');
|
||||
client.addCommand('my other command');
|
||||
|
||||
// redis.print as callback
|
||||
client.set(str, str, redis.print);
|
||||
client.get(str, redis.print);
|
||||
|
||||
// increase-by-float reply a string
|
||||
client.incrbyfloat('a', 1.5, (error, value) => value.startsWith('1'));
|
||||
client.INCRBYFLOAT('a', 1.5, (error, value) => value.startsWith('1'));
|
||||
client.hincrbyfloat('a', 'b', 1.5, (error, value) => value.startsWith('1'));
|
||||
client.HINCRBYFLOAT('a', 'b', 1.5, (error, value) => value.startsWith('1'));
|
||||
client.zincrby('a', 1, 'b', strCallback);
|
||||
client.ZINCRBY('a', 1, 'b', strCallback);
|
||||
|
||||
client.flushdb(okCallback);
|
||||
23
types/redis/ts3.1/tsconfig.json
Normal file
23
types/redis/ts3.1/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"redis-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/redis/ts3.1/tslint.json
Normal file
1
types/redis/ts3.1/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user