timeout-date

1.0.3 • Public • Published

timeout-date

Build Status contributions welcome HitCount npm npm

Set timeout using date objects

Install

npm install --save timeout-date

Usage

const timeoutDate = require('timeout-date').default
 
// Current time is 'Sat Feb 24 2018 5:00:00 GMT+0530 (IST)'
const date = new Date('Sat Feb 24 2018 5:30:00 GMT+0530 (IST)')
// You have a date object 30 minutes later from now
const later = timeoutDate(() => console.log('Hooray!'), date)
 
// The timeout object is returned.
// clearTimeout(later)

API

timeoutDate(callback, [date])

timeoutDate takes a callback and an optional date object. If no date object is provided, timeout is triggered immideatly. The second argument if provided, must be a valid date object.

Returns a Timeout for use with clearTimeout().

Note: When delay is larger than 2147483647 (around 25 days) or less than 1, the delay will be set to 1. This is the default setTimeout behaviour.

License

MIT © Siddharth Doshi

Readme

Keywords

none

Package Sidebar

Install

npm i timeout-date

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

219 kB

Total Files

11

Last publish

Collaborators

  • sidoshi