Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@open-draft/until

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@open-draft/until

Gracefully handle a Promise using async/await.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.8M
decreased by-0.07%
Maintainers
1
Weekly downloads
 
Created
Source

Build status

until

Gracefully handle a Promise using async/await.

Getting started

Install

npm install @open-draft/until

Use

import { until } from '@open-draft/until'

async function(id) {
  const [error, user] = await until(() => fetchUser(id))

  if (error) {
    return handleError(error)
  }

  return user
}

Usage with TypeScript

import { until } from '@open-draft/until'

interface User {
  firstName: string
  age: number
}

interface UserFetchError {
  type: 'FORBIDDEN' | 'NOT_FOUND'
  message?: string
}

async function(id: string) {
  const [error, user] = await until<User, UserFetchError>(() => fetchUser(id))

  if (error) {
    handleError(error.type, error.message)
  }

  return user.firstName
}

FAQs

Package last updated on 24 Mar 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc