From bba20d8061a6d97a0d71d92bc50b98376c9a1768 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Wed, 13 Apr 2022 10:10:26 +0100 Subject: [PATCH] Remove Array.flatMap polyfill This has been supported natively since Node v11, Chrome 69, Firefox 62 and Safari 12. --- package.json | 4 +--- src/preact10-rst.ts | 3 +-- yarn.lock | 9 --------- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 8ca1bd2..0f77288 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,7 @@ "test-cjs": "yarn build-cjs && nyc mocha -r build-cjs/test/init.js build-cjs/test/*.js", "test:compat": "yarn test --preact-compat-lib preact/compat" }, - "dependencies": { - "array.prototype.flatmap": "^1.2.1" - }, + "dependencies": {}, "files": [ "build/src/**/*", "build-cjs/src/**/*", diff --git a/src/preact10-rst.ts b/src/preact10-rst.ts index 18cb8c5..7f6fd59 100644 --- a/src/preact10-rst.ts +++ b/src/preact10-rst.ts @@ -10,7 +10,6 @@ import type { NodeType, RSTNode } from 'enzyme'; import { Component, Fragment, VNode } from 'preact'; -import flatMap from 'array.prototype.flatmap'; import { childElements } from './compat.js'; import { @@ -47,7 +46,7 @@ function rstNodesFromChildren(nodes: (VNode | null)[] | null): RSTNodeTypes[] { if (!nodes) { return []; } - return flatMap(nodes, (node: VNode | null) => { + return nodes.flatMap(node => { if (node === null) { // The array of rendered children may have `null` entries as a result of // eg. conditionally rendered children where the condition was false. diff --git a/yarn.lock b/yarn.lock index b54d258..c4f5950 100644 --- a/yarn.lock +++ b/yarn.lock @@ -451,15 +451,6 @@ array.prototype.flat@^1.2.3: define-properties "^1.1.3" es-abstract "^1.17.0-next.1" -array.prototype.flatmap@^1.2.1: - version "1.2.3" - resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.2.3.tgz#1c13f84a178566042dd63de4414440db9222e443" - integrity sha512-OOEk+lkePcg+ODXIpvuU9PAryCikCJyo7GlDG1upleEpQRx6mzL9puEBkozQ5iAx20KV0l3DbyQwqciJtqe5Pg== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.0-next.1" - function-bind "^1.1.1" - asn1@~0.2.3: version "0.2.4" resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136"