ronantakizawa/codereview-bench huggingface dataset:
Repository: date-fns/date-fns
File: src/set/index.js (JavaScript)

Code before:
  var hasNaN = Object.values(options).every(x => isNaN(x))

  if (!isNumbers) {
    throw new RangeError('The options object must only contain numbers')
  } else if (hasNaN) {
    throw new RangeError('The options object must not contain a NaN')
  }

  var years = options.years == null ? 0 : toInteger(options.years)
  var months = options.months == null ? 0 : toInteger(options.months)
  var days = options.days == null ? 0 : toInteger(options.days)
  var hours = options.hours == null ? 0 : toInteger(options.hours)
  var minutes = options.minutes == null ? 0 : toInteger(options.minutes)
  var seconds = options.seconds == null ? 0 : toInteger(options.seconds)
  var milliseconds =
    options.milliseconds == null ? 0 : toInteger(options.milliseconds)

  var date = toDate(dirtyDate)

  // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
  if (isNaN(date)) {
    return new Date(NaN)
  }

  if (years > 0) date.setFullYear(years)
  if (months > 0) date = setMonth(date, months)
  if (days > 0) date.setDate(days)
  if (hours > 0) date.setHours(hours)
  if (minutes > 0) date.setMinutes(minutes)
  if (seconds > 0) date.setSeconds(seconds)
  if (milliseconds > 0) date.setMilliseconds(milliseconds)

  return date
}


Review comment (bug):
Month indexing in JS starts with 0 (= January) so this function fails in that case. The correct solution would be to check for nullability and setting the value at the same time:

```js
if (hours != null) {
  date.setHours(toInteger(hours))
}
```

Code after:
 * // Set 12 PM to 1 September 2014 01:23:45 to 1 September 2014 12:00:00:
 * var result = set(new Date(2014, 8, 1, 1, 23, 45), { hours: 12 })
 * //=> Mon Sep 01 2014 12:23:45
 */

export default function set(dirtyDate, values) {
  if (arguments.length < 2) {
    throw new TypeError(
      '2 arguments required, but only ' + arguments.length + ' present'
    )
  }

  if (typeof values !== 'object' || values === null) {
    throw new RangeError('values parameter must be an object')
  }

  var date = toDate(dirtyDate)

  // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
  if (isNaN(date)) {
    return new Date(NaN)
  }

  if (values.year != null) {
    date.setFullYear(values.year)
  }

  if (values.month != null) {
    date = setMonth(date, values.month)
  }

  if (values.date != null) {
    date.setDate(toInteger(values.date))
  }

  if (values.hours != null) {
    date.setHours(toInteger(values.hours))
  }

  if (values.minutes != null) {
    date.setMinutes(toInteger(values.minutes))
  }

  if (values.seconds != null) {
    date.setSeconds(toInteger(values.seconds))
  }

  if (values.milliseconds != null) {
    date.setMilliseconds(toInteger(values.milliseconds))
  }
Repository: date-fns/date-fns
File: src/locale/kk/_lib/localize/index.js (JavaScript)

Code before:
    'шіл',
    'там',
    'қыр',
    'қаз',
    'қар',
    'жел'
  ],
  wide: [
    'қаңтар',
    'ақпан',
    'наурыз',
    'сәуір',
    'мамыр',
    'маусым',
    'шілде',
    'тамыз',
    'қыркүйек',
    'қазан',
    'қараша',
    'желтоқсан'
  ]
}

var dayValues = {
  narrow: ['Ж', 'Д', 'С', 'С', 'Б', 'Ж', 'С'],
  short: ['жк', 'дй', 'сй', 'ср', 'бй', 'жм', 'сн'],
  abbreviated: ['жек', 'дүй', 'сей', 'сәр', 'бей', 'жұм', 'сен'],
  wide: [
    'жексенбі',
    'дүйсенбі',
    'сейсенбі',
    'сәрсенбі',
    'бейсенбі',
    'жұма',
    'сенбі'
  ]
}

