An open API service indexing awesome lists of open source software.

https://github.com/blackglory/go

🌳
https://github.com/blackglory/go

browser esm library nodejs npm-package typescript

Last synced: about 2 months ago
JSON representation

🌳

Awesome Lists containing this project

README

          

# go
## Install
```sh
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
### go
```ts
function go(fn: () => T): T
```

### goMicrotask
```ts
function goMicrotask(fn: () => Awaitable): Promise
```

### goMacrotask
```ts
function goMacrotask(fn: () => Awaitable): Promise
```

### goGenerator
```ts
function goGenerator(
fn: () =>
| void
| Generator
): Generator
```

### goAsyncGenerator
```ts
function goAsyncGenerator(
fn: () =>
| void
| Generator
| AsyncGenerator
): AsyncGenerator
```