Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/janwirth/headless-work-timer
A headless work timer component with zero dependencies. Defaults to Pomodoro intervals.
https://github.com/janwirth/headless-work-timer
Last synced: about 5 hours ago
JSON representation
A headless work timer component with zero dependencies. Defaults to Pomodoro intervals.
- Host: GitHub
- URL: https://github.com/janwirth/headless-work-timer
- Owner: janwirth
- Created: 2017-12-23T17:15:12.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-05T10:27:46.000Z (almost 7 years ago)
- Last Synced: 2024-11-06T22:42:37.332Z (13 days ago)
- Language: JavaScript
- Homepage: https://npm.runkit.com/headless-work-timer
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# headless-work-timer
A work timer component with zero dependencies and no view layer.
Defaults to Pomodoro intervals.[![Standard - JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
## Installation
```sh
npm install --save headless-work-timer
```## Usage
```js
const timer = require('headless-work-timer')const DEFAULT_STATE = {
phase: 'work',
second: 0, // current second
streak: 0 // start with first work interval
}const DEFAULT_SETTINGS = timer.createSettings(25)(25)(15)(5)
// When the user hits 'start'
// NOTE: You don't have to make the defaults explicit - they're defaults
const stop = timer(/* DEFAULT_SETTINGS */)(/* DEFAULT_STATE */)((state, phaseChanged, settings) => {
console.log('')
phaseChanged ? console.log('PHASE CHANGED') : 'noop'
console.log('PHASE', state.phase)
console.log('SECOND', state.second)
console.log('streak', state.streak)
console.log(settings)
})// When the user hits 'stop'
stop()```
If you want to implement a 'pause' feature, just call `stop` and when you want to continue, pass the the last `state` to `start`.