Skip to content

Commit eb68e9a

Browse files
committed
perf: reduce package bundle size
1 parent 1493c81 commit eb68e9a

File tree

7 files changed

+23
-24
lines changed

7 files changed

+23
-24
lines changed

lib/commander.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ commands.push('sentinel');
3636
* @public
3737
*/
3838
Commander.prototype.getBuiltinCommands = function () {
39-
return _.clone(commands);
39+
return commands.slice(0);
4040
};
4141

4242
/**

lib/redis.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ Redis.prototype.end = function () {
366366
* @public
367367
*/
368368
Redis.prototype.duplicate = function (override) {
369-
return new Redis(Object.assign(_.cloneDeep(this.options), override || {}));
369+
return new Redis(Object.assign({}, this.options, override || {}));
370370
};
371371

372372
/**

lib/utils/lodash.js

-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ exports.pick = require('lodash.pick');
55
exports.defaults = require('lodash.defaults');
66
exports.noop = function () {};
77
exports.difference = require('lodash.difference');
8-
exports.clone = require('lodash.clone');
98
exports.sample = require('lodash.sample');
109
exports.flatten = require('lodash.flatten');
11-
exports.bind = require('lodash.bind');
1210
exports.isEmpty = require('lodash.isempty');
1311
exports.values = require('lodash.values');
1412
exports.shuffle = require('lodash.shuffle');
1513
exports.partial = require('lodash.partial');
16-
exports.cloneDeep = require('lodash.clonedeep');

package-lock.json

-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"test:cov": "NODE_ENV=test node ./node_modules/istanbul/lib/cli.js cover --preserve-comments ./node_modules/mocha/bin/_mocha -- -r ts-node/register -R spec --exit",
1313
"build": "rm -rf built && tsc",
1414
"generate-docs": "jsdoc2md lib/redis.js lib/cluster/index.js lib/commander.js > API.md",
15-
"prepublish": "npm run build && npm test",
15+
"prepublishOnly": "npm run build && npm test",
1616
"bench": "matcha benchmarks/*.js"
1717
},
1818
"repository": {
@@ -32,9 +32,6 @@
3232
"debug": "^3.1.0",
3333
"denque": "^1.1.0",
3434
"flexbuffer": "0.0.6",
35-
"lodash.bind": "^4.2.1",
36-
"lodash.clone": "^4.5.0",
37-
"lodash.clonedeep": "^4.5.0",
3835
"lodash.defaults": "^4.2.0",
3936
"lodash.difference": "^4.5.0",
4037
"lodash.flatten": "^4.4.0",

test/functional/duplicate.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
describe('duplicate', () => {
4+
it('clone the options', () => {
5+
var redis = new Redis()
6+
var duplicatedRedis = redis.duplicate()
7+
redis.options.port = 1234
8+
expect(duplicatedRedis.options.port).to.eql(6379)
9+
});
10+
});

test/unit/commander.js

+10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
var Commander = require('../../lib/commander');
44

55
describe('Commander', function () {
6+
describe('#getBuiltinCommands()', () => {
7+
it('returns a new copy of commands', () => {
8+
const c = new Commander()
9+
const commands = c.getBuiltinCommands()
10+
commands.unshift('abc')
11+
const commandsNew = c.getBuiltinCommands()
12+
expect(commands.slice(1)).to.eql(commandsNew)
13+
})
14+
})
15+
616
it('should pass the correct arguments', function () {
717
stub(Commander.prototype, 'sendCommand', function (command) {
818
return command;

0 commit comments

Comments
 (0)