date-streaks
Advanced tools
Comparing version 1.1.6 to 1.2.0
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.sortDates = exports.filterInvalidDates = exports.relativeDates = undefined; | ||
exports.getDatesParameter = exports.sortDates = exports.filterInvalidDates = exports.relativeDates = undefined; | ||
@@ -45,2 +45,14 @@ var _start_of_day = require('date-fns/start_of_day'); | ||
}).reverse(); | ||
}; | ||
var getDatesParameter = exports.getDatesParameter = function getDatesParameter() { | ||
var param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
if (Array.isArray(param)) { | ||
return param; | ||
} else { | ||
var dates = param.dates; | ||
return dates || []; | ||
} | ||
}; |
@@ -17,6 +17,6 @@ 'use strict'; | ||
function streakRanges(_ref) { | ||
var _ref$dates = _ref.dates, | ||
dates = _ref$dates === undefined ? [] : _ref$dates; | ||
function streakRanges() { | ||
var datesParam = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
var dates = (0, _helpers.getDatesParameter)(datesParam); | ||
if (dates.length === 0) { | ||
@@ -23,0 +23,0 @@ return []; |
@@ -21,6 +21,7 @@ 'use strict'; | ||
function summary(_ref) { | ||
var _ref$dates = _ref.dates, | ||
dates = _ref$dates === undefined ? [] : _ref$dates; | ||
function summary() { | ||
var datesParam = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
var dates = (0, _helpers.getDatesParameter)(datesParam); | ||
var _relativeDates = (0, _helpers.relativeDates)(), | ||
@@ -27,0 +28,0 @@ today = _relativeDates.today, |
{ | ||
"name": "date-streaks", | ||
"version": "1.1.6", | ||
"version": "1.2.0", | ||
"description": "Find a variety of streak metrics from a list of dates.", | ||
"main": "./dist/index.js", | ||
"scripts": { | ||
"test": "npm run build && mocha test/index.js", | ||
"test": "npm run build && mocha test/*.js", | ||
"build": "babel src --presets babel-preset-env --out-dir dist", | ||
@@ -9,0 +9,0 @@ "prepublish": "npm run build" |
@@ -16,3 +16,3 @@ # 🗓⚡️ Date Streaks | ||
summary({ dates }); | ||
summary({ dates }) // or summary(dates) -> accepts an array as well; | ||
``` | ||
@@ -66,3 +66,3 @@ | ||
summary({ dates }); | ||
summary({ dates }); // or summary(dates) -> accepts an array as well | ||
``` | ||
@@ -98,3 +98,3 @@ | ||
streakRanges({ dates }); | ||
streakRanges({ dates }); // or streakRanges(dates) -> accepts an array as well | ||
``` | ||
@@ -140,3 +140,3 @@ | ||
trackRecord({ dates, length }); | ||
trackRecord({ dates, length }); // object filled w/ {dates:Array, length:Number} | ||
``` | ||
@@ -143,0 +143,0 @@ |
@@ -140,2 +140,20 @@ var { startOfDay, subDays, addDays } = require('date-fns'); | ||
}); | ||
it('should accept an array as input', () => { | ||
var longStreak = summary([ | ||
new Date('08/19/2018'), | ||
new Date('08/10/2018'), | ||
new Date('08/17/2018'), | ||
new Date('08/18/2018'), | ||
new Date('08/15/2018'), | ||
new Date('08/14/2018'), | ||
new Date('08/16/2018'), | ||
new Date('08/12/2018'), | ||
new Date('08/13/2018'), | ||
new Date('08/11/2018'), | ||
new Date('08/09/2018'), | ||
]); | ||
expect(longStreak.longestStreak).to.equal(11); | ||
}); | ||
}); | ||
@@ -142,0 +160,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22487
12
405