Variable: next()
const
next: <Value
>(iterable
) => [Optional
<Value
>,Iterable
<Value
>]
Defined in: optionals.d.ts:308
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
Value
Parameters
iterable
Iterable
<Value
>
Returns
[Optional
<Value
>, Iterable
<Value
>]
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