diff --git a/README.md b/README.md index 3706ee5..067457a 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ Assuming you are using [browserify][], [webpack][], [rollup][], or another bundl | -------------- | -------------------------- | | **BunKat** | | | **Nick Baugh** | | +| **yrambler2001** | | ## License diff --git a/package.json b/package.json index 12a0d33..cd396b5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@breejs/later", "description": "Maintained fork of later. Determine later (or previous) occurrences of recurring schedules", - "version": "4.0.2", + "version": "4.0.3", "author": "BunKat ", "bugs": { "url": "https://github.com/breejs/later/issues", @@ -9,7 +9,8 @@ }, "contributors": [ "BunKat ", - "Nick Baugh (http://niftylettuce.com/)" + "Nick Baugh (http://niftylettuce.com/)", + "yrambler2001 (https://yrambler2001.me/)" ], "dependencies": {}, "devDependencies": { diff --git a/src/index.js b/src/index.js index 85e067b..5ddfd6b 100644 --- a/src/index.js +++ b/src/index.js @@ -841,9 +841,11 @@ later.compile = function (schedDef) { function compareFn(dir) { return dir === 'next' ? function (a, b) { + if (!a || !b) return true; return a.getTime() > b.getTime(); } : function (a, b) { + if (!a || !b) return true; return b.getTime() > a.getTime(); }; } @@ -1148,10 +1150,12 @@ later.schedule = function (sched) { function compareFn(dir) { return dir === 'next' ? function (a, b) { - return !b || a.getTime() > b.getTime(); + if (!a || !b) return true; + return a.getTime() > b.getTime(); } : function (a, b) { - return !a || b.getTime() > a.getTime(); + if (!a || !b) return true; + return b.getTime() > a.getTime(); }; }