Skip to content

Conversation

@sosukesuzuki
Copy link
Contributor

Description

Address #13142 (comment)

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

return object.at
? object.at(index)
: object[index < 0 ? object.length + index : index];
if (Array.isArray(object)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am wondering if we should include brand checking for safety...

Copy link
Member

@fisker fisker Mar 25, 2023

Choose a reason for hiding this comment

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

.at not only available on array, but we can check array and string only for now. We probably won't use TypedArray, and the transform only works for files (not packages) now.

if (!file.startsWith(SOURCE_DIR)) {

@fisker fisker changed the title Fix Array.prototype.at transform Transform .at to property access to improve performance Mar 25, 2023
@fisker
Copy link
Member

fisker commented Mar 25, 2023

Change this back to at and move comment here.

@sosukesuzuki sosukesuzuki merged commit 00e59ed into prettier:next Mar 25, 2023
@sosukesuzuki sosukesuzuki deleted the fix-at-transform branch March 25, 2023 19:14
medikoo pushed a commit to medikoo/prettier-elastic that referenced this pull request Feb 13, 2024
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

Successfully merging this pull request may close these issues.

2 participants