Skip to content

imedadel/micro-loops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

micro-loops

πŸš… 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.

Install

yarn add micro-loops

Usage

import { map } from "micro-loops"

map({ arr: [1, 2, 3], fn: e => e * 2 })

API

map({arr, fn, len})

  • arr: The array to iterate over
  • fn: The function invoked per iteration
  • len?: The length of the array (optional)

Returns the new array.

mapna({arr, fn, len})

  • 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

find({arr, fn, len})

  • arr: The array to iterate over
  • fn: The function invoked per iteration, returns true or false
  • len?: The length of the array (optional)

Returns the index of the found element or undefined.

findel({arr, fn, len})

  • arr: The array to iterate over
  • fn: The function invoked per iteration, returns true or false
  • len?: The length of the array (optional)

Returns the element or undefined.

filter({arr, fn, len})

  • arr: The array to iterate over
  • fn: The function invoked per iteration, returns true or false
  • len?: The length of the array (optional)

Returns the filtered array.

About

πŸš… Fast and small (228B) implementations of JS loops

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published