var dayPeriodValues = {
  narrow: {
    am: 'ТД',
    pm: 'ТК',
    midnight: 'түн ортасы',
    noon: 'түс',
    morning: 'таң',
    afternoon: 'күндіз',
    evening: 'кеш',
    night: 'түн'
  },
  wide: {
    am: 'ТД',

Review comment (suggestion):
Can you cite where did you see such short usage of weekdays?

At [Astana Akimat official website](http://astana.gov.kz/) I could find `жс, дс, сс...` usage.

Code after:
    'шіл',
    'там',
    'қыр',
    'қаз',
    'қар',
    'жел'
  ],
  wide: [
    'қаңтар',
    'ақпан',
    'наурыз',
    'сәуір',
    'мамыр',
    'маусым',
    'шілде',
    'тамыз',
    'қыркүйек',
    'қазан',
    'қараша',
    'желтоқсан'
  ]
}

var dayValues = {
  narrow: ['Ж', 'Д', 'С', 'С', 'Б', 'Ж', 'С'],
  short: ['жс', 'дс', 'сс', 'ср', 'бс', 'жм', 'сб'],
  abbreviated: ['жс', 'дс', 'сс', 'ср', 'бс', 'жм', 'сб'],
  wide: [
    'жексенбі',
    'дүйсенбі',
    'сейсенбі',
    'сәрсенбі',
    'бейсенбі',
    'жұма',
    'сенбі'
  ]
}

var dayPeriodValues = {
  narrow: {
    am: 'ТД',
    pm: 'ТК',
    midnight: 'түн ортасы',
    noon: 'түс',
    morning: 'таң',
    afternoon: 'күндіз',
    evening: 'кеш',
    night: 'түн'
  },
  wide: {
    am: 'ТД',
Repository: date-fns/date-fns
File: src/formatISO/index.js (JavaScript)

Code before:
  if (representation !== 'date') {
    // Add the timezone.
    const offset = originalDate.getTimezoneOffset()

    if (offset !== 0 || format === 'extended') {
      const absoluteOffset = Math.abs(offset)
      const hourOffset = addLeadingZeros(absoluteOffset / 60, 2)
      const minuteOffset = addLeadingZeros(absoluteOffset % 60, 2)
      // If less than 0, the sign is +, because it is ahead of time.
      const sign = offset < 0 ? '+' : '-'

      tzOffset = `${sign}${hourOffset}:${minuteOffset}`
    } else {
      // The notation "Z" only applies for basic format AND if the timezone offset is 0.
      tzOffset = 'Z'
    }

    const hour = addLeadingZeros(originalDate.getHours(), 2)
    const minute = addLeadingZeros(originalDate.getMinutes(), 2)
    const second = addLeadingZeros(originalDate.getSeconds(), 2)

    // If there's also date, separate it with time with 'T'
    const separator = result === '' ? '' : 'T'

    // HHmmss or HH:mm:ss.
    result = `${result}${separator}${hour}${timeDelimiter}${minute}${timeDelimiter}${second}${tzOffset}`
  }

  return result
}


Review comment (suggestion):
now that I think about it, is it better to do `[hour, minute, second].join(timeDelimiter)` instead for readability purposes? 😅 

Code after:
  if (representation !== 'date') {
    // Add the timezone.
    const offset = originalDate.getTimezoneOffset()

    if (offset !== 0) {
      const absoluteOffset = Math.abs(offset)
      const hourOffset = addLeadingZeros(absoluteOffset / 60, 2)
      const minuteOffset = addLeadingZeros(absoluteOffset % 60, 2)
      // If less than 0, the sign is +, because it is ahead of time.
      const sign = offset < 0 ? '+' : '-'

      tzOffset = `${sign}${hourOffset}:${minuteOffset}`
    } else {
      tzOffset = 'Z'
    }

    const hour = addLeadingZeros(originalDate.getHours(), 2)
    const minute = addLeadingZeros(originalDate.getMinutes(), 2)
    const second = addLeadingZeros(originalDate.getSeconds(), 2)

    // If there's also date, separate it with time with 'T'
    const separator = result === '' ? '' : 'T'

    // Creates a time string consisting of hour, minute, and second, separated by delimiters, if defined.
    const time = [hour, minute, second].join(timeDelimiter)

    // HHmmss or HH:mm:ss.
    result = `${result}${separator}${time}${tzOffset}`
  }

  return result
}
Repository: date-fns/date-fns
File: src/add/index.js (JavaScript)

Code before:
 *
 * @example
 * // Add followind amount to 'Mon Sep 01 2014 10:20:00 GMT+0530 (India Standard Time)':
 * var result = add(new Date(2014, 8 , 1, 10, 19, 50, 10000), {
 *     milliseconds: 30000,
 *     seconds: 30,
 *     minutes: 9,
 *     hours: 5,
 *     days: 7,
 *     weeks: 1,
 *     months: 9,
 *     quarters: 5,
 *     years: 2
 *   })
 * => Sat Sep 15 2018 15:30:00 GMT+0530 (India Standard Time)
 */
export default function add(dirtyDate, givenAmount) {
  if (arguments.length < 2) {
    throw new TypeError(
      '2 arguments required, but only ' + arguments.length + ' present'
    )
  }

  if (!givenAmount) {
    return new Date(NaN)
  }
  const finalDate = toDate(dirtyDate)
  if (typeof givenAmount === 'number') {
    finalDate.setTime(finalDate.getTime() + givenAmount)
    return finalDate
  }
  if (Object.keys(givenAmount).length === 0) {
    return finalDate
  }
  let milliseconds = toInteger(givenAmount.milliseconds) || 0
  let seconds = toInteger(givenAmount.seconds) || 0
  let minutes = toInteger(givenAmount.minutes) || 0
  let hours = toInteger(givenAmount.hours) || 0
  let days = toInteger(givenAmount.days) || 0
  let months = toInteger(givenAmount.months) || 0
  const quarters = toInteger(givenAmount.quarters) || 0
  const weeks = toInteger(givenAmount.weeks) || 0
  const years = toInteger(givenAmount.years) || 0

  months += years * 12 + quarters * 3
  let desiredMonth = finalDate.getMonth() + months
  let dateWithDesiredMonth = new Date(0)
  dateWithDesiredMonth.setFullYear(finalDate.getFullYear(), desiredMonth, 1)
  dateWithDesiredMonth.setHours(0, 0, 0, 0)
  let daysInMonth = getDaysInMonth(dateWithDesiredMonth)
  finalDate.setMonth(desiredMonth, Math.min(daysInMonth, finalDate.getDate()))

Review comment (bug):
JavaScript throws `RangeError` whenever option values are wrong. Please do a simple object check instead:

```js
if (!duration || typeof duration !== 'object') throw new RangeError('duration must be an object')
```

Code after:
 *   years: 2,
 *   months: 24,
 *   days: 7,
 *   hours: 5,
 *   minutes: 9,
 *   seconds: 30,
 * })
 * //=> Sat Sep 8 2018 15:29:20
 */
