LazyIterable
An iterable object that lazily implements many Array.prototype
members.
{ 1 2 3} const lazy = generator const array = lazy console // [2, 4, 6]
The advantage that LazyIterable
has over Array
is that the its source is
evaluated as late as possible.
let iterated = false { iterated = true 1 2 3} let lazy = generatorconsole // false lazy = lazyconsole // false const array = lazyconsole // true
LazyIterable
implements most of the read-only members of Array.prototype
as
well as a couple in-place members in a read-only fashion.
- Lazy members
concat
entries
filter
keys
map
reverse
slice
sort
values
- Eager members:
length
every
find
findIndex
forEach
includes
indexOf
itemAt
join
reduce
reduceRight
some
toArray
reverse
and sort
each return a new LazyIterable
whereas Array
performs
the action in-place.
Read more in the API Documentation.