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

Implement TypedArray.prototype.toReversed #1366

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robik
Copy link
Contributor

@robik robik commented Mar 29, 2024

Summary

This PR implements ES2023 TypedArray.prototype.toReversed method. This is a follow-up of PR #1286 which added with method on standard Array prototype.

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

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Mar 29, 2024
@facebook-github-bot
Copy link
Contributor

@dannysu has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@dannysu dannysu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! A minor comment on something caught by our internal linter.

double from = len - k - 1;

// 6b. Let Pk be ! ToString(𝔽(k)).
kHandle = HermesValue::encodeTrustedNumberValue(k);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kHandle is unused other than being assigned here. Could you please remove it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants