facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.41k stars 596 forks source link

Implement `TypedArray.prototype.toSorted` #1367

Open robik opened 1 month ago

robik commented 1 month ago

Summary

This PR implements ES2023 TypedArray.prototype.toSorted method.

See also:

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([3, 1, 2]).toSorted()" | ./bin/hermes
# >> Int8Array [ 1, 2, 3 ]