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

Exception: TypeError: data.map(...).flat is not a function #14

Open
eddex opened this issue May 2, 2020 · 2 comments
Open

Exception: TypeError: data.map(...).flat is not a function #14

eddex opened this issue May 2, 2020 · 2 comments

Comments

@eddex
Copy link

eddex commented May 2, 2020

Environment
coverage-viewer: 0.4.1
OS: Windows 10
shell: PowerShell
npm: 6.13.0
node: v10.16.3

Install output

> npm i -g coverage-viewer

npm WARN deprecated [email protected]: This method has been renamed to "flat" - please use `array.prototype.flat` instead
C:\Users\larry\AppData\Roaming\npm\coverage-viewer -> C:\Users\larry\AppData\Roaming\npm\node_modules\coverage-viewer\cli.js
+ [email protected]
added 108 packages from 65 contributors in 10.354s

Exception

> coverage-viewer "./tests/coverage.json" -s "./src" -o "./viewer"

C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\statistics.js:1
const getAllFiles = data => data.map(project => project.files).flat()
                                                               ^

TypeError: data.map(...).flat is not a function
    at getAllFiles (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\statistics.js:1:64)
    at exports.getFileStats.data (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\statistics.js:93:17)
    at renderFile (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\render.js:34:21)
    at files.map.file (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\render.js:52:13)
    at Array.map (<anonymous>)
    at Object.exports.renderFiles (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\render.js:49:16)
    at fs.readFile (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\render.js:73:13)
    at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
@eddex eddex changed the title Exception Exception: TypeError: data.map(...).flat is not a function May 2, 2020
@eddex
Copy link
Author

eddex commented May 2, 2020

Seems to be similar to #10

@derrickwilliams
Copy link

Before this commit the array.prototype.flatten module was used to shim the flatten method on array.prototype. But now the native array.prototype.flat method is being used. However, array.prototype.flat is only available in Node 11+.

Along with updating the call to .flat(), the array.prototype.flat shim should be used for backwards compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants