Problem
fromItems fails on large arrays, and fromRawParts is too verbose for simple array usage.
Overview
Given an array, there are two ways (afaik) to make an Iterator:
Using fromItems:
Iterator.fromItems(...myArray);
Using fromRawParts:
let i = 0;
Iterator.fromRawParts(
() => Option.wrap(myArray[i++]),
fixedSizeHint(myArray.size())
);
fromRawParts is a bit too verbose for simple use cases, and fromItems is the ideal happy path.
Although, fromItems fails on large arrays. When trying to unpack large arrays, you'll get the following error:
too many results to unpack
Proposal
To retain the ideal happy path usage, it would be great if there was a dedicated method for arrays.
public static fromArray<T extends defined>(items: Array<T>): Iterator<T>;
Problem
fromItemsfails on large arrays, andfromRawPartsis too verbose for simple array usage.Overview
Given an array, there are two ways (afaik) to make an
Iterator:Using
fromItems:Using
fromRawParts:fromRawPartsis a bit too verbose for simple use cases, andfromItemsis the ideal happy path.Although,
fromItemsfails on large arrays. When trying to unpack large arrays, you'll get the following error:Proposal
To retain the ideal happy path usage, it would be great if there was a dedicated method for arrays.