Function: next()
next<
Value
>(iterable
): [Optional
<Value
>,Iterable
<Value
,any
,any
>]
Returns a pair of iterables. If iterable
is empty, then both of the
returned iterables are empty. Otherwise, the first iterable contains the
first value of iterable
and the second iterable contains the rest of the
values of iterable
. The second iterable can only be iterated once.
Type Parameters
• Value
Parameters
iterable
Iterable
<Value
, any
, any
>
Returns
[Optional
<Value
>, Iterable
<Value
, any
, any
>]
Example
import { count, get, next } from 'lfi'
const [first, rest] = next([`sloth`, `lazy`, `sleep`])
console.log(get(first))
//=> sloth
console.log([...rest])
//=> [ 'lazy', 'sleep' ]
const [first2, rest2] = next([])
console.log(count(first2))
//=> 0
console.log(count(rest2))
//=> 0
Since
v0.0.1