/** * @license Use of this source code is governed by an MIT-style license that * can be found in the LICENSE file at https://github.com/cartant/rxjs-etc */ import { Observable, OperatorFunction, Subject } from "rxjs"; import { bucketBy } from "./bucketBy"; export function splitBy( predicate: (value: T, index: number) => value is S, subjectSelector?: () => Subject ): OperatorFunction, Observable>]>; export function splitBy( predicate: (value: T, index: number) => boolean, subjectSelector?: () => Subject ): OperatorFunction, Observable]>; export function splitBy( predicate: (value: T, index: number) => boolean, subjectSelector: () => Subject = () => new Subject() ): OperatorFunction, Observable]> { return bucketBy( 2, (value, index) => (predicate(value, index) ? 0 : 1), subjectSelector ) as OperatorFunction, Observable]>; }