Socket
Socket
Sign inDemoInstall

await-to-done

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    await-to-done

Async await wrapper for easy error handling


Version published
Weekly downloads
31
decreased by-41.51%
Maintainers
1
Install size
97.6 kB
Created
Weekly downloads
 

Changelog

Source

2024.05.30 v1.1.1

  1. docs work
  2. use pnpm v9

Readme

Source

await-to-done

Async await wrapper for easy error handling

NPM version Codacy Badge typescript Test coverage npm download gzip License

Sonar

DocumentationChange Log

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

Installing

# use pnpm
$ pnpm install await-to-done

# use npm
$ npm install await-to-done --save

Usage

Simple Usage

  1. ES6 module
import to from 'await-to-done'

const [err, data] = await to(/* promise function */)
  1. Node.js require
const to = require('await-to-done')

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

Multiple Promises

import to from 'await-to-done'

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

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

Using unpkg CDN

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

Support & Issues

Please open an issue here.

License

MIT

Keywords

FAQs

Last updated on 30 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc