1.4.6 • Published 5 months ago

@resreq/task v1.4.6

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Task

version workflow download

⏰ Short and sweet task.

Install

npm install @resreq/task

Usage

import Task from '@resreq/task'

const log1 = (time: number) => console.log('log1:', time)
const log2 = (time: number) => console.log('log2:', time)
const log3 = (time: number) => console.log('log3:', time)

const task = new Task({
  interval: 1000
})

task.push('id-1', log1)
task.push('id-2', log2)
task.push('id-3', log3)

task.start()

setTimeout(() => {
  task.stop()
}, 3000)

// log1: 1733133501541
// log2: 1733133502541
// log3: 1733133503541

Adapter

setTimeout is used by default, and custom adapters are supported, such as requestAnimationFrame, cancelIdleCallback, etc...

const task = new Task({
  adapter: {
    setTimer: globalThis.requestAnimationFrame.bind(globalThis),
    cancelTimer: globalThis.cancelAnimationFrame.bind(globalThis)
  }
})

LICENSE

This project is licensed under the MIT License - see the LICENSE file for details.

1.4.6

5 months ago

1.4.5

8 months ago

1.4.4

8 months ago

1.4.3

8 months ago

1.4.2

8 months ago

1.4.1

8 months ago

1.4.0

8 months ago

1.3.4

8 months ago

1.3.3

8 months ago

1.3.2

8 months ago

1.3.1

8 months ago

1.3.0

8 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.3

10 months ago

1.1.2

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago