hermes
hermes copied to clipboard
Implement `TypedArray.prototype.with`
Summary
This PR implements ES2023 TypedArray.prototype.with method. This is a follow-up of PR #1286 which added with method on standard Array prototype.
See also:
- PR for
TypedArray.prototype.toReversed: #1366 - PR for
TypedArray.prototype.toSorted: #1367
I am creating separate PRs for each method in case there are any suggestions or change requests from your side, so that PRs are more independent.
Test Plan
Code is annotated with algorithm steps from EcmaScript specification for easier verification and maintenance. I also added tests to verify that methods work as intended. There might be some more edge cases that might be covered based on your experience.
$ echo "new Int8Array([0]).with(0, 5)" | ./bin/hermes
# >> Int8Array [ 5 ]
Superseded by #5601.