Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cd3439f

Browse files
authored
add support for ioredis clients (#68)
* add support for ioredis clients * install ioredis in build command
1 parent 89c9c60 commit cd3439f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

‎.circleci/config.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545

4646

4747
# generate types
48+
- run: npm install ioredis # ioredis is used in jsdocs (and the types built from the jsdoc)
4849
- run: npm run types
4950

5051
# run tests!

‎src/graph.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const redis = require("redis"),
55
util = require("util"),
66
ResultSet = require("./resultSet");
77

8+
/**
9+
* @typedef {import('ioredis') | redis.RedisClient} RedisClient
10+
*/
11+
812
/**
913
* RedisGraph client
1014
*/
@@ -14,7 +18,7 @@ class Graph {
1418
* See: node_redis for more options on createClient
1519
*
1620
* @param {string} graphId the graph id
17-
* @param {string | redis.RedisClient} [host] Redis host or node_redis client
21+
* @param {string | RedisClient} [host] Redis host or node_redis client or ioredis client
1822
* @param {string | number} [port] Redis port (integer)
1923
* @param {Object} [options] node_redis options
2024
*/
@@ -29,7 +33,7 @@ class Graph {
2933
this._relationshipPromise = undefined; // used as a synchronization mechanizom for relationship types retrival
3034

3135
this._client =
32-
host instanceofredis.RedisClient
36+
host &&typeofhost.send_command==='function'// check if it's an instance of `redis` or `ioredis`
3337
? host
3438
: redis.createClient(port, host, options);
3539
this._sendCommand = util.promisify(this._client.send_command).bind(this._client);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /