@nevware21/ts-utils
    Preparing search index...

    Function iterToArray

    • Materializes an iterator / iterable / array-like value as an array. The value is processed like for...of (and iterForOf), so an iterable (including a string or an array) is processed using its iterator (a string by its code points on a runtime which supports Symbol.iterator) and an iterator which is not iterable is used as-is. Unlike for...of (and iterForOf, which only also processes an array) any other array-like which is not iterable (eg. { length: 2, 0: "a", 1: "b" }, or arguments or a string on a runtime without Symbol.iterator) is processed using its indexes, and (like iterForOf) a Map or Set which is not iterable (eg. on IE 11) returns its [key, value] entries / values.

      Type Parameters

      • T
      • R = T

      Parameters

      • iter: Iterator<T, any, undefined> | Iterable<T> | ArrayLike<T>
      • OptionalmapFn: IterMapCallbackFn<T, R>
      • OptionalthisArg: any

      Returns R[]

      0.15.0

      TypeError when the value's [Symbol.iterator] isn't null, undefined or a function, when its [Symbol.iterator]() doesn't return an iterator, or the iterator's next() returns a value which is not an object

      iterToArray(createRangeIterator(1, 3)); // [1, 2, 3]
      iterToArray([10, 20, 30], (value, idx) => value + idx); // [10, 21, 32]