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

callforth

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callforth

A tiny utility library to replace callbacks with Promises where possible.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Callforth :running:

A tiny utility library to replace callbacks with Promises where possible. Don't callback, callforth!

It basically includes two functions I see myself re-implementing in nearly every project. So I might as well put them in a package.

Do things like:

await timeout(3000);

await eventOn(videoElement, "loadeddata");

let message = await eventOn(webWorker, "message");

Install :package:

npm install callforth

Now you can:

import { eventOn, timeout } from "callforth"

API

eventOn

let payload = await eventOn(target, successEvent, errorEvent)
Parameters
  • target: anything you can call addEventListener on.
  • successEvent: name of the event you want to await.
  • errorEvent (optional): if this event fires, the promise is rejected.
Return Value
  • payload: what would usually be the first argument of the callback.

timeout

await timeout(delay)
Parameters
  • delay: delay in milliseconds after which the Promise should resolves.
Return Value
  • undefined

FAQs

Package last updated on 23 Aug 2019

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