@azteam/redis-async 1.0.51 → 1.0.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,8 @@
1
1
  {
2
2
  "name": "@azteam/redis-async",
3
- "version": "1.0.51",
3
+ "version": "1.0.54",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/toda93/redis-async.git"
9
- },
10
6
  "engines": {
11
7
  "node": ">= 10.0.0",
12
8
  "npm": ">=7.0.0"
@@ -19,12 +15,8 @@
19
15
  ],
20
16
  "author": "toda <sp.azsolution.net@gmail.com>",
21
17
  "license": "MIT",
22
- "bugs": {
23
- "url": "https://github.com/toda93/redis-async/issues"
24
- },
25
- "homepage": "https://github.com/toda93/redis-async#readme",
26
18
  "dependencies": {
27
- "@azteam/util": "1.0.9",
19
+ "@azteam/util": "1.0.10",
28
20
  "redis": "4.0.6"
29
21
  }
30
22
  }
package/src/Provider.js CHANGED
@@ -1,13 +1,16 @@
1
1
  import RedisAsync from './RedisAsync';
2
2
 
3
3
  class Provider {
4
- constructor(configs, isSingle = false) {
4
+ constructor(configs = []) {
5
5
  this.connections = {};
6
- this.configs = configs;
7
- if (isSingle) {
8
- this.configs = {
9
- single: configs,
10
- };
6
+ this.configs = {};
7
+ if (Array.isArray(configs)) {
8
+ configs.map((config) => {
9
+ this.configs[config.name] = config;
10
+ return true;
11
+ });
12
+ } else {
13
+ this.configs.single = configs;
11
14
  }
12
15
  }
13
16
 
package/src/RedisAsync.js CHANGED
@@ -2,7 +2,7 @@ import {createClient} from 'redis';
2
2
  import {timeout} from '@azteam/util';
3
3
 
4
4
  class RedisAsync {
5
- constructor(config) {
5
+ constructor(configs = []) {
6
6
  this.connected = false;
7
7
  this.host = config.host;
8
8
  this.port = config.port;
@@ -11,15 +11,12 @@ class RedisAsync {
11
11
  }
12
12
 
13
13
  async waitConnection(n = 10) {
14
- let i = 0;
15
- while (!this.connected) {
16
- ++i;
17
- if (i >= n) {
18
- return false;
19
- }
14
+ for (let i = 0; !this.connected || i < n; i += 1) {
20
15
  await timeout(1000);
21
16
  }
22
- return true;
17
+ if (!this.connected) {
18
+ throw new Error('Redis not connected');
19
+ }
23
20
  }
24
21
 
25
22
  parsePrefix(name) {