UNPKG

fast-check

Version:

Property based testing framework for JavaScript (like QuickCheck)

21 lines (20 loc) 463 B
class LazyIterableIterator { constructor(producer) { this.producer = producer; } [Symbol.iterator]() { if (this.it === undefined) { this.it = this.producer(); } return this.it; } next() { if (this.it === undefined) { this.it = this.producer(); } return this.it.next(); } } export function makeLazy(producer) { return new LazyIterableIterator(producer); }