aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node_modules/@fastify/busboy/lib/utils/getLimit.js
blob: cb64fd6721aaccfccb37525a3049ff639dd39666 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'use strict'

module.exports = function getLimit (limits, name, defaultLimit) {
  if (
    !limits ||
    limits[name] === undefined ||
    limits[name] === null
  ) { return defaultLimit }

  if (
    typeof limits[name] !== 'number' ||
    isNaN(limits[name])
  ) { throw new TypeError('Limit ' + name + ' is not a valid number') }

  return limits[name]
}