export default function add(dirtyDate, duration) {
  requiredArgs(2, arguments)

  if (!duration || typeof duration !== 'object') return new Date(NaN)

  const years = 'years' in duration ? toInteger(duration.years) : 0
  const months = 'months' in duration ? toInteger(duration.months) : 0
  const days = 'days' in duration ? toInteger(duration.days) : 0
  const hours = 'hours' in duration ? toInteger(duration.hours) : 0
  const minutes = 'minutes' in duration ? toInteger(duration.minutes) : 0
  const seconds = 'seconds' in duration ? toInteger(duration.seconds) : 0

  // Add years and months
  const dateWithMonths = addMonths(toDate(dirtyDate), months + years * 12)

  // Add days, hours, minutes and seconds
  const hoursToAdd = hours + days * 24
  const minutesToAdd = minutes + hoursToAdd * 60
  const secondsToAdd = seconds + minutesToAdd * 60
  const msToAdd = secondsToAdd * 1000
  const finalDate = new Date(dateWithMonths.getTime() + msToAdd)

  return finalDate
}
Repository: date-fns/date-fns
File: src/getDay/index.js (JavaScript)

Code before:
import toDate from '../toDate/index.js'
import requiredArgs from '../_lib/requiredArgs/index.js'

/**
 * @name getDay
 * @category Weekday Helpers
 * @summary Get the day of the week of the given date.
 *
 * @description
 * Get the day of the week of the given date.
 *
 * ### v2.0.0 breaking changes:
 *
 * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
 *
 * @param {Date|Number} date - the given date
 * @returns {Number} the day of week
 * @throws {TypeError} 1 argument required
 *
 * @example
 * // Which day of the week is 29 February 2012?
 * var result = getDay(new Date(2012, 1, 29))
 * //=> 3
 */
export default function getDay(dirtyDate) {
  requiredArgs(1, arguments)

  var date = toDate(dirtyDate)
  var day = date.getDay()
  return day
}


Review comment (suggestion):
@kossnocorp I believe this is what you are referring to - I did commit the JSDoc change. I generated all other changes after via `./scripts/build/build.sh`.

