以下面这种方式,写单例很容易: let someModule async getSomeModule() { if (!someModule) { someModule = await someAsyncOperationsToInitializeModule() } return someModule } module.exports = getSomeModule 复制代码 通常以这种方式使用它: // in async function const getSomeModul...
以下面这种方式,写单例很容易: let someModule async getSomeModule() { if (!someModule) { someModule = await someAsyncOperationsToInitializeModule() } return someModule } module.exports = getSomeModule 复制代码 通常以这种方式使用它: // in async function const getSomeModul...