import { Mock } from './mock/mock' ; export type Property = string | symbol ; export interface ProxyTraps { /**
     * Called when accessing any property on an object, except for
     * `.call`, `.apply` and `.bind`.
     */ property : ( property : Property ) => unknown ; example example example example apply : ( args : any [ ] ) => unknown ; example example ownKeys : ( ) => Property [ ] ; } export const createProxy = < T > ( traps ) : Mock < T > => new Proxy ( ( ) => { } , { get : ( target , prop ) => { if ( prop === 'bind' ) { return ( thisArg , ... args ) => ( ... moreArgs ) => traps . apply ( [ ... args , ... moreArgs ] ) ; } if ( prop === 'apply' ) { return ( thisArg , args ) => traps . apply ( args || [ ] ) ; } if ( prop === 'call' ) { return ( thisArg , ... args ) => traps . apply ( args ) ; } return traps . property ( prop ) ; } , apply : ( target , thisArg , args ) => traps . apply ( args ) , ownKeys : ( ) => traps . ownKeys ( ) , getOwnPropertyDescriptor ( target , prop ) { const keys = traps . ownKeys ( ) ; if ( keys . includes ( prop ) ) { return { configurable : true , enumerable : true , } ; } return undefined ; } , } ) as unknown as Mock < T > ;