js-take

A function to extract an array sequence of the first n items from another array.

Usage no npm install needed!

<script type="module">
  import jsTake from 'https://cdn.skypack.dev/js-take';
</script>

README

npm Build Status

js-take

A function to extract an array sequence of the first n items from another array, or all items if there are fewer than n. Similar to Clojure's take, but without laziness.

Installation

npm i -S js-take

Usage

import range from 'js-take';

take(2, [1, 2, 3, 4]]); // [1, 2]
take(3, [1, 2]); // [1, 2]