New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

timeoutn

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timeoutn

Simple library for taming timed out async work

1.0.2
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

timeoutn

timeoutn is a simple library for taming timed out async work

Build Status

Installation

$ npm install timeoutn

Basic Example

Here is a simple timed example. Where we call done callback before async work has finished.

var timeoutn = require('timeoutn')
  , timedout

function done(err) {
  if (err) {
    console.log(err)
  }

  if (timedout()) {
    return console.log('Handle timed out scenario here')
  }

  ...
}

timedout = timeoutn(2000, done, 'Error processing after 2000 ms')
setTimeout(done, 3000)

Or you could just use err passed to handle, for timed out scenario

var timeoutn = require('timeoutn')

function done(err) {
  if (err) {
    return console.log(err)
  }

  ...
}

timeoutn(2000, done, 'Error processing after 2000 ms')
setTimeout(done, 3000)

What's it good for?

Whenever you need to be sure that something has finished, and is not staling forever. You should setup timeout expectation and respond accordingly.

Running tests

$ npm install
$ npm test

Authors

  • dejanr

License

BSD

Keywords

async

FAQs

Package last updated on 11 Sep 2014

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