Skip to content

Commit 78f1532

Browse files
committed
Dependency Update & Lint
1 parent 86c2bb9 commit 78f1532

File tree

11 files changed

+1599
-1995
lines changed

11 files changed

+1599
-1995
lines changed

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
test/
1+
node_modules/

.eslintrc

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{
22
"root": true,
3-
"extends": [
4-
"airbnb"
5-
],
3+
"extends": ["eslint:recommended"],
4+
"parserOptions": {
5+
"ecmaVersion": 8,
6+
"sourceType": "script"
7+
},
68
"env": {
7-
"node": true
9+
"es6": true,
10+
"node": true,
11+
"mocha": true
812
}
913
}

LICENSE.md LICENSE

File renamed without changes.

examples/create-redis.js

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
const asyncRedis = require("../src");
1+
/* eslint no-console: 0 */
2+
const asyncRedis = require('../src');
3+
24
const client = asyncRedis.createClient();
35

4-
client.on("error", function (err) {
5-
console.log("Error " + err);
6+
client.on('error', (err) => {
7+
console.log(`Error ${err}`);
68
});
79

8-
let addToSet = async () => {
9-
let key = 'exampleSet';
10-
let values = [
10+
const addToSet = async () => {
11+
const key = 'exampleSet';
12+
const values = [
1113
'item_1',
1214
'item_2',
1315
'item_3',
1416
'item_4',
1517
'item_5',
1618
];
17-
let promises = values.map((value) => {
18-
return client.sadd(key, value);
19-
});
19+
const promises = values.map(value => client.sadd(key, value));
2020
await Promise.all(promises);
21-
return await client.smembers(key);
21+
return client.smembers(key);
2222
};
2323

24-
let flush = async () => {
25-
return await client.flushall();
26-
};
24+
const flush = async () => client.flushall();
2725

2826
addToSet()
2927
.then((results) => {

package.json

+24-27
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,51 @@
11
{
22
"private": false,
3-
"version": "1.1.7",
3+
"author": "Matthew Oaxaca",
4+
"license": "MIT",
5+
"version": "1.1.8",
46
"name": "async-redis",
57
"keywords": [
68
"redis",
79
"async",
810
"promise",
911
"es6"
1012
],
11-
"author": "Matthew Oaxaca",
12-
"license": "MIT",
1313
"description": "Light wrapper over redis_node with first class async & promise support.",
14+
"repository": {
15+
"type": "git",
16+
"url": "git://github.com/moaxaca/async-redis.git"
17+
},
18+
"bugs": {
19+
"url": "https://github.com/moaxaca/async-redis/issues"
20+
},
1421
"main": "src/index.js",
15-
"typings": "./index.d.ts",
22+
"typings": "src/index.d.ts",
1623
"engines": {
1724
"node": ">=7.6.0"
1825
},
26+
"directories": {
27+
"example": "examples",
28+
"test": "test"
29+
},
1930
"scripts": {
2031
"coveralls": "nyc yarn test && nyc report --reporter=text-lcov | coveralls",
21-
"lint": "eslint --fix --ext .js, src",
32+
"lint": "eslint --fix --ext .js, .",
2233
"test": "mocha",
34+
"test:unit": "mocha",
2335
"version:patch": "npm version patch",
2436
"version:minor": "npm version minor",
2537
"version:major": "npm version major"
2638
},
2739
"dependencies": {
28-
"redis": "^3.0.0",
29-
"redis-commands": "^1.3.1"
40+
"redis": "^3.0.2",
41+
"redis-commands": "^1.6.0"
3042
},
3143
"devDependencies": {
32-
"chai": "^3.5.0",
44+
"chai": "^4.2.0",
3345
"chai-as-promised": "^7.1.1",
34-
"coveralls": "^3.0.0",
35-
"eslint": "^4.17.0",
36-
"eslint-config-airbnb": "^16.1.0",
37-
"eslint-plugin-import": "^2.8.0",
38-
"eslint-plugin-jsx-a11y": "^6.0.3",
39-
"eslint-plugin-react": "^7.6.1",
40-
"mocha": "^3.2.0",
41-
"nyc": "^11.4.1"
42-
},
43-
"repository": {
44-
"type": "git",
45-
"url": "git://github.com/moaxaca/async-redis.git"
46-
},
47-
"bugs": {
48-
"url": "https://github.com/moaxaca/async-redis/issues"
49-
},
50-
"directories": {
51-
"example": "examples",
52-
"test": "test"
46+
"coveralls": "^3.1.0",
47+
"eslint": "^7.6.0",
48+
"mocha": "^8.1.0",
49+
"nyc": "^15.1.0"
5350
}
5451
}

src/index.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint func-names: ["error", "as-needed"] */
2-
31
const redis = require('redis');
42
const commands = require('redis-commands').list;
53
const objectDecorator = require('./object-decorator');
@@ -11,13 +9,9 @@ const AsyncRedis = function (args) {
119

1210
AsyncRedis.createClient = (...args) => new AsyncRedis(args);
1311

14-
// this is the set of commands to NOT promisify
1512
const commandsToSkipSet = new Set(['multi']);
16-
// this is the set of commands to promisify
1713
const commandSet = new Set(commands.filter(c => !commandsToSkipSet.has(c)));
18-
// this is the set of commands that return a Multi
1914
const queueCommandSet = new Set(['batch', 'multi']);
20-
// this is the set of Multi commands to promisify
2115
const multiCommandSet = new Set(['exec', 'exec_atomic']);
2216

2317
const promisify = function (object, method) {
@@ -31,16 +25,13 @@ const promisify = function (object, method) {
3125
});
3226
method.apply(object, args);
3327
});
34-
}
28+
};
3529

3630
AsyncRedis.decorate = redisClient => objectDecorator(redisClient, (name, method) => {
37-
const asyncClient = Object.create(redisClient);
38-
3931
if (commandSet.has(name)) {
4032
return promisify(redisClient, method);
4133
} else if (queueCommandSet.has(name)) {
4234
return (...args) => {
43-
// Decorate the Multi object
4435
const multi = method.apply(redisClient, args);
4536
return objectDecorator(multi, (multiName, multiMethod) => {
4637
if (multiCommandSet.has(multiName)) {

test/integration/commands/common.spec.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
const { assert } = require('chai');
22
const AsyncRedis = require('../../../src');
33

4-
describe('Commands - Common', function () {
4+
describe('Commands - Common', () => {
55
let redisClient;
66

7-
beforeEach(async() => {
7+
beforeEach(async () => {
88
redisClient = new AsyncRedis();
99
});
1010

11-
afterEach(async() => {
11+
afterEach(async () => {
1212
redisClient.flushall();
1313
});
1414

15-
describe('test set method', function () {
15+
describe('test set method', () => {
1616
it('should return ok', async () => {
17-
let status = await redisClient.set('hello', 'world');
17+
const status = await redisClient.set('hello', 'world');
1818
assert.equal(status, 'OK');
1919
});
2020
});
2121

22-
describe('test get method', function () {
22+
describe('test get method', () => {
2323
it('should return value', async () => {
2424
await redisClient.set('hello', 'world');
2525
const value = await redisClient.get('hello');
2626
assert.equal(value, 'world');
2727
});
2828
});
2929

30-
describe('test del method', function () {
30+
describe('test del method', () => {
3131
it('should return true', async () => {
3232
await redisClient.set('hello', 'world');
3333
const status = await redisClient.del('hello');
@@ -40,25 +40,24 @@ describe('Commands - Common', function () {
4040
});
4141
});
4242

43-
describe('test del method', function () {
43+
describe('test del method', () => {
4444
it('should return true', async () => {
4545
await redisClient.set('hello', 'world');
4646
const status = await redisClient.del('hello');
4747
assert.equal(status, true);
4848
});
4949
});
5050

51-
describe('test rejection', function () {
51+
describe('test rejection', () => {
5252
it('should reject promise on throw', async () => {
53-
let promise = redisClient.set('hello');
53+
const promise = redisClient.set('hello');
5454
assert.isRejected(promise, Error);
5555
});
5656
});
5757

58-
describe('test multi not a promise', function () {
58+
describe('test multi not a promise', () => {
5959
it('should be not equal', async () => {
60-
let notAPromise = redisClient.multi();
61-
console.log(notAPromise);
60+
const notAPromise = redisClient.multi();
6261
assert.notEqual(Promise.resolve(notAPromise), notAPromise);
6362
});
6463
});

test/integration/create-client.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { assert } = require('chai');
22
const { RedisClient } = require('redis');
33
const AsyncRedis = require('../../src');
44

5-
describe('AsyncRedis.createClient', function () {
5+
describe('AsyncRedis.createClient', () => {
66
const options = {
77
host: '127.0.0.1',
88
port: 6379,

test/integration/decorate-redis.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ const redis = require('redis');
33
const redisCommands = require('redis-commands');
44
const AsyncRedis = require('../../src');
55

6-
describe('AsyncRedis.decorate', function () {
6+
describe('AsyncRedis.decorate', () => {
77
const client = redis.createClient();
88
const asyncRedisClient = AsyncRedis.decorate(client);
99

1010
it('should have decorated every command', async () => {
1111
const commands = redisCommands.list;
12-
commands.forEach(command => {
12+
commands.forEach((command) => {
1313
assert.isFunction(asyncRedisClient[command], `redis.${command} isn't decorated`);
1414
});
1515
});

test/unit/object-decorator.js

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,29 @@
1-
"use strict";
2-
31
const { assert } = require('chai');
42
const objectDecorator = require('../../src/object-decorator');
53

6-
const Mock = function () {
7-
this.add = function(a, b) {
8-
return a + b;
9-
};
10-
this.subtract = function(a, b) {
11-
return a - b;
12-
};
4+
const Mock = () => {
5+
this.add = (a, b) => a + b;
6+
this.subtract = (a, b) => a - b;
137
};
148

15-
describe('Object Decorator', function () {
9+
describe('Object Decorator', () => {
1610
it('should decorate a method', async () => {
17-
let mock = new Mock();
18-
let mockTwo = new Mock();
11+
const mock = new Mock();
12+
const mockTwo = new Mock();
1913
objectDecorator(mock, (name, method) => {
20-
switch(name) {
14+
switch (name) {
2115
case 'add':
2216
return (...args) => {
23-
let a = args[0] + 1;
24-
let b = args[1] + 1;
17+
const a = args[0] + 1;
18+
const b = args[1] + 1;
2519
return method(a, b);
2620
};
27-
break;
2821
case 'subtract':
2922
return (...args) => {
30-
let a = args[0];
31-
let b = args[1] + 1;
23+
const a = args[0];
24+
const b = args[1] + 1;
3225
return method(a, b);
3326
};
34-
break;
3527
default:
3628
return method;
3729
}

0 commit comments

Comments
 (0)