/** * @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 { OperatorFunction } from "rxjs"; import { filter } from "rxjs/operators"; export function instanceOf( ctor: new (...args: any[]) => R ): OperatorFunction; export function instanceOf< T, R extends { [key: string]: new (...args: any[]) => T } >(ctors: R): OperatorFunction>; export function instanceOf(arg: any): OperatorFunction { return typeof arg === "function" ? filter((value) => value instanceof arg) : filter((value) => Object.keys(arg).some((key) => value instanceof arg[key]) ); }