Skip to content

Commit

Permalink
remove unecessary toDate call in the next* functions (date-fns#2599)
Browse files Browse the repository at this point in the history
  • Loading branch information
fturmel authored Nov 25, 2021
1 parent 846b707 commit 3a8c0e3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 21 deletions.
5 changes: 2 additions & 3 deletions src/nextFriday/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import requiredArgs from '../_lib/requiredArgs/index'
import nextDay from '../nextDay/index'
import toDate from '../toDate/index'
import requiredArgs from '../_lib/requiredArgs/index'

/**
* @name nextFriday
Expand All @@ -21,5 +20,5 @@ import toDate from '../toDate/index'
*/
export default function nextFriday(date: Date | number): Date {
requiredArgs(1, arguments)
return nextDay(toDate(date), 5)
return nextDay(date, 5)
}
5 changes: 2 additions & 3 deletions src/nextMonday/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import requiredArgs from '../_lib/requiredArgs/index'
import nextDay from '../nextDay/index'
import toDate from '../toDate/index'
import requiredArgs from '../_lib/requiredArgs/index'

/**
* @name nextMonday
Expand All @@ -21,5 +20,5 @@ import toDate from '../toDate/index'
*/
export default function nextMonday(date: Date | number): Date {
requiredArgs(1, arguments)
return nextDay(toDate(date), 1)
return nextDay(date, 1)
}
5 changes: 2 additions & 3 deletions src/nextSaturday/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import requiredArgs from '../_lib/requiredArgs/index'
import nextDay from '../nextDay/index'
import toDate from '../toDate/index'
import requiredArgs from '../_lib/requiredArgs/index'

/**
* @name nextSaturday
Expand All @@ -21,5 +20,5 @@ import toDate from '../toDate/index'
*/
export default function nextSaturday(date: Date | number): Date {
requiredArgs(1, arguments)
return nextDay(toDate(date), 6)
return nextDay(date, 6)
}
5 changes: 2 additions & 3 deletions src/nextSunday/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import requiredArgs from '../_lib/requiredArgs/index'
import nextDay from '../nextDay/index'
import toDate from '../toDate/index'
import requiredArgs from '../_lib/requiredArgs/index'

/**
* @name nextSunday
Expand All @@ -21,5 +20,5 @@ import toDate from '../toDate/index'
*/
export default function nextSunday(date: Date | number): Date {
requiredArgs(1, arguments)
return nextDay(toDate(date), 0)
return nextDay(date, 0)
}
5 changes: 2 additions & 3 deletions src/nextThursday/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import requiredArgs from '../_lib/requiredArgs/index'
import nextDay from '../nextDay/index'
import toDate from '../toDate/index'
import requiredArgs from '../_lib/requiredArgs/index'

/**
* @name nextThursday
Expand All @@ -21,5 +20,5 @@ import toDate from '../toDate/index'
*/
export default function nextThursday(date: Date | number): Date {
requiredArgs(1, arguments)
return nextDay(toDate(date), 4)
return nextDay(date, 4)
}
5 changes: 2 additions & 3 deletions src/nextTuesday/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import requiredArgs from '../_lib/requiredArgs/index'
import nextDay from '../nextDay/index'
import toDate from '../toDate/index'
import requiredArgs from '../_lib/requiredArgs/index'

/**
* @name nextTuesday
Expand All @@ -21,5 +20,5 @@ import toDate from '../toDate/index'
*/
export default function nextTuesday(date: Date | number): Date {
requiredArgs(1, arguments)
return nextDay(toDate(date), 2)
return nextDay(date, 2)
}
5 changes: 2 additions & 3 deletions src/nextWednesday/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import requiredArgs from '../_lib/requiredArgs/index'
import nextDay from '../nextDay/index'
import toDate from '../toDate/index'
import requiredArgs from '../_lib/requiredArgs/index'

/**
* @name nextWednesday
Expand All @@ -21,5 +20,5 @@ import toDate from '../toDate/index'
*/
export default function nextWednesday(date: Date | number): Date {
requiredArgs(1, arguments)
return nextDay(toDate(date), 3)
return nextDay(date, 3)
}

0 comments on commit 3a8c0e3

Please sign in to comment.