Skip to content

Commit

Permalink
chore: directly import only needed lodash modules (#1271)
Browse files Browse the repository at this point in the history
instead of `import _ from 'lodash';` we import
```import filter from 'lodash/filter.js';
import map from 'lodash/map.js';
```

This reduces the bundle size and will help bundlers with tree shaking.
  • Loading branch information
lukecotter authored Jul 28, 2023
1 parent 88d1091 commit 790b805
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/inquirer/lib/objects/choices.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import assert from 'node:assert';
import _ from 'lodash';
import filter from 'lodash/filter.js';
import map from 'lodash/map.js';

import Separator from './separator.js';
import Choice from './choice.js';
Expand Down Expand Up @@ -72,7 +73,7 @@ export default class Choices {
* @return {Array} Matching choices or empty array
*/
where(whereClause) {
return _.filter(this.realChoices, whereClause);
return filter(this.realChoices, whereClause);
}

/**
Expand All @@ -81,7 +82,7 @@ export default class Choices {
* @return {Array} Selected properties
*/
pluck(propertyName) {
return _.map(this.realChoices, propertyName);
return map(this.realChoices, propertyName);
}

// Expose usual Array methods
Expand Down

0 comments on commit 790b805

Please sign in to comment.