Skip to content

Commit

Permalink
Only mport used lodash methods (SBoudrias#923)
Browse files Browse the repository at this point in the history
* perf: only import used lodash methods

* fix: add missing import
  • Loading branch information
merceyz authored May 31, 2020
1 parent 2602c6e commit 0c6d41a
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 15 deletions.
7 changes: 6 additions & 1 deletion lib/objects/choice.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
'use strict';
var _ = require('lodash');
var _ = {
isString: require('lodash/isString'),
isNumber: require('lodash/isNumber'),
extend: require('lodash/extend'),
isFunction: require('lodash/isFunction')
};

/**
* Choice object
Expand Down
7 changes: 6 additions & 1 deletion lib/objects/choices.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
'use strict';
var assert = require('assert');
var _ = require('lodash');
var _ = {
isNumber: require('lodash/isNumber'),
filter: require('lodash/filter'),
map: require('lodash/map'),
find: require('lodash/find')
};
var Separator = require('./separator');
var Choice = require('./choice');

Expand Down
7 changes: 5 additions & 2 deletions lib/prompts/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
* Base prompt implementation
* Should be extended by prompt types.
*/

var _ = require('lodash');
var _ = {
assign: require('lodash/assign'),
defaults: require('lodash/defaults'),
clone: require('lodash/clone')
};
var chalk = require('chalk');
var runAsync = require('run-async');
var { filter, flatMap, share, take, takeUntil } = require('rxjs/operators');
Expand Down
6 changes: 5 additions & 1 deletion lib/prompts/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
* `list` type prompt
*/

var _ = require('lodash');
var _ = {
isArray: require('lodash/isArray'),
map: require('lodash/map'),
isString: require('lodash/isString')
};
var chalk = require('chalk');
var cliCursor = require('cli-cursor');
var figures = require('figures');
Expand Down
5 changes: 4 additions & 1 deletion lib/prompts/confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
* `confirm` type prompt
*/

var _ = require('lodash');
var _ = {
extend: require('lodash/extend'),
isBoolean: require('lodash/isBoolean')
};
var chalk = require('chalk');
var { take, takeUntil } = require('rxjs/operators');
var Base = require('./base');
Expand Down
7 changes: 6 additions & 1 deletion lib/prompts/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
* `rawlist` type prompt
*/

var _ = require('lodash');
var _ = {
uniq: require('lodash/uniq'),
isString: require('lodash/isString'),
isNumber: require('lodash/isNumber'),
findIndex: require('lodash/findIndex')
};
var chalk = require('chalk');
var { map, takeUntil } = require('rxjs/operators');
var Base = require('./base');
Expand Down
6 changes: 5 additions & 1 deletion lib/prompts/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
* `list` type prompt
*/

var _ = require('lodash');
var _ = {
isNumber: require('lodash/isNumber'),
findIndex: require('lodash/findIndex'),
isString: require('lodash/isString')
};
var chalk = require('chalk');
var figures = require('figures');
var cliCursor = require('cli-cursor');
Expand Down
6 changes: 5 additions & 1 deletion lib/prompts/rawlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
* `rawlist` type prompt
*/

var _ = require('lodash');
var _ = {
extend: require('lodash/extend'),
isNumber: require('lodash/isNumber'),
findIndex: require('lodash/findIndex')
};
var chalk = require('chalk');
var { map, takeUntil } = require('rxjs/operators');
var Base = require('./base');
Expand Down
5 changes: 4 additions & 1 deletion lib/ui/baseUI.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';
var _ = require('lodash');
var _ = {
extend: require('lodash/extend'),
omit: require('lodash/omit')
};
var MuteStream = require('mute-stream');
var readline = require('readline');

Expand Down
4 changes: 3 additions & 1 deletion lib/ui/bottom-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
var through = require('through');
var Base = require('./baseUI');
var rlUtils = require('../utils/readline');
var _ = require('lodash');
var _ = {
last: require('lodash/last')
};

class BottomBar extends Base {
constructor(opt) {
Expand Down
8 changes: 7 additions & 1 deletion lib/ui/prompt.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
'use strict';
var _ = require('lodash');
var _ = {
isPlainObject: require('lodash/isPlainObject'),
clone: require('lodash/clone'),
isArray: require('lodash/isArray'),
set: require('lodash/set'),
isFunction: require('lodash/isFunction')
};
var { defer, empty, from, of } = require('rxjs');
var { concatMap, filter, publish, reduce } = require('rxjs/operators');
var runAsync = require('run-async');
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/paginator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

var _ = require('lodash');
var _ = {
sum: require('lodash/sum'),
flatten: require('lodash/flatten')
};
var chalk = require('chalk');

/**
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/screen-manager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';
var _ = require('lodash');
var _ = {
last: require('lodash/last'),
flatten: require('lodash/flatten')
};
var util = require('./readline');
var cliWidth = require('cli-width');
var stripAnsi = require('strip-ansi');
Expand Down
4 changes: 3 additions & 1 deletion lib/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';
var _ = require('lodash');
var _ = {
isFunction: require('lodash/isFunction')
};
var { from, of } = require('rxjs');
var runAsync = require('run-async');

Expand Down

0 comments on commit 0c6d41a

Please sign in to comment.