Skip to main content

Function: from()

from<ElementType, ResolvableType>(value: ResolvableType): IterableResolved<ResolvableType>

Resolves an iterable from an iterable or iterator-like object.

Type Parameters

Type Parameter
ElementType
ResolvableType extends IterableResolvable<ElementType>

Parameters

ParameterTypeDescription
valueResolvableTypeThe value to convert to an iterator.

Returns

IterableResolved<ResolvableType>

Example

import { from } from '@sapphire/iterator-utilities';

const iterable = from([1, 2, 3, 4, 5]);
for (const element of iterable) {
console.log(element);
// Output: 1, 2, 3, 4, 5
}

Defined in

projects/utilities/packages/iterator-utilities/src/lib/from.ts:17