Neutral Political Machine

    This package has been deprecated

    Author message:

    Use setInterval with https://npm.im/ms instead

    reg-task

    1.0.2 • Public • Published

    rtr - Regular Task Runner

    Running arbitrary code on a regular basis made easy

    const Runner = require('reg-task').Runner
    
    // A task that runs every hour
    let task = new Runner({ h: 1 }, () => {
      // Complex algorithm goes here ...
    })
    
    task.start()

    Features

    • Runs code at a defined interval
    • Any errors are caught and emitted (via EventEmitter)
    • Use async/await, because why would you use anything else
    • Tasks never run in parallel, the old task must finish
    • Simplified scheduling syntax to quickly get a timer going

    Examples

    const Runner = require('reg-task').Runner
    
    
    // Tick Configuration
    let daily = { d: 1 }
    let everyTenSeconds = { s: 10 }
    let everyTwelfthMinute = { m: 12 }
    let everyDayAndAHalf = { d: 1, h: 12 }
    
    
    // Creating a task
    let task = new Runner(everyDayAndAHalf, () => {
      // Complex algorithm goes here ...
    })
    
    
    // Start the task
    task.start()
    
    
    // Listen for errors
    task.on('error', (e) => {
      console.error('Task Error', e)
    })
    
    
    // Force the task to execute once
    task.forceTask()
    
    
    // Stop the task
    task.stop()
    

    Keywords

    none

    Install

    npm i reg-task

    DownloadsWeekly Downloads

    2

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    4.36 kB

    Total Files

    4

    Last publish

    Collaborators

    • robb_j