Skip to content

Commit

Permalink
refactor: implement suggestion from #2019 review
Browse files Browse the repository at this point in the history
  • Loading branch information
WikiRik authored Oct 23, 2022
1 parent 71102d4 commit f32d228
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/lib/isAfter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@ import toDate from './toDate';
export default function isAfter(str, options) {
assertString(str);

let date;

if (typeof (options) === 'object') {
date = options.date;
} else { // backwards compatibility: isAfter(str [, date])
// eslint-disable-next-line prefer-rest-params
date = arguments[1];
}

if (!date) {
date = String(new Date());
}
// accessing 'arguments' for backwards compatibility: isAfter(str [, date])
// eslint-disable-next-line prefer-rest-params
const date = (typeof options === 'object' ? options.date : arguments[1]) || String(new Date());

const comparison = toDate(date);
const original = toDate(str);
Expand Down

0 comments on commit f32d228

Please sign in to comment.