mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
refactor: Replace _.flatten with Array.prototype.flat (#11271)
This commit is contained in:
parent
4f7e12939c
commit
b36cdf2db6
@ -255,8 +255,9 @@ module.exports = {
|
||||
const partition = account.partition;
|
||||
|
||||
const functionNames = await this.serverless.service.getAllFunctions();
|
||||
const cloudwatchLogEvents = _.flatten(
|
||||
functionNames.map((functionName) => {
|
||||
|
||||
const cloudwatchLogEvents = functionNames
|
||||
.map((functionName) => {
|
||||
const functionObj = this.serverless.service.getFunction(functionName);
|
||||
const FunctionName = functionObj.name;
|
||||
const events = functionObj.events;
|
||||
@ -272,7 +273,7 @@ module.exports = {
|
||||
return { FunctionName, functionName, logGroupName, logSubscriptionSerialNumber };
|
||||
});
|
||||
})
|
||||
);
|
||||
.flat();
|
||||
|
||||
const cloudwatchLogEventsMap = _.groupBy(cloudwatchLogEvents, 'logGroupName');
|
||||
const logGroupNames = Object.keys(cloudwatchLogEventsMap);
|
||||
|
||||
@ -113,11 +113,10 @@ class AwsMetrics {
|
||||
|
||||
if (metrics && metrics.length > 0) {
|
||||
const getDatapointsByLabel = (Label) =>
|
||||
_.flatten(
|
||||
_.flatten(metrics)
|
||||
.filter((metric) => metric.Label === Label)
|
||||
.map((metric) => metric.Datapoints)
|
||||
);
|
||||
metrics
|
||||
.flat(2)
|
||||
.filter((metric) => metric.Label === Label)
|
||||
.map((metric) => metric.Datapoints);
|
||||
|
||||
const invocationsCount = _.sumBy(getDatapointsByLabel('Invocations'), 'Sum');
|
||||
const throttlesCount = _.sumBy(getDatapointsByLabel('Throttles'), 'Sum');
|
||||
|
||||
@ -43,7 +43,10 @@ module.exports = {
|
||||
if (
|
||||
_.isObject(apiKeyDefinition) &&
|
||||
Array.isArray(usagePlan) &&
|
||||
_.flatten(usagePlan.map((item) => Object.keys(item))).includes(name)
|
||||
usagePlan
|
||||
.map((item) => Object.keys(item))
|
||||
.flat()
|
||||
.includes(name)
|
||||
) {
|
||||
keyNumber = 0;
|
||||
apiKeyDefinition[name].forEach((key) => {
|
||||
|
||||
@ -6,8 +6,8 @@ const pickWebsocketsTemplatePart = require('./pick-websockets-template-part');
|
||||
|
||||
module.exports = {
|
||||
compileDeployment() {
|
||||
const dependentResourceIds = _.flatten(
|
||||
this.validated.events.map((event) => {
|
||||
const dependentResourceIds = this.validated.events
|
||||
.map((event) => {
|
||||
const result = [];
|
||||
if (event.routeResponseSelectionExpression) {
|
||||
result.push(this.provider.naming.getWebsocketsRouteResponseLogicalId(event.route));
|
||||
@ -15,7 +15,8 @@ module.exports = {
|
||||
result.push(this.provider.naming.getWebsocketsRouteLogicalId(event.route));
|
||||
return result;
|
||||
})
|
||||
);
|
||||
.flat();
|
||||
|
||||
const websocketsTemplatePart = pickWebsocketsTemplatePart(
|
||||
this.serverless.service.provider.compiledCloudFormationTemplate,
|
||||
this.provider.naming.getWebsocketsApiLogicalId()
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports = (stacks, prefix, service, stage) =>
|
||||
_.flatten(stacks).map((entry) => ({
|
||||
stacks.flat().map((entry) => ({
|
||||
Key: `${prefix}/${service}/${stage}/${entry.directory}/${entry.file}`,
|
||||
}));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user