Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.
/ repeat Public archive

create repeating task chains

License

Notifications You must be signed in to change notification settings

117/repeat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

repeat

version language maintenance prettier

create repeating task chains

Contents

Features

  • Chain any number of tasks and repeat them once or forever.
  • Optional synchronous and asynchronous API.

Install

From NPM:

> npm i repeat

Chain

Creating a new chain

The following chain will execute all tasks every second. A task is any callable function.

// ES6
import { Chain } from 'repeat'

// ES5
// let { Chain } = require('repeat')

let chain = new Chain()

chain
  .add(
    // task A
    () => console.log('how are you?'),
    // task B
    () => console.log('good')
    // you can add task C, D, E, F ...
  )
  .every(1000)

Examples

The following methods are available on the chain.

add

// add any number of tasks to the chain
chain.add(
  () => console.log('cat'),
  () => console.log('dog'),
  () => console.log('fish')
)

once

// execute the tasks once
chain.once()

every

// execute the tasks asynchronously every second
chain.every(1000)

forever

// execute the tasks as fast as possible
chain.forever()

cancel

// halt further execution of tasks
chain.cancel()

Contributing

Feel free to contribute and PR to your 💖's content.

Releases

No releases published

Packages

No packages published