UNPKG

tiny-types

Version:

A tiny library that brings Tiny Types to JavaScript and TypeScript

19 lines (16 loc) 529 B
import { ConstructorOrAbstract } from '../../types'; import { MatcherRule } from './MatcherRule'; /** * @access private */ export class MatchesObjectsWithCommonPrototype<Input_Type, Output_Type> extends MatcherRule<Input_Type, Output_Type> { constructor( private readonly pattern: ConstructorOrAbstract<Input_Type>, transformation: (v: Input_Type) => Output_Type, ) { super(transformation); } matches(value: Input_Type): boolean { return value instanceof this.pattern; } }