Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced lodash pullAllWith with Array.filter() #7861

Merged
merged 5 commits into from
Jun 26, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/plugins/aws/deploy/lib/cleanupS3Bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
.then(response => {
const stacks = findAndGroupDeployments(response, prefix, service, stage);
const stacksToKeep = stacks.slice(-stacksToKeepCount || Infinity);
const stacksToRemove = _.pullAllWith(stacks, stacksToKeep, _.isEqual);
const stacksToRemove = stacks.filter(i => !stacksToKeep.includes(i));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I see logic above is about splitting stacks into two slices stacksToKeep and stacksToRemove, and In that case I think stacksToRemove can also be constructed with slice same as stacksToKeep:

stacksToRemove = stacks.slice(0, -stacksToKeepCount || Infinity);

I think above notation will be more accurate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I focused replacing lodash functions #7747 from this issue. So, I did not see this point. Thanks

const objectsToRemove = getS3ObjectsFromStacks(stacksToRemove, prefix, service, stage);

if (objectsToRemove.length) {
Expand Down