whirlwinds

    0.0.5 • Public • Published

    Whirlwinds

    Dependecy-less micro library for timed functions based on the amazing work done by bjoerge with repeat a lustrum ago.

    Build Status

    Warning

    This is a work in progress. The API is likely to be changed.

    Installation

    npm install whirlwinds

    Usage

    Sleep

    const { sleep } = require('whirlwinds')
     
    async function doSomething(){
     
      console.log('I need to wait 3000ms..')
     
      await sleep(3000)
     
      console.log('3000ms have passed!!')
     
    }
     

    Repeat

    Basic example:

    const { repeat } = require('whirlwinds')
     
    const target = ()=> console.log('printing indefinitely')
     
    repeat(target)
    .every(200)
    .go()

    If things get serious, Whirlwinds allows you to pause and resume the execution of target the function whenever you feel is more convenient:

    const { repeat } = require('whirlwinds')
     
    const { pause, resume, stop } = repeat(()=>{
      console.log('printing indefinitely')
    })
    .every(200)
    .go()
     
    // pausing...
    pause()
     
    // ... 
     
    // resuming...
    resume()
     

    Licence

    M.I.T.

    Install

    npm i whirlwinds

    DownloadsWeekly Downloads

    1

    Version

    0.0.5

    License

    M.I.T

    Last publish

    Collaborators

    • alvarob