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
🌳
- Host: GitHub
- URL: https://github.com/blackglory/go
- Owner: BlackGlory
- License: mit
- Created: 2021-03-07T17:10:06.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-17T07:51:39.000Z (about 2 years ago)
- Last Synced: 2025-02-03T15:53:02.787Z (over 1 year ago)
- Topics: browser, esm, library, nodejs, npm-package, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@blackglory/go
- Size: 1.07 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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
```