| 32 | private freqList: string[] |
| 33 | |
| 34 | constructor({start, end, offset, freq, period}: Params){ |
| 35 | this.start = start |
| 36 | this.end = end |
| 37 | this.offset = offset |
| 38 | this.freq = freq ? freq : "D" |
| 39 | this.period = period |
| 40 | this.freqList = [ "M", "D", "s", "H", "m", "Y" ] |
| 41 | |
| 42 | if (this.freq.length == 1){ |
| 43 | if (!this.freqList.includes(this.freq)){ |
| 44 | throw new Error(`invalid freq ${this.freq}`); |
| 45 | } |
| 46 | } else { |
| 47 | this.offset = parseInt(this.freq.slice(0, -1)); |
| 48 | if (!Number.isFinite(this.offset)){ |
| 49 | throw new Error(`invalid freq offset ${this.freq.slice(0, -1)}`); |
| 50 | } |
| 51 | this.freq = this.freq.slice(-1); |
| 52 | if (!this.freqList.includes(this.freq)){ |
| 53 | throw new Error(`invalid freq ${this.freq}`); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | } |
| 58 | |
| 59 | range(): string[] { |
| 60 | let start = this.start |