import ParserError from "../parserError" ; import { ParseFn , ParserInput } from "../parserFn" ; import { isNil } from "../util" ; param fn returns export default function withObject < T , O = Record < string , ParserInput > > ( fn ) { return ( x ) => { if ( isNil ( x ) ) { throw new ParserError ( "Object" , typeof x ) ; } if ( Object . prototype . toString . call ( x ) !== "[object Object]" ) { throw new ParserError ( "Object" , typeof x ) ; } return fn ( x ) ; } ; }