codingjoe / codingjoe/esupgrade

Add Array.findLast/findLastIndex transformer

Open
#73 0 comments 0 reactions 0 assignees View on GitHub
newly available
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.