π Fast and small implementations of JS loops
micro-loops is "fast and small" because it ignores many details and possible errors. Test it before using it in production.
yarn add micro-loops
import { map } from "micro-loops"
map({ arr: [1, 2, 3], fn: e => e * 2 })
- arr: The array to iterate over
- fn: The function invoked per iteration
- len?: The length of the array (optional)
Returns the new array.
- arr: The array to iterate over
- fn: The function invoked per iteration
- len?: The length of the array (optional)
Returns the new array.
Does not pre-allocate the new array, can be either slower or faster, depending on your use case
- arr: The array to iterate over
- fn: The function invoked per iteration, returns
true
orfalse
- len?: The length of the array (optional)
Returns the index of the found element or undefined.
- arr: The array to iterate over
- fn: The function invoked per iteration, returns
true
orfalse
- len?: The length of the array (optional)
Returns the element or undefined.
- arr: The array to iterate over
- fn: The function invoked per iteration, returns
true
orfalse
- len?: The length of the array (optional)
Returns the filtered array.