From 59f63b2e9e8a856cd6ef8038bfd8a444c3414944 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Tue, 23 Nov 2021 18:17:08 +0100 Subject: [PATCH] chore!: drop support for Node 10 --- .github/workflows/workflow.yml | 6 +++--- package.json | 2 +- src/operations.js | 18 +++++++----------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index ae11bf0..52ea0f7 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -13,12 +13,12 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - node-version: ['10.18.0', '*'] + node-version: ['12.20.0', '*'] exclude: - os: macOS-latest - node-version: '10.18.0' + node-version: '12.20.0' - os: windows-latest - node-version: '10.18.0' + node-version: '12.20.0' fail-fast: false steps: - name: Git checkout diff --git a/package.json b/package.json index 6f99511..0691d8c 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "webpack-cli": "^4.5.0" }, "engines": { - "node": ">=10.18.0" + "node": "^12.20.0 || ^14.14.0 || >=16.0.0" }, "ava": { "files": [ diff --git a/src/operations.js b/src/operations.js index e947867..3a3ca8a 100644 --- a/src/operations.js +++ b/src/operations.js @@ -3,17 +3,13 @@ const omit = require('omit.js').default // Retrieve all OpenAPI operations const getOperations = function () { - // TODO: switch to Array.flat() once we drop support for Node.js < 11.0.0 - // eslint-disable-next-line unicorn/prefer-spread - return [].concat( - ...Object.entries(paths).map(([path, pathItem]) => { - const operations = omit(pathItem, ['parameters']) - return Object.entries(operations).map(([method, operation]) => { - const parameters = getParameters(pathItem.parameters, operation.parameters) - return { ...operation, verb: method, path, parameters } - }) - }), - ) + return Object.entries(paths).flatMap(([path, pathItem]) => { + const operations = omit(pathItem, ['parameters']) + return Object.entries(operations).map(([method, operation]) => { + const parameters = getParameters(pathItem.parameters, operation.parameters) + return { ...operation, verb: method, path, parameters } + }) + }) } const getParameters = function (pathParameters = [], operationParameters = []) {