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

    Function iterMap

    • Creates a lazily mapped iterable iterator. 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. A Map or Set which is not iterable (eg. on IE 11) is processed using a copy of its [key, value] entries / values, which is made when this is called (rather than when the first value is read), so a value added after that is not processed. Like the native iterator helpers a TypeError is thrown when the source's next() returns a value which is not an object, the source is closed (by calling its return() with no arguments) when the callbackfn throws, it is done once the source or the callbackfn throws, its return() only closes the source when it isn't already done, and a TypeError is thrown when its next() or return() is called by the callbackfn.

      Type Parameters

      • T
      • R = T

      Parameters

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

      Returns IterableIterator<R>

      TypeError when it is created if the value's [Symbol.iterator] isn't null, undefined or a function, from its next() (the iterator isn't checked when it is created) when the value's [Symbol.iterator]() doesn't return an iterator or the source's next() returns a value which is not an object, from its return() when the source's return() returns a value which is not an object, and when its next() or return() is called by the callbackfn

      0.15.0

      const mapped = iterMap([1, 2, 3], (value) => value * 10);
      iterToArray(mapped); // [10, 20, 30]