import { SafeUint } from 'ts-data-forge'; import { type DropInitialValueOperator } from '../types/index.mjs'; /** * Emits values from the source observable while the predicate returns true. * Completes immediately when the predicate returns false. * * @template A - The type of values from the source * @param predicate - Function to test each value * @returns An operator that takes values while the predicate is true * * @example * ```ts * // Timeline: * // * // num$ 1 2 3 4 5 6 1 2 (ignored) * // taken$ 1 2 3 4 | (completes) * // * // Explanation: * // - takeWhile emits values while the predicate returns true * // - Completes immediately when the predicate returns false * // - No further values are emitted after completion * * const num$ = source(); * * const taken$ = num$.pipe(takeWhile((x) => x < 5)); * * const valueHistory: number[] = []; * * taken$.subscribe((x) => { * valueHistory.push(x); * }); * * num$.next(1); // logs: 1 * * assert.deepStrictEqual(valueHistory, [1]); * * num$.next(2); // logs: 2 * * num$.next(3); // logs: 3 * * num$.next(4); // logs: 4 * * assert.deepStrictEqual(valueHistory, [1, 2, 3, 4]); * * num$.next(5); // nothing logged (completes) * * assert.deepStrictEqual(valueHistory, [1, 2, 3, 4]); * * num$.next(6); // nothing logged (already completed) * * assert.deepStrictEqual(valueHistory, [1, 2, 3, 4]); * * num$.next(1); // logs: 1 * * assert.deepStrictEqual(valueHistory, [1, 2, 3, 4]); * ``` */ export declare const takeWhile: (predicate: (value: A, index: SafeUint | -1) => boolean) => DropInitialValueOperator; //# sourceMappingURL=take-while.d.mts.map