BlackGlory / go

🌳

Home Page:https://www.npmjs.com/package/@blackglory/go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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>

About

🌳

https://www.npmjs.com/package/@blackglory/go

License:MIT License


Languages

Language:TypeScript 96.8%Language:JavaScript 3.2%