# @blackglory/go

> ```sh npm install --save @blackglory/go # or yarn add @blackglory/go ```

Latest version **2.0.0** (published 2024-04-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @blackglory/go
pnpm add @blackglory/go
yarn add @blackglory/go
bun add @blackglory/go
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-04-17 |
| First published | 2021-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.17.0 |
| Dependencies | 2 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | BlackGlory |
| Maintainers | black_glory |

## Links

- npm: https://www.npmjs.com/package/@blackglory/go
- Repository: https://github.com/BlackGlory/go
- Homepage: https://github.com/BlackGlory/go#readme
- Issues: https://github.com/BlackGlory/go/issues
- npm.io page: https://npm.io/package/@blackglory/go

## Dependencies (2)

- [justypes](https://npm.io/package/justypes.md) ^4.2.1
- [extra-timers](https://npm.io/package/extra-timers.md) ^0.2.6

## Recent versions

- 2.0.0 (latest) — 2024-04-17
- 1.1.3 — 2023-06-11
- 1.1.2 — 2022-08-01
- 1.1.1 — 2022-06-09
- 1.1.0 — 2022-06-09
- 1.0.0 — 2022-03-05
- 0.1.1 — 2021-12-04
- 0.1.0 — 2021-03-07

## 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<T>(fn: () => T): T
```

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

### goMarcotask
```ts
function goMarcotask<T>(fn: () => Awaitable<T>): Promise<T>
```

### goGenerator
```ts
function goGenerator<Yield, Next>(
  fn: () =>
  | void
  | Generator<Yield, void, Next>
): Generator<Yield, void, Next>
```

### goAsyncGenerator
```ts
function goAsyncGenerator<Yield, Next>(
  fn: () =>
  | void
  | Generator<Yield, void, Next>
  | AsyncGenerator<Yield, void, Next>
): AsyncGenerator<Yield, void, Next>
```

---
_Source: https://npm.io/package/@blackglory/go · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
