/// import * as error from "../Error/_all"; import { Consts } from "../Consts"; import { IProxy } from "./IProxy"; import { IProxyHandler, PropKey } from "./IProxyHandler"; export class ProxyES6 implements IProxy { readonly ___id = Consts.IPROXY_ID_VALUE; private constructor(target: T, handler: IProxyHandler) { const p = >new Proxy(target, handler); (p)[Symbol.toStringTag] = Function.prototype.toString.bind(target); return p; } static of(target: U, handler: IProxyHandler): ProxyES6 { ProxyES6.check(); const result = new ProxyES6(target, handler); return result; } private static check(): void { if (typeof Proxy === "undefined") throw new error.MockException(error.MockExceptionReason.InvalidDynamicProxyRuntime, null, "ES6 Proxy object not detected; the dynamic mocking feature requires ES6 Proxy object support"); } }