Skip to content

disowned-projects/decade-out

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

decade-out

Build Status contributions welcome HitCount npm npm

Set huge timeouts

Install

npm install --save decade-out

Usage

import { decadeOut, clearDecadeOut } from 'decade-out'

const oneDecade = 1000 * 60 * 60 * 24 * 365

// The callback will fire after 10 years,
// Given the program keeps running.
const decadeId = decadeOut(
  () => console.log('You are 10 years older now!'),
  oneDecade
)

// You can also cancel the execution
clearDecadeOut(decadeId)

Set timeouts for huge duration which are not handled by setTimeout. Cancel it if required.

API

decadeOut(callback, [ms]) -> ?decadeID

callback

Function to execute when timeout occurs.

ms

Time in ms after which callback should be fired. It can be much longer than what the default timeout supports.

If not provided, callback fires immediately. If Infinity is provided, callback will never fire as no timer is set at all and null is returned. If a proper ms is provided, callback will be fired after the time passes.

decadeId

decadeId is returned from decadeOut which is an internal way of identifying the running timer. You can't use it with clearTimeout. You have to use it with clearDecadeOut.

clearDecadeOut(decadeId)

decadeId can be passed to clearDecadeOut to clear the timeout. Use this instead of clearTimeout.

License

MIT © Siddharth Doshi

Releases

No releases published

Packages

No packages published