JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q44372F
  • License MIT

Package Exports

  • await-into
  • await-into/dist/index.cjs.js
  • await-into/dist/index.mjs.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (await-into) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

await-into

Async await wrapper for easy error handling

License

DocumentationChange Log

Read this in other languages: English | 简体中文

Installing

# use pnpm
$ pnpm install await-into

# use npm
$ npm install await-into

# use yarn
$ yarn add await-into

Usage

Simple Usage

  1. ES6 module
import into from 'await-into'

const [err, data] = await into(/* promise function */)

2.重试策略

import into from 'await-into'

const [err, data] = await on(someAsyncOperation, { retries: 3 });

3.Node.js require

const into = require('await-into')

const [err, data] = await into(/* promise function */)

Multiple Promises

import into from 'await-into'

const bar = () => new Promise<boolean>()
const foo = () => new Promise<string>()

const [err, data] = await into(bar(), foo()) // data = [boolean, string]
// or pass in an Array
const [err, data] = await into([bar(), foo()]) // data = [boolean, string]

Using unpkg CDN

<script src="https://unpkg.com/await-into@latest/dist/index.global.prod.js"></script>
<script>
  ;(async () => {
    const into = window.awaitToDone
    const [err, data] = await into(/* promise function */)
  })()
</script>

Support & Issues

Please open an issue here.

License

MIT