Skip to content

Commit

Permalink
Require only part of lodash to decrease global package size
Browse files Browse the repository at this point in the history
  • Loading branch information
kraynel committed Jan 6, 2020
1 parent 45c01b7 commit 3c1de62
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
6 changes: 3 additions & 3 deletions configure/request-next.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

var core = require('../'),
isArray = require('lodash/isArray'),
isFunction = require('lodash/isFunction'),
isObjectLike = require('lodash/isObjectLike');
isArray = Array.isArray,
isFunction = require('lodash.isfunction'),
isObjectLike = require('lodash.isobjectlike');


module.exports = function (options) {
Expand Down
6 changes: 3 additions & 3 deletions configure/request2.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

var core = require('../'),
isArray = require('lodash/isArray'),
isFunction = require('lodash/isFunction'),
isObjectLike = require('lodash/isObjectLike');
isArray = Array.isArray,
isFunction = require('lodash.isfunction'),
isObjectLike = require('lodash.isobjectlike');


module.exports = function (options) {
Expand Down
8 changes: 4 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var chalk = require('chalk');
var rimraf = require('rimraf');
var coveralls = require('gulp-coveralls');
var eslint = require('gulp-eslint');
var _ = require('lodash');
var flatten = require('lodash.flatten');

var chai = require('chai');
global.expect = chai.expect;
Expand All @@ -27,7 +27,7 @@ gulp.task('dev', ['watch', 'validate']);

gulp.task('watch', function () {

gulp.watch(_.flatten([
gulp.watch(flatten([
paths.libJsFiles,
paths.specFiles,
paths.fixtureFiles,
Expand All @@ -36,7 +36,7 @@ gulp.task('watch', function () {
'validate'
]);

gulp.watch(_.flatten([
gulp.watch(flatten([
paths.eslintrc
]), [
'lint'
Expand All @@ -50,7 +50,7 @@ gulp.task('validate', function (done) {

gulp.task('lint', function () {

return gulp.src(_.flatten([
return gulp.src(flatten([
paths.libJsFiles,
paths.gulpfile,
paths.specFiles,
Expand Down
8 changes: 4 additions & 4 deletions lib/plumbing.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

var errors = require('./errors.js'),
isFunction = require('lodash/isFunction'),
isObjectLike = require('lodash/isObjectLike'),
isString = require('lodash/isString'),
isUndefined = require('lodash/isUndefined');
isFunction = require('lodash.isfunction'),
isObjectLike = require('lodash.isobjectlike'),
isString = require('lodash.isstring'),
isUndefined = require('lodash.isundefined');


module.exports = function (options) {
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
"node": ">=0.10.0"
},
"dependencies": {
"lodash": "^4.17.15"
"lodash.isfunction": "^3.0.9",
"lodash.isobjectlike": "^4.0.0",
"lodash.isstring": "^4.0.1",
"lodash.isundefined": "^3.0.1"
},
"peerDependencies": {
"request": "^2.34"
Expand All @@ -50,6 +53,7 @@
"gulp-eslint": "~2.1.0",
"gulp-istanbul": "~1.0.0",
"gulp-mocha": "~2.2.0",
"lodash.flatten": "^4.4.0",
"node-version": "~1.0.0",
"publish-please": "~2.4.1",
"request": "^2.34.0",
Expand Down
12 changes: 6 additions & 6 deletions test/spec/plumbing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var _ = require('lodash'),
var isFunction = require('lodash.isfunction'),
Bluebird = require('bluebird'),
errors = require('../../errors'),
plumbing = require('../../');
Expand Down Expand Up @@ -62,8 +62,8 @@ describe('Promise-Core\'s Plumbing', function () {

pl.init.call(context, {});

expect(_.isFunction(context._rp_promise.then)).to.eql(true);
expect(_.isFunction(context._rp_resolve)).to.eql(true);
expect(isFunction(context._rp_promise.then)).to.eql(true);
expect(isFunction(context._rp_resolve)).to.eql(true);

context._rp_resolve();

Expand All @@ -82,8 +82,8 @@ describe('Promise-Core\'s Plumbing', function () {
var context = {};
pl.init.call(context, {});

expect(_.isFunction(context._rp_promise.then)).to.eql(true);
expect(_.isFunction(context._rp_reject)).to.eql(true);
expect(isFunction(context._rp_promise.then)).to.eql(true);
expect(isFunction(context._rp_reject)).to.eql(true);

context._rp_reject(new Error('Rejected by test case'));

Expand Down Expand Up @@ -134,7 +134,7 @@ describe('Promise-Core\'s Plumbing', function () {
var context = {};
pl.init.call(context, {});

expect(_.isFunction(context._rp_options.callback)).to.eql(true);
expect(isFunction(context._rp_options.callback)).to.eql(true);
delete context._rp_options.callback;

expect(context._rp_options).to.eql({
Expand Down

0 comments on commit 3c1de62

Please sign in to comment.