Often no-for-loop
results in something that be simplified down to Array.from
Note for even simpler cases are handled by #1713
This is an alternative to #1712 and only one of these rules should be implemented. This can been seen as superior to #1712 as it works for both arrays and iterators.
Original idea: #1712 (comment)
const result = []
for (const element of array) {
result.push(transform(element))
}
const result = []
for (const [index, element] of array.entries()) {
result[index] = transform(element)
}
const result = []
for (const [index, element] of array.entries()) {
result.push(anotherArray[index](element))
}
const result = Array.from(array, (element) => transform(element))
const result = Array.from(array, (element, index) => anotherArray[index](element))
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too