array-lite

Tiny array utility which emphases functional-style and does not access the global object

Usage no npm install needed!

<script type="module">
  import arrayLite from 'https://cdn.skypack.dev/array-lite';
</script>

README

ArrayLite

Tiny array utility inspired from the builtin Array and Set methods which does not access the global object. This module was developped to produce code resilient to modification of the global object. It provides a significantly faster alternative to performing Reflect.apply on Array.prototype's methods.

  • Array.prototpe
    • concat
    • every
    • filter
    • find
    • findIndex
    • flat
    • flatMap
    • forEach
    • includes
    • indexOf
    • join
    • lastIndexOf
    • map
    • reduce
    • reduceRight
    • reverse
    • slice
    • some
  • Set.prototype
    • has
    • add
    • delete
  • Specific to array-lite:
    • mapReduce

These functions are not intended to work exactly as their builtin counterpart. Main differences are:

  • The array is passed as the first argument rather than the this argument.
  • Arguments are assumed to be present and of the correct type (i.e.: no type checking nor casting).
  • It is not possible to specify the this argument passed to callback functions (e.g.: forEach, map, filter, etc).