{"id":11463,"library":"normalize-range","title":"Numeric Range Normalization Utility","description":"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.","status":"abandoned","version":"0.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/jamestalmage/normalize-range","tags":["javascript","range","normalize","utility","angle","degrees","polar"],"install":[{"cmd":"npm install normalize-range","lang":"bash","label":"npm"},{"cmd":"yarn add normalize-range","lang":"bash","label":"yarn"},{"cmd":"pnpm add normalize-range","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and does not provide an ESM export. Direct ESM imports will fail.","wrong":"import nr from 'normalize-range';\n// or\nimport * as nr from 'normalize-range';","symbol":"normalize-range module","correct":"const nr = require('normalize-range');"},{"note":"While direct destructuring from `require` is common, the module itself is CommonJS-only and ESM imports are not supported.","wrong":"import { wrap } from 'normalize-range';","symbol":"wrap function","correct":"const { wrap } = require('normalize-range');"},{"note":"Accessing curried functions or specific methods directly requires `require()` syntax as the package is CommonJS-only.","wrong":"import { curry } from 'normalize-range';","symbol":"curry function","correct":"const curryRange = require('normalize-range').curry;"}],"quickstart":{"code":"const nr = require('normalize-range');\n\nconsole.log('Wrapping 400 in (0, 360):', nr.wrap(0, 360, 400));\n//=> 40\nconsole.log('Wrapping -90 in (0, 360):', nr.wrap(0, 360, -90));\n//=> 270\nconsole.log('Limiting 500 in (0, 100):', nr.limit(0, 100, 500));\n//=> 100\nconsole.log('Limiting -20 in (0, 100):', nr.limit(0, 100, -20));\n//=> 0\n\n// Currying example for convenience\nconst wrapAngle = nr.curry(0, 360).wrap;\nconst limitTo10 = nr.curry(0, 10).limit;\n\nconsole.log('Curried wrapAngle(-30):', wrapAngle(-30));\n//=> 330\nconsole.log('Curried limitTo10(15):', limitTo10(15));\n//=> 10","lang":"javascript","description":"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."},"warnings":[{"fix":"Use dynamic `import('normalize-range').then(nr => ...)` or transpilation if targeting a mixed environment, or ensure your file is a CommonJS module using `require()`.","message":"This package is CommonJS-only and lacks native ES module (ESM) support. Attempting to `import` it directly in an ES module environment will result in errors.","severity":"breaking","affected_versions":">=0.1.2"},{"fix":"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`.","message":"The `wrap` function treats the `min` value as inclusive and the `max` value as exclusive (e.g., `wrap(0, 360, 360)` returns `0`). In contrast, the `limit` function treats both `min` and `max` as inclusive.","severity":"gotcha","affected_versions":">=0.1.2"},{"fix":"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.","message":"The `normalize-range` package is no longer actively maintained. The last commit and release occurred approximately 8 years ago. Consider potential security implications or lack of compatibility with newer JavaScript features or environments.","severity":"deprecated","affected_versions":">=0.1.2"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"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\"`).","cause":"Attempting to use `require()` within a JavaScript file that is being treated as an ES module (e.g., due to `\"type\": \"module\"` in `package.json` or `.mjs` extension).","error":"ReferenceError: require is not defined in ES module scope"},{"fix":"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)`.","cause":"This typically occurs when a bundler or transpiler tries to convert a CommonJS `require` into an ESM `import` in a way that doesn't correctly handle the module's default export, or when directly trying to destructure from an incorrectly imported CJS module.","error":"TypeError: (0, _normalizeRange.wrap) is not a function"}],"ecosystem":"npm"}