Code after:
import toDate from '../toDate/index.js'
import requiredArgs from '../_lib/requiredArgs/index.js'

/**
 * @name getDay
 * @category Weekday Helpers
 * @summary Get the day of the week of the given date.
 *
 * @description
 * Get the day of the week of the given date.
 *
 * ### v2.0.0 breaking changes:
 *
 * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
 *
 * @param {Date|Number} date - the given date
 * @returns {0|1|2|3|4|5|6} the day of week
 * @throws {TypeError} 1 argument required
 *
 * @example
 * // Which day of the week is 29 February 2012?
 * var result = getDay(new Date(2012, 1, 29))
 * //=> 3
 */
export default function getDay(dirtyDate) {
  requiredArgs(1, arguments)

  var date = toDate(dirtyDate)
  var day = date.getDay()
  return day
}
Repository: date-fns/date-fns
File: src/locale/zh-CN/_lib/localize/index.js (JavaScript)

Code before:
    pm: '下午',
    midnight: '凌晨',
    noon: '中午',
    morning: '早晨',
    afternoon: '中午',
    evening: '晚上',
    night: '夜间'
  }
}

function ordinalNumber(dirtyNumber, dirtyOptions) {
  // If ordinal numbers depend on context, for example,
  // if they are different for different grammatical genders,
  // use `options.unit`:
  //
  //   var options = dirtyOptions || {}
  //   var unit = String(options.unit)
  //
  // where `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
  // 'day', 'hour', 'minute', 'second'
  var number = Number(dirtyNumber)
  var options = dirtyOptions || {}
  var unit = String(options.unit)

  if (unit === 'date') {
    return number.toString() + '号'
  }

  return '第 ' + number.toString()
}

var localize = {
  ordinalNumber: ordinalNumber,

  era: buildLocalizeFn({
    values: eraValues,
    defaultWidth: 'wide'
  }),

  quarter: buildLocalizeFn({
    values: quarterValues,
    defaultWidth: 'wide',
    argumentCallback: function(quarter) {
      return Number(quarter) - 1
    }
  }),

  month: buildLocalizeFn({
    values: monthValues,
    defaultWidth: 'wide'
  }),

Review comment (suggestion):
1. According to Chinese National Standard (GB/T 7408-2005), the unit of date should be '日' 
2. Could you explain why you remove code like `... unit === 'hour' || unit === 'minute' || unit === 'second' ... `
3. if put a unit for 'date', unit for  'hour' / 'minute' / 'second' might be necessary

Code after:
    pm: '下午',
    midnight: '凌晨',
    noon: '中午',
    morning: '早晨',
    afternoon: '中午',
    evening: '晚上',
    night: '夜间'
  }
}

function ordinalNumber(dirtyNumber, dirtyOptions) {
  // If ordinal numbers depend on context, for example,
  // if they are different for different grammatical genders,
  // use `options.unit`:
  //
  //   var options = dirtyOptions || {}
  //   var unit = String(options.unit)
  //
  // where `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
  // 'day', 'hour', 'minute', 'second'
  var number = Number(dirtyNumber)
  var options = dirtyOptions || {}
  var unit = String(options.unit)

  switch (unit) {
    case 'date':
      return number.toString() + '日'
    case 'hour':
      return number.toString() + '时'
    case 'minute':
      return number.toString() + '分'
    case 'second':
      return number.toString() + '秒'
    default:
      return '第 ' + number.toString()
  }
}

