ljharb / js-traverse

MIT License
45 stars 8 forks source link

Fix cloning typed arrays #3

Closed scagood closed 4 months ago

scagood commented 1 year ago

This attempts to fix Typed Array cloning.


I had to add a node version check in the tests because:

  1. TypedArray.from was added in node 4
Image of failed test runs in actions summary image

I have pre-run all the tests already here: Name Link
Tests: node.js >= 10 https://github.com/scagood/js-traverse/actions/runs/5943582826
Tests: node.js < 10 https://github.com/scagood/js-traverse/actions/runs/5943582822
Tests: pretest/posttest https://github.com/scagood/js-traverse/actions/runs/5943582818
scagood commented 11 months ago

Tests run here:

Name Link
Tests: node.js < 10 https://github.com/scagood/js-traverse/actions/runs/6139158049
Tests: node.js >= 10 https://github.com/scagood/js-traverse/actions/runs/6139158048
Tests: pretest/posttest https://github.com/scagood/js-traverse/actions/runs/6139158047
ljharb commented 11 months ago

This seems good; I’ve got a bunch of TODOs to replace inline code with deps, so I’m thinking about the best release plan for that before merging this.

ljharb commented 8 months ago

@scagood turns out Uint8Array.from isn't always available, so I changed it to new Uint8Array; then tests revealed that copying a Typed Array would be easier using typedarray.prototype.slice; now they're failing in another place because BYTES_PER_ELEMENT is readonly.

Please fetch my latest changes and work off of those; I'll mark this PR as a draft until the tests are passing again.