dist/async-iterable/operators.js
/** Take and yield items in an iterable until the passed predicate fails, then abort the sequence */
Take and yield items in an iterable until the passed predicate fails, then abort the sequence
Take and yield items in an iterable until the passed predicate fails then abort the sequence
function takeWhile(predicate) {
    return function (iterable) {
        return __asyncGenerator(this, arguments, function* () {
            var e_15, _a;
            let i = 0;
            try {
                for (var iterable_13 = __asyncValues(iterable), iterable_13_1; iterable_13_1 = yield __await(iterable_13.next()), !iterable_13_1.done;) {
                    const item = iterable_13_1.value;
                    if (!(yield __await(Promise.resolve(predicate(item, i))))) {
                        break;
                    }
                    yield yield __await(item);
                    i = i + 1;
                }
            }
            catch (e_15_1) { e_15 = { error: e_15_1 }; }
            finally {
                try {
                    if (iterable_13_1 && !iterable_13_1.done && (_a = iterable_13.return)) yield __await(_a.call(iterable_13));
                }
                finally { if (e_15) throw e_15.error; }
            }
        });
    };
}
function takeWhile ( predicate ) { return function ( iterable ) { return __asyncGenerator ( this , arguments , function * ( ) { var e_15 , _a ; let i = 0 ; try { for ( var iterable_13 = __asyncValues ( iterable ) , iterable_13_1 ; iterable_13_1 = yield __await ( iterable_13 . next ( ) ) , ! iterable_13_1 . done ; ) { const item = iterable_13_1 . value ; if ( ! ( yield __await ( Promise . resolve ( predicate ( item , i ) ) ) ) ) { break ; } yield yield __await ( item ) ; i = i + 1 ; } } catch ( e_15_1 ) { e_15 = { error : e_15_1 } ; } finally { try { if ( iterable_13_1 && ! iterable_13_1 . done && ( _a = iterable_13 . return ) ) yield __await ( _a . call ( iterable_13 ) ) ; } finally { if ( e_15 ) throw e_15 . error ; } } } ) ; } ; }
Take and yield items in an iterable until the passed predicate fails, then abort the sequence
Take and yield items in an iterable until the passed predicate fails then abort the sequence