UNPKG

@tsdotnet/collection-base

Version:

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/tsdotnet/collection-base/blob/master/LICENSE) ![npm-publish](https://github.com/tsdotnet/collection-base/workflows/npm-publish/badge.svg) [![npm ve

27 lines (26 loc) 926 B
/*! * @author electricessence / https://github.com/electricessence/ * @license MIT */ import { SelectorWithIndex } from '@tsdotnet/common-interfaces'; /** * Some iterables/generators can be infinite. * This class is provided as a base for implementing any iterable including endless ones. */ export default abstract class IterableBase<T> implements Iterable<T> { protected constructor(); [Symbol.iterator](): Iterator<T>; /** * Returns an iterable mapped by the provided selector. * @param {SelectorWithIndex<T, TResult>} selector * @return {Iterable<TResult>} */ map<TResult>(selector: SelectorWithIndex<T, TResult>): Iterable<TResult>; /** * Override to define the actual iterator. * The [Symbol.iterator] should not be overridden as it handles version tracking. * @returns {Iterator} * @private */ protected abstract _getIterator(): Iterator<T>; }