js-head

Get the first element in iterable collection

Usage no npm install needed!

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

README

js-head

Get the first element in iterable collection

A common way of getting the first element in a collection which implements Iterable protocol.

Installation

$ npm i js-head

Usage

import head from 'js-head';

head([1, 2, 3]); // 1
head(new Set([1, 2, 3])); // 1
head(Immutable.List([1, 2, 3])); // 1