streaky-util

1.0.1 • Public • Published

streaky-util

Utility functions to calculate streak related values.

Install

  $ npm install streaky-util

API

All dates passed should be ISO 8601 dates.

streakyUtil.getCurrentStreak(entries, options)

  • entries can be an array of dates, or an object where the keys are dates and the values are boolean:
  let entries = ['2018-02-08', '2018-02-09', '2018-02-10']
  streakyUtils.getCurrentStreak(entries, {initialDate: '2018-02-10'}) // -> 3
 
  // or
 
  entries = {
    '2018-02-08': false,
    '2018-02-09': true,
    '2018-02-10': true
  }
 
  streakyUtils.getCurrentStreak(entries, {initialDate: '2018-02-10'}) // => 2
  • options is an object that can have a initialDate property, to change the date to start counting from. If not passed, the current day is considered.

streakyUtil.getLongestStreak(entries, options)

  • entries can be an array of dates, or an object where the keys are dates and the values are boolean.
  • options is an object that can have a initialDate property, to change the date to start counting from. If not passed, the current day is considered.

Readme

Keywords

none

Package Sidebar

Install

npm i streaky-util

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

8.41 kB

Total Files

6

Last publish

Collaborators

  • lucaspin