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

Replace lodash _.first with native array[0] #7816

Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
let keyNumber = 0;
this.serverless.service.provider.apiKeys.forEach(apiKeyDefinition => {
// if multiple API key types are used
const name = _.first(Object.keys(apiKeyDefinition));
const name = Object.keys(apiKeyDefinition)[0];
if (
_.isObject(apiKeyDefinition) &&
_.includes(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const _ = require('lodash');
const expect = require('chai').expect;
const AwsCompileApigEvents = require('../index');
const Serverless = require('../../../../../../../Serverless');
Expand Down Expand Up @@ -172,7 +171,7 @@ describe('#compileApiKeys()', () => {
],
};
awsCompileApigEvents.serverless.service.provider.apiKeys.forEach(plan => {
const planName = _.first(Object.keys(plan)); // free || paid
const planName = Object.keys(plan)[0]; // free || paid
const apiKeys = expectedApiKeys[planName];
apiKeys.forEach((apiKey, index) => {
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ module.exports = {

this.serverless.service.provider.apiKeys.forEach(apiKeyDefinition => {
// if multiple API key types are used
const apiKey = _.first(_.entries(apiKeyDefinition));
const name = _.first(apiKey);
const apiKey = _.entries(apiKeyDefinition)[0];
const name = apiKey[0];
const value = _.last(apiKey);
if (
this.apiGatewayUsagePlanNames.length > 0 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('#compileUsagePlanKeys()', () => {

return awsCompileApigEvents.compileUsagePlanKeys().then(() => {
awsCompileApigEvents.serverless.service.provider.apiKeys.forEach(plan => {
const planName = _.first(Object.keys(plan)); // free || paid
const planName = Object.keys(plan)[0]; // free || paid
const apiKeys = plan[planName];
apiKeys.forEach((apiKey, index) => {
expect(
Expand Down