UNPKG

mongo-url-utils

Version:

url parser utilities for connecting with mongodb

12 lines (9 loc) 315 B
const is = require('is'); function limit(s) { const n = parseInt(s, 10); if (!is.int(n)) throw new Error('limit must be an integer'); if (n.toString() !== s) throw new Error('limit must be an integer'); if (n < 0) throw new Error('limit must be a positive integer'); return n; } module.exports = limit;