https://github.com/5310/callbag-date-timer
Callbag source that after given Date emits numbers in sequence to a specified period.
https://github.com/5310/callbag-date-timer
Last synced: 2 months ago
JSON representation
Callbag source that after given Date emits numbers in sequence to a specified period.
- Host: GitHub
- URL: https://github.com/5310/callbag-date-timer
- Owner: 5310
- Created: 2018-09-17T12:42:57.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-04T05:34:27.000Z (about 3 years ago)
- Last Synced: 2025-01-20T06:38:14.772Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
callbag-date-timer
------------------Callbag source that after given Date emits numbers in sequence to a specified period.
[](https://badge.fury.io/js/callbag-date-timer)
[](https://travis-ci.org/5310/callbag-date-timer)## Examples
### Emitting Sometime in the Future
```js
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
```js
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
```js
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)
}),
)
```