normalize-range is a utility package designed to normalize numeric values within specified ranges, particularly useful for applications involving cyclical systems like angles or polar coordinates. The current stable version is 0.1.2, released approximately 8 years ago, indicating the package is no longer actively maintained. Its core functionality includes `wrap` for values that "wrap around" (e.g., 361 degrees becoming 1 degree in a 0-360 range), `limit` for clamping values within a fixed inclusive range, `test` for range checking, `validate` for asserting values within a range, and `curry` for creating partially applied range functions. A key differentiator is its explicit handling of inclusive/exclusive range boundaries, which differs between `wrap` and `limit` operations, providing precise control for various normalization scenarios.
npm install normalize-rangeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the core `wrap` and `limit` functions, along with the `curry` utility for creating partially applied range functions, showcasing how to normalize values in both cyclical and bounded ranges.
Use dynamic `import('normalize-range').then(nr => ...)` or transpilation if targeting a mixed environment, or ensure your file is a CommonJS module using `require()`.Carefully review the API documentation for `wrap` and `limit` to ensure correct boundary handling based on your specific use case, especially when dealing with edge values equal to `min` or `max`.
Evaluate alternative, actively maintained range normalization libraries if long-term support, security updates, or new features are critical. If continuing to use this package, be aware of its unmaintained status.
If your project is ESM-only, use dynamic import: `import('normalize-range').then(nrModule => { const nr = nrModule; /* ... */ });`. Alternatively, ensure the file using `require()` is a CommonJS module (e.g., `.js` file in a non-module project, or explicitly marked as `"type": "commonjs"`).Ensure that `normalize-range` is imported using the standard CommonJS `require` syntax: `const nr = require('normalize-range');` and then access methods like `nr.wrap(min, max, value)`.No dependency data recorded yet.