{"_id":"enforce-range","_rev":"2-e8459bf8bdad57a5948064a1cfd23c5f","name":"enforce-range","description":"Enforce a minimum and/or maximum value for a number.","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"enforce-range","version":"1.0.0","description":"Enforce a minimum and/or maximum value for a number.","keywords":["number","range","min","minimum","max","maximum","value"],"author":{"name":"John Lamansky"},"license":"MIT","homepage":"https://github.com/lamansky/enforce-range","repository":{"type":"git","url":"git+https://github.com/lamansky/enforce-range.git"},"main":"index.js","files":[],"dependencies":{"2":"^1.0.2"},"devDependencies":{"eslint-config-lamansky":"^1.0.0","mocha":"^4.0.1"},"scripts":{"test":"mocha"},"eslintConfig":{"extends":"lamansky","env":{"mocha":true}},"gitHead":"fe3c70c8866f5d0224470ef57f55dac6dbec5ab2","bugs":{"url":"https://github.com/lamansky/enforce-range/issues"},"_id":"enforce-range@1.0.0","_shasum":"f10ccc0396e23684b413d73661d020d192e5ba70","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"lamansky","email":"johnlamansky@gmail.com"},"dist":{"shasum":"f10ccc0396e23684b413d73661d020d192e5ba70","tarball":"https://registry.npmjs.org/enforce-range/-/enforce-range-1.0.0.tgz","integrity":"sha512-iOYthPljA5P/S823In8avtTbeUl8/uTP1+pqy08ryb8jeMO2enuIO/f72QFFqT4GTNiOe0yWPIzXB9nR3u6O5A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAZaqLBZXD+aZjyEsMsgARngSL/T+NS9x0WX/Av5uKxUAiAKZGTxoW5F6yxEbJ2jC9+ASMWwF+7Spq0CIGsZ/qpd2Q=="}]},"maintainers":[{"name":"lamansky","email":"johnlamansky@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/enforce-range-1.0.0.tgz_1512828359960_0.2076918443199247"}}},"readme":"# enforce-range\n\nEnforce a minimum and/or maximum value for a number.\n\n## Installation\n\n```bash\nnpm install enforce-range --save\n```\n\n## Usage\n\n```javascript\nconst enforceRange = require('enforce-range')\n\n// Number should be between 0 and 100\nenforceRange(0, 100, 51) // 51\nenforceRange(0, 100, -123) // 0\nenforceRange(0, 100, 456) // 100\n```\n\n### Partial Application\n\nIf you provide only the first two arguments (a minimum and a maximum value), the module will create a partially-applied function which enforces that range. Here's the above example repeated with this usage mode:\n\n```javascript\nconst enforce0to100 = require('enforce-range')(0, 100)\n\n// Number should be between 0 and 100\nenforce0to100(51) // 51\nenforce0to100(-123) // 0\nenforce0to100(456) // 100\n```\n\n### Open-Ended Ranges\n\nIf, for some reason, you want this module to enforce a range that is only bound on one end, you can do so by passing `null` or ±`Infinity` as the minimum/maximum value. (However, in such a case you’re probably better off cutting the overhead of using a module and just using `Math.min()` or `Math.max()`.)\n\n```javascript\nconst enforceRange = require('enforce-range')\n\n// Maximum only\nenforceRange(null, 100, 200) // 100\nenforceRange(-Infinity, 100, 200) // 100\n\n// Minimum only\nenforceRange(0, null, 51) // 51\nenforceRange(0, Infinity, 51) // 51\n\n// No range enforcement at all (module does nothing)\nenforceRange(null, null, 12345) // 12345\nenforceRange(-Infinity, Infinity, 12345) // 12345\n```\n","maintainers":[{"name":"lamansky","email":"johnlamansky@gmail.com"}],"time":{"modified":"2022-06-17T05:18:13.317Z","created":"2017-12-09T14:06:00.118Z","1.0.0":"2017-12-09T14:06:00.118Z"},"homepage":"https://github.com/lamansky/enforce-range","keywords":["number","range","min","minimum","max","maximum","value"],"repository":{"type":"git","url":"git+https://github.com/lamansky/enforce-range.git"},"author":{"name":"John Lamansky"},"bugs":{"url":"https://github.com/lamansky/enforce-range/issues"},"license":"MIT","readmeFilename":"readme.md"}