离开
安装
npm install --save @blackglory/go
# or
yarn add @blackglory/go
使用量
import { go } from '@blackglory/go'
go(async () => {
...
})
为什么?
IIFE (英语) 好,直到你忘记引用它:
;(async () => {
...
}) // oops!
无分号样式很好,直到你忘记在IIFE前添加分号:
const arr = []
// oops!
(async () => {
...
})()
API 密码
离开
function go<T>(fn: () => T): T
goMicrotask 移动任务
function goMicrotask<T>(fn: () => Awaitable<T>): Promise<T>
去马可塔克
function goMarcotask<T>(fn: () => Awaitable<T>): Promise<T>
goGenerator 游戏
function goGenerator<Yield, Next>(
fn: () =>
| void
| Generator<Yield, void, Next>
): Generator<Yield, void, Next>
goAsync 编辑器
function goAsyncGenerator<Yield, Next>(
fn: () =>
| void
| Generator<Yield, void, Next>
| AsyncGenerator<Yield, void, Next>
): AsyncGenerator<Yield, void, Next>