2.0.0 • Published 1 year ago

@blackglory/go v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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>