• Creates a new instance of the passed in ctor with the Enumerable as input. Useful for custom iterables.

    Type Parameters

    • TSource
    • TResult

    Parameters

    • src: Iterable<TSource>

      The source Iterable.

    • ctor: new (src: Iterable<TSource>) => TResult

      The constructor function to create the result.

    Returns TResult

    A new instance of the passed in ctor with the enumerable passed as input.

    class MyCustomEnumerable<T> extends Enumerable<T> {
    public foo(): void {
    console.log('hello');
    }
    }

    const items = [1, 2, 3];

    const asCustom = from(items).to(MyCustomEnumerable); // asCustom is now a MyCustomEnumerable instance.

    TSource The type of the source iterable.

    TResult The type of the returned object.