callbag-date-timer

1.0.5 • Public • Published

callbag-date-timer

Callbag source that after given Date emits numbers in sequence to a specified period.

npm version Build Status

Examples

Emitting Sometime in the Future

import forEach from 'callbag-for-each'
import pipe from 'callbag-pipe'
import timer from 'callbag-date-timer'
 
const date = new Date(Date.now() + 10000)
 
pipe(
  timer(date),
  forEach(value => {
    // will log 0
    console.log(value)
  }),
)

Starting a Period Sometime in the Future

import forEach from 'callbag-for-each'
import pipe from 'callbag-pipe'
import timer from 'callbag-date-timer'
 
const date = new Date(Date.now() + 10000)
 
pipe(
  timer(date, 2000),
  forEach(value => {
    // will log 0 1 2 3 4 ...
    console.log(value)
  }),
)

Starting in the Past

import forEach from 'callbag-for-each'
import pipe from 'callbag-pipe'
import timer from 'callbag-date-timer'
 
const date = new Date(Date.now() - 10000)
 
pipe(
  timer(date, 2000),
  forEach(value => {
    // will log 5 6 7 8 9 ...
    console.log(value)
  }),
)

Package Sidebar

Install

npm i callbag-date-timer

Weekly Downloads

2

Version

1.0.5

License

ISC

Unpacked Size

3.92 kB

Total Files

5

Last publish

Collaborators

  • scio