Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1x 1x | /**
* Converts all elements of an {@link Iterable} to an {@link Array}.
*
* @example
* Convert {@link Iterable} to {@link Array}
* ```ts
* const iterable = [1, 2, 3];
* const array = toArray(iterable);
* console.log(array); // [1, 2, 3]
* ```
*
* @typeParam T - the {@link Iterable} value type
* @param iterable - the {@link Iterable} to convert
* @returns an {@link Array} consisting of all elements
*/
export const toArray = <T>(iterable: Iterable<T>): T[] => {
return Array.from(iterable);
};
|