var localize = {
  ordinalNumber: ordinalNumber,

  era: buildLocalizeFn({
    values: eraValues,
    defaultWidth: 'wide'
  }),

  quarter: buildLocalizeFn({
    values: quarterValues,
    defaultWidth: 'wide',
    argumentCallback: function(quarter) {
      return Number(quarter) - 1
Repository: date-fns/date-fns
File: src/intlFormat/index.ts (TypeScript)

Code before:
import requiredArgs from '../_lib/requiredArgs/index'

type Locale = Intl.ResolvedDateTimeFormatOptions['locale']
type FormatOptions = Intl.DateTimeFormatOptions
type LocaleOptions = { locale: Locale | Locale[] }

export default function intlFormat(date: Date): string
export default function intlFormat(date: Date, locale: LocaleOptions): string
export default function intlFormat(
  date: Date,
  formatOptions: FormatOptions
): string
export default function intlFormat(
  date: Date,
  formatOptions: FormatOptions,
  locale: LocaleOptions
): string
export default function intlFormat(
  date: Date,
  formatOrLocale?: FormatOptions | LocaleOptions,
  localeOptions?: LocaleOptions
) {
  requiredArgs(1, arguments)

  let formatOptions: FormatOptions | undefined

  if (isFormatOptions(formatOrLocale)) {
    formatOptions = formatOrLocale
  } else {
    assertIsUndefined(
      localeOptions,
      new TypeError("Can't provide 2 locales for the function")
    )
    localeOptions = formatOrLocale
  }

  return new Intl.DateTimeFormat(localeOptions?.locale, formatOptions).format(
    date
  )
}

function isFormatOptions(
  opts: LocaleOptions | FormatOptions | undefined
): opts is FormatOptions {
  return opts !== undefined && !('locale' in opts)
}

function assertIsUndefined(opts: unknown, error: Error) {
  if (opts !== undefined) {
    throw error
  }
}


Review comment (suggestion):
Let's not assert this. I know that the rest of the library does similar checks, but in v3 I want to remove runtime checks and make users rely on the type systems. This will make the library leaner and faster.

Code after:
export default function intlFormat(
  date: Date,
  localeOptions: LocaleOptions
): string
export default function intlFormat(
  date: Date,
  formatOptions: FormatOptions
): string
export default function intlFormat(
  date: Date,
  formatOptions: FormatOptions,
  localeOptions: LocaleOptions
): string
export default function intlFormat(
  date: Date,
  formatOrLocale?: FormatOptions | LocaleOptions,
  localeOptions?: LocaleOptions
): string {
  requiredArgs(1, arguments)

  let formatOptions: FormatOptions | undefined

  if (isFormatOptions(formatOrLocale)) {
    formatOptions = formatOrLocale
  } else {
    localeOptions = formatOrLocale
  }

  return new Intl.DateTimeFormat(localeOptions?.locale, formatOptions).format(
    date
  )
}

function isFormatOptions(
  opts: LocaleOptions | FormatOptions | undefined
): opts is FormatOptions {
  return opts !== undefined && !('locale' in opts)
}
Repository: date-fns/date-fns
File: src/intlFormat/index.ts (TypeScript)

Code before:
 * const result = intlFormat.default(new Date(2019, 9, 4, 12, 30, 13, 456), {
 *      year: 'numeric',
 *      month: 'numeric',
 *      day: 'numeric',
 *      hour: 'numeric',
 *  })
 * //=> 10/4/2019, 12 PM
 *
 * @example
 * // Represent 10 October 2019 in Korean.
 * // Convert the date with locale's options.
 * const result = intlFormat(new Date(2019, 9, 4, 12, 30, 13, 456), {
 *      locale: 'ko-KR',
 *  })
 * //=> 2019. 10. 4.
 *
 * @example
 * // Represent 10 October 2019 in middle-endian format:
 * const result = intlFormat(new Date(2019, 9, 4, 12, 30, 13, 456))
 * //=> 10/4/2019
 */
export default function intlFormat(
  date: Date,
  formatOrLocale?: FormatOptions | LocaleOptions,
  localeOptions?: LocaleOptions
) {
  requiredArgs(1, arguments)

  let formatOptions: FormatOptions | undefined

  if (isFormatOptions(formatOrLocale)) {
    formatOptions = formatOrLocale
  } else {
    localeOptions = formatOrLocale
  }

  return new Intl.DateTimeFormat(localeOptions?.locale, formatOptions).format(
    date
  )
}

function isFormatOptions(
  opts: LocaleOptions | FormatOptions | undefined
): opts is FormatOptions {
  return opts !== undefined && !('locale' in opts)
}


Review comment (suggestion):
Let's force return type at all times.

```suggestion
): string {
```

Code after:
 *
 * @example
 * // Represent 10 October 2019 in middle-endian format:
 * const result = intlFormat(new Date(2019, 9, 4, 12, 30, 13, 456))
 * //=> 10/4/2019
 */

export default function intlFormat(date: Date): string
export default function intlFormat(
  date: Date,
  localeOptions: LocaleOptions
): string
export default function intlFormat(
  date: Date,
  formatOptions: FormatOptions
): string
export default function intlFormat(
  date: Date,
  formatOptions: FormatOptions,
  localeOptions: LocaleOptions
): string
export default function intlFormat(
  date: Date,
  formatOrLocale?: FormatOptions | LocaleOptions,
  localeOptions?: LocaleOptions
): string {
  requiredArgs(1, arguments)

  let formatOptions: FormatOptions | undefined

  if (isFormatOptions(formatOrLocale)) {
    formatOptions = formatOrLocale
  } else {
    localeOptions = formatOrLocale
  }

  return new Intl.DateTimeFormat(localeOptions?.locale, formatOptions).format(
    date
  )
}

function isFormatOptions(
  opts: LocaleOptions | FormatOptions | undefined
): opts is FormatOptions {
  return opts !== undefined && !('locale' in opts)
}
Repository: date-fns/date-fns
File: src/nextMonday/index.ts (TypeScript)

Code before:
 * When is the next Monday after Mar, 22, 2020?
 * var result = nextMonday(new Date(2020, 2, 22))
 * => new Date(2020, 2, 23)
 **/
export default function nextMonday(date: Date): Date {
  requiredArgs(1, arguments)
  const convertedDate = toDate(date)

  switch (getDay(convertedDate)) {
    case 0:
      return addDays(convertedDate, 1)
    case 1:
      return addDays(convertedDate, 7)
    case 2:
      return addDays(convertedDate, 6)
    case 3:
      return addDays(convertedDate, 5)
    case 4:
      return addDays(convertedDate, 4)
    case 5:
      return addDays(convertedDate, 3)
    case 6:
      return addDays(convertedDate, 2)
    default:
      return convertedDate
  }
}


Review comment (suggestion):
```suggestion
  return addDays(date, map[getDay(date)])
```

Code after:
import requiredArgs from '../_lib/requiredArgs/index'
import nextDay from '../nextDay/index'
import toDate from '../toDate/index'

/**
 * @name nextMonday
 * @category Weekday Helpers
 * @summary When is the next Monday?
 *
 * @description
 * When is the next Monday?
 *
 * @param {Date | number} date - the date to check
 * @returns {Date} - the date is the next Monday
 * @throws {TypeError} - the date should be a valid date
 * @throws {TypeError} - 1 argument required
 *
 * @example
 * When is the next Monday after Mar, 22, 2020?
 * const result = nextMonday(new Date(2020, 2, 22))
 * => Mon Mar 23 2020 00:00:00
 **/
export default function nextMonday(date: Date | number): Date {
  requiredArgs(1, arguments)
  return nextDay(toDate(date), 1)
}
Repository: date-fns/date-fns
File: src/nextMonday/index.ts (TypeScript)

Code before:
import requiredArgs from '../_lib/requiredArgs/index'
import getDay from '../getDay'
import addDays from '../addDays'
import toDate from '../toDate/index'
/**
 * @name nextMonday
 * @category Weekday Helpers
 * @summary When is the next Monday?
 *
 * @description
 * When is the next Monday?
 * {0|1|2|3|4|5|6} the day of week, 0 represents Sunday
 *
 * @param {Date} date - the date to check
 * @returns {Date} the date is Monday
 * @throws {TypeError} 1 argument required
 *
 * @example
 * When is the next Monday after Mar, 22, 2020?
 * var result = nextMonday(new Date(2020, 2, 22))
 * => new Date(2020, 2, 23)
 **/
export default function nextMonday(date: Date): Date {
  requiredArgs(1, arguments)
  const convertedDate = toDate(date)

  switch (getDay(convertedDate)) {
    case 0:
      return addDays(convertedDate, 1)
    case 1:

Review comment (suggestion):
```suggestion

const map = [1, 7, 6, 5, 4, 3, 2]

/**
```

Code after:
import requiredArgs from '../_lib/requiredArgs/index'
import nextDay from '../nextDay/index'
import toDate from '../toDate/index'

/**
 * @name nextMonday
 * @category Weekday Helpers
 * @summary When is the next Monday?
 *
 * @description
 * When is the next Monday?
 *
 * @param {Date | number} date - the date to check
 * @returns {Date} - the date is the next Monday
 * @throws {TypeError} - the date should be a valid date
 * @throws {TypeError} - 1 argument required
 *
 * @example
 * When is the next Monday after Mar, 22, 2020?
 * const result = nextMonday(new Date(2020, 2, 22))
 * => Mon Mar 23 2020 00:00:00
 **/
export default function nextMonday(date: Date | number): Date {
  requiredArgs(1, arguments)
  return nextDay(toDate(date), 1)
}