@mudssky/jsutils
    Preparing search index...

    Function singletonProxy

    • 传入一个对象,利用Proxy包装返回一个单例对象 因为使用了Proxy,所以this绑定还是原来的对象不会受影响

      Type Parameters

      • T extends object

      Parameters

      • obj: new (...args: any[]) => T

      Returns new (...args: any[]) => T

      	const singleDate = singletonProxy(Date)
      const date1 = new singleDate()
      const date2 = new singleDate()
      date1 === date2