{"library":"node-range","title":"Node Range - Lazy Sequence Generator","description":"Node-range is a JavaScript utility package designed to generate lazy sequences (ranges) of numbers, offering methods like `map`, `forEach`, and `forEachAsync` that operate without fully materializing the entire sequence into memory upfront. This can be beneficial for performance and memory usage when dealing with very large ranges. The package's current and only stable version is 0.1.0, last published over a decade ago in January 2015. Due to its age, it relies on older CommonJS module patterns and lacks support for modern JavaScript features like native Promises (it uses callbacks for async operations) or TypeScript definitions. Its claim of being \"faster than Array.map\" might be outdated due to significant V8 engine optimizations in modern Node.js. Given its lack of updates, it is no longer maintained and should be used with caution, if at all.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install node-range"],"cli":null},"imports":["const range = require('node-range');","const range = require('node-range');\n// Then use range(start, end)","const rangeInstance = require('node-range')(1, 11);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const range = require('node-range');\n\nconsole.log('--- Lazy Map Example ---');\n// Generate a lazy range from 1 to 10 (exclusive of 11), and map each element\n// The array is only materialized when needed (e.g., by console.log or when iteration completes)\nconst mappedArr = range(1, 11).map(function(i) {\n    return i * 5;\n});\nconsole.log('Result of lazy map:', mappedArr);\n\nconsole.log('\\n--- To Array and Map Example ---');\n// Convert to an array first, then use standard Array.prototype.map\nconst toArrayAndMap = range(1, 11).toArray().map(function(i) {\n    return i * 2;\n});\nconsole.log('Result of toArray().map:', toArrayAndMap);\n\nconsole.log('\\n--- Synchronous ForEach Example ---');\n// Execute a function for each item in the range without returning an array\nrange(1, 5).forEach(function(i) {\n    console.log('forEach sync:', Math.pow(i, 2));\n});\n\nconsole.log('\\n--- Asynchronous ForEach (Callback-based) Example ---');\n// Execute a function asynchronously for each item (callback-based)\n// Note: This is non-blocking but uses older callback patterns\nrange(1, 3).forEachAsync(function(i) {\n    console.log('forEachAsync num:', i);\n});\nconsole.log('This should come first (demonstrating async nature)');","lang":"javascript","description":"This quickstart demonstrates creating lazy numerical ranges, applying transformations with `map` (lazy and eager), iterating with `forEach` for synchronous operations, and `forEachAsync` for non-blocking iteration using callbacks.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}