@blackglory/go
v2.0.0
Published
```sh npm install --save @blackglory/go # or yarn add @blackglory/go ```
Downloads
12,491
Readme
go
Install
npm install --save @blackglory/go
# or
yarn add @blackglory/go
Usage
import { go } from '@blackglory/go'
go(async () => {
...
})
Why?
IIFE is good until you forget to invoke it:
;(async () => {
...
}) // oops!
The semicolon-free style is good until you forget to add a semicolon before the IIFE:
const arr = []
// oops!
(async () => {
...
})()
API
go
function go<T>(fn: () => T): T
goMicrotask
function goMicrotask<T>(fn: () => Awaitable<T>): Promise<T>
goMarcotask
function goMarcotask<T>(fn: () => Awaitable<T>): Promise<T>
goGenerator
function goGenerator<Yield, Next>(
fn: () =>
| void
| Generator<Yield, void, Next>
): Generator<Yield, void, Next>
goAsyncGenerator
function goAsyncGenerator<Yield, Next>(
fn: () =>
| void
| Generator<Yield, void, Next>
| AsyncGenerator<Yield, void, Next>
): AsyncGenerator<Yield, void, Next>