UNPKG

com-tools

Version:

com-tools 提供了一些通用的工具函数;

54 lines (26 loc) 882 B
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [com-tools](./com-tools.md) &gt; [createSingleton](./com-tools.createsingleton.md) ## createSingleton() function 为指定的函数 fun 创建对应的 单例函数 **Signature:** ```typescript export declare function createSingleton<Fun extends Function>(fun: Fun): Fun; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> fun </td><td> Fun </td><td> : Function 普通函数 或者 构造函数 Function 增加了单例机制的函数;该函数的使用方式 和 原函数 fun 一样,只是无论多少次调用该函数,该函数都会返回原函数 fun 的同一实例 </td></tr> </tbody></table> **Returns:** Fun