Skip to content

Commit

Permalink
Replace lodash _.every(array) with native Array.every serverless#7747
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisVillanueva committed May 21, 2020
1 parent dd902e8 commit 55ca3b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Expand Up @@ -92,13 +92,13 @@ module.exports = {
n.name = resource.name;
if (resource.resourceId) {
n.resourceId = resource.resourceId;
if (_.every(predefinedResourceNodes, iter => iter.path !== n.path)) {
if (predefinedResourceNodes.every(iter => iter.path !== n.path)) {
predefinedResourceNodes.push(node);
}
}
if (isMethod && !node.hasMethod) {
n.hasMethod = true;
if (_.every(methodNodes, iter => iter.path !== n.path)) {
if (methodNodes.every(iter => iter.path !== n.path)) {
methodNodes.push(node);
}
}
Expand Down Expand Up @@ -162,7 +162,7 @@ module.exports = {

// if all methods have resource ID already, no need to validate resource trees
if (
_.every(this.validated.events, event =>
this.validated.events.every(event =>
_.some(predefinedResourceNodes, node => node.path === event.http.path)
)
) {
Expand Down Expand Up @@ -209,7 +209,7 @@ module.exports = {
while (iter) {
if (iter.resourceId) {
cutBranch(iter);
if (_.every(validatedTrees, t => t.path !== node.path)) {
if (validatedTrees.every(t => t.path !== node.path)) {
validatedTrees.push(iter);
}

Expand Down
5 changes: 2 additions & 3 deletions lib/plugins/aws/utils/findReferences.test.js
@@ -1,7 +1,6 @@
'use strict';

const expect = require('chai').expect;
const _ = require('lodash');
const findReferences = require('./findReferences');

describe('#findReferences()', () => {
Expand Down Expand Up @@ -52,7 +51,7 @@ describe('#findReferences()', () => {
expect(paths)
.to.be.a('Array')
.to.have.lengthOf(4);
expect(_.every(paths, path => expectedResult.includes(path))).to.equal(true);
expect(paths.every(path => expectedResult.includes(path))).to.equal(true);
});

it('should not fail with circular references', () => {
Expand Down Expand Up @@ -91,6 +90,6 @@ describe('#findReferences()', () => {
expect(paths)
.to.be.a('Array')
.to.have.lengthOf(4);
expect(_.every(paths, path => expectedResult.includes(path))).to.equal(true);
expect(paths.every(path => expectedResult.includes(path))).to.equal(true);
});
});

0 comments on commit 55ca3b8

Please sign in to comment.