1.0.1 • Published 8 years ago
streaky-util v1.0.1
streaky-util
Utility functions to calculate streak related values.
Install
$ npm install streaky-utilAPI
All dates passed should be ISO 8601 dates.
streakyUtil.getCurrentStreak(entries, options)
entriescan 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'}) // => 2optionsis an object that can have ainitialDateproperty, to change the date to start counting from. If not passed, the current day is considered.
streakyUtil.getLongestStreak(entries, options)
entriescan be an array of dates, or an object where the keys are dates and the values are boolean.optionsis an object that can have ainitialDateproperty, to change the date to start counting from. If not passed, the current day is considered.