diff options
Diffstat (limited to 'fastify-busboy/lib/utils/getLimit.js')
-rw-r--r-- | fastify-busboy/lib/utils/getLimit.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fastify-busboy/lib/utils/getLimit.js b/fastify-busboy/lib/utils/getLimit.js new file mode 100644 index 0000000..cb64fd6 --- /dev/null +++ b/fastify-busboy/lib/utils/getLimit.js @@ -0,0 +1,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] +} |