codingjoe / codingjoe/esupgrade
Add Array.findLast/findLastIndex transformer
- Dominant language
- JavaScript
- Stars
- 13
- Forks
- 2
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 6
Description
## Feature Request
Add a transformer to convert reverse-then-find patterns to findLast()/findLastIndex().
### Baseline Status
- **Status:** Newly Available (2023)
- **Feature:** Array.prototype.findLast(), Array.prototype.findLastIndex()
### Transformations
```js
// Before
arr.slice().reverse().find(predicate)
// After
arr.findLast(predicate)
```
```js
// Before
// Manual reverse iteration
// After
arr.findLastIndex(predicate)
```
### Priority
Medium - More efficient than slice + reverse.
### Note
Only available with `--baseline newly-available` flag.
### References
- MDN (findLast): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast
- MDN (findLastIndex): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex
- Catalog: See BASELINE_TRANSFORMERS.md #4 (Newly Available)
Contributor guide
Assessment
This issue has not been assessed yet.