```sh npm install --save @blackglory/go # or yarn add @blackglory/go ```
npm install @blackglory/gosh
npm install --save @blackglory/go
or
yarn add @blackglory/go
`Usage
`ts
import { go } from '@blackglory/go'go(async () => {
...
})
`Why?
[IIFE] is good until you forget to invoke it:`ts
;(async () => {
...
}) // oops!
`The semicolon-free style is good until you forget to add a semicolon before the IIFE:
`ts
const arr = []// oops!
(async () => {
...
})()
`[IIFE]: https://en.wikipedia.org/wiki/Immediately_invoked_function_expression
API
$3
`ts
function go(fn: () => T): T
`$3
`ts
function goMicrotask(fn: () => Awaitable): Promise
`$3
`ts
function goMarcotask(fn: () => Awaitable): Promise
`$3
`ts
function goGenerator(
fn: () =>
| void
| Generator
): Generator
`$3
`ts
function goAsyncGenerator(
fn: () =>
| void
| Generator
| AsyncGenerator
): AsyncGenerator
``