{"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,"search_vec":"'-360':70 '0':69 '0.1.2':37 '1':65 '361':62 '8':40 'activ':49 'ago':42 'angl':28,129 'appli':97 'applic':23 'approxim':39 'around':60 'assert':87 'becom':64 'boundari':110 'check':84 'clamp':74 'control':120 'coordin':31 'core':52 'creat':95 'current':33 'curri':93 'cyclic':25 'degre':63,66,130 'design':12 'differ':112 'differenti':102 'e.g':61 'explicit':105 'fix':78 'function':53,99 'handl':106 'includ':54 'inclus':79 'inclusive/exclusive':108 'indic':43 'involv':24 'javascript':125 'key':101 'like':27 'limit':72,116 'longer':48 'maintain':50 'normal':3,6,14,123,127 'normalize-rang':5 'numer':1,15 'oper':117 'packag':11,45 'partial':96 'particular':20 'polar':30,131 'precis':119 'provid':118 'rang':2,7,19,71,80,83,91,98,109,126 'releas':38 'scenario':124 'specifi':18 'stabl':34 'system':26 'test':81 'use':21 'util':4,10,128 'valid':85 'valu':16,57,75,88 'various':122 'version':35 'within':17,76,89 'wrap':55,59,114 'year':41","created_at":"2026-04-19T13:38:07.667206+00:00","updated_at":"2026-04-19T13:38:07.667206+00:00","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","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/jamestalmage/normalize-range","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/normalize-range","openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}