Socket
Socket
Sign inDemoInstall

signal-promise

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

signal-promise

Simple wait/notify promise with optional max wait time


Version published
Weekly downloads
1.9K
increased by29.8%
Maintainers
1
Weekly downloads
 
Created
Source

signal-promise

Simple wait/notify promise with optional max wait time

npm install signal-promise

Usage

const Signal = require('signal-promise')

const input = new Signal()

while (await input.wait()) {
  console.log('someone typed!')
}

process.stdin.on('stdin', function () {
  input.notify()
})

API

s = new Signal()

Make a new signal

await s.wait([maxWaitTime])

Wait for someone to call notify. If you specify maxWaitTime the promise will resolve after maxWaitTime ms if no notify call has happened.

As a convenience the promise resolves to true so it's easy to use it as a condition.

s.notify([error])

Notify everyone waiting. If you pass an error the wait promise will reject with that error.

License

MIT

FAQs

Package last updated on 03 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