adds more tests for period predictions, moves getcycleslength into cycle module
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import assert from 'assert'
|
||||
import { LocalDate, ChronoUnit } from 'js-joda'
|
||||
import cycleModule from '../lib/cycle'
|
||||
|
||||
export function getCycleLengthStats(cycleLengths) {
|
||||
throwIfArgsAreNotInRequiredFormat(cycleLengths)
|
||||
@@ -48,14 +46,4 @@ function throwIfArgsAreNotInRequiredFormat(cycleLengths) {
|
||||
assert.equal(typeof cycleLength, 'number', 'Elements in the array should be of type number.')
|
||||
assert.ok(!isNaN(cycleLength), 'Elements of array should not be NaN.')
|
||||
})
|
||||
}
|
||||
|
||||
export function getCycleLength(cycleStartDates) {
|
||||
const cycleLengths = []
|
||||
for (let i = 0; i < cycleStartDates.length - 1; i++) {
|
||||
const nextCycleStart = LocalDate.parse(cycleStartDates[i])
|
||||
const cycleStart = LocalDate.parse(cycleStartDates[i + 1])
|
||||
cycleLengths.push(cycleStart.until(nextCycleStart, ChronoUnit.DAYS))
|
||||
}
|
||||
return cycleLengths
|
||||
}
|
||||
Reference in New Issue
Block a user