bunkat / later

A javascript library for defining recurring schedules and calculating future (or past) occurrences for them. Includes support for using English phrases and Cron schedules. Works in Node and in the browser.
http://bunkat.github.io/later/
MIT License
2.42k stars 245 forks source link

next() returns inconsistent types #211

Open nibblesnbits opened 7 years ago

nibblesnbits commented 7 years ago

I noticed that when you call .next(1) on a schedule, it returns only a single Date object, but when you call it with a value greater than one, it returns an Array. This forces me to make odd exceptions in my code. Is there a configuration or extension point where I can tell next() to always return an Array?

crsssl commented 7 years ago

I'd like to add to this: If there are no subsequent occurrences, .next() returns a number (0). So we have to check for up to three conditions: a number, a Date, and an array of Date.