UNPKG

ix

Version:

The Interactive Extensions for JavaScript

15 lines (14 loc) 476 B
/** * Converts an existing iterable to anarray of values. * * @template TSource The type of elements in the source sequence. * @param {Iterable<TSource>} source The source sequence to convert to an array. * @returns {TSource[]} All the items from the source sequence as an array. */ export function toArray<TSource>(source: Iterable<TSource>): TSource[] { const results = [] as TSource[]; for (const item of source) { results.push(item); } return results; }