{"_id":"drange@2.0.2","bugs":{"url":"https://github.com/fent/node-drange/issues"},"dist":{"shasum":"77e24c76b2bcf5356b9989107a434f45a3e9d201","tarball":"http://registry-npm.ywwl.com/drange/download/drange-2.0.2.tgz","fileCount":5,"integrity":"sha512-g3Y2hWzX5bTyGMlpX0AzxHO5/C/jFFEyHtzO3EdsWvfiuXZnyVH/KjQIy79wTLzLjZf5qWBmQmo63ZDKOG/Ukw==","signatures":[{"sig":"MEQCIAbk5Z6Ay8HEw71dEoQyVLl97KbiRT3NkLLoy/mx/FlkAiAJjw6k7GwgpMPSGyHq2tNuCRxXoKCA9IjVpffQvSGXMA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDl7i4cF1Udsdfx1H0Khh3W3t3UxXdPkbc18+cTEjte3QIhAPnO0Bg/4jeF0nIYca+equjQnRLct8rnp8azNN098fgj"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/drange@2.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":10290,"size":3546,"noattachment":false,"key":"/drange/-/drange-2.0.2.tgz"},"main":"lib/index.js","name":"drange","types":"./types","author":{"url":"https://github.com/fent","name":"fent","email":"fentbox@gmail.com"},"engines":{"node":">=20"},"gitHead":"b112556ab668f813c3553955c61d6b7ea90b65ec","license":"MIT","scripts":{"lint":"biome check .","test":"nyc --reporter=lcov --reporter=text-summary mocha -- test/*-test.js","lint:fix":"biome check --write .","test:types":"tsc -p types"},"version":"2.0.2","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"fe21e28e-4f86-4a7f-91d4-419c14c82dcc"}},"homepage":"https://github.com/fent/node-drange#readme","keywords":["discontinuous","range","set"],"repository":{"url":"git+https://github.com/fent/node-drange.git","type":"git"},"_npmVersion":"11.21.2","description":"For adding, subtracting, and indexing discontinuous ranges of numbers","directories":{},"maintainers":[{"name":"fent","email":"fentbox@gmail.com"}],"sideEffects":false,"_nodeVersion":"26.13.0","contributors":[{"url":"https://github.com/fent","name":"fent"}],"_hasShrinkwrap":false,"devDependencies":{"nyc":"^18.0.0","mocha":"^12.0.3","typescript":"^7.0.2","@biomejs/biome":"^2.5.15"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/drange_2.0.2_1794078850807_0.32092419697195096"},"readme":"# drange\n\nFor adding/subtracting sets of range of numbers.\n\n[![npm version](https://img.shields.io/npm/v/drange.svg)](https://npmjs.org/package/drange)\n[![Node CI](https://github.com/fent/node-drange/actions/workflows/nodejs.yml/badge.svg)](https://github.com/fent/node-drange/actions/workflows/nodejs.yml)\n[![codecov](https://codecov.io/gh/fent/node-drange/branch/master/graph/badge.svg)](https://codecov.io/gh/fent/node-drange)\n\n# Usage\n\n```\nconst DRange = require('drange');\n\nlet allNums = new DRange(1, 100); //[ 1-100 ]\nlet badNums = DRange(13).add(8).add(60,80); //[8, 13, 60-80]\nlet goodNums = allNums.clone().subtract(badNums);\nconsole.log(goodNums.toString()); //[ 1-7, 9-12, 14-59, 81-100 ]\nlet randomGoodNum = goodNums.index(Math.floor(Math.random() * goodNums.length));\n```\n\n# API\n### new DRange([low], [high])\nCreates a new instance of DRange.\n\n### DRange#length\nThe total length of all subranges\n\n### DRange#add(low, high)\nAdds a subrange\n\n### DRange#add(drange)\nAdds all of another DRange's subranges\n\n### DRange#subtract(low, high)\nSubtracts a subrange\n\n### DRange#subtract(drange)\nSubtracts all of another DRange's subranges\n\n### DRange#intersect(low, range)\nKeep only subranges that overlap the given subrange\n\n### DRange#intersect(drange)\nIntersect all of another DRange's subranges\n\n### DRange#index(i)\nGet the number at the specified index\n\n```js\nlet drange = new DRange()\ndrange.add(1, 10);\ndrange.add(21, 30);\nconsole.log(drange.index(15)); // 25\n```\n\n### DRange#numbers()\nGet contained numbers\n\n```js\nlet drange = new DRange(1, 4)\ndrange.add(6);\ndrange.subtract(2);\nconsole.log(drange.numbers()); // [1, 3, 4, 6]\n```\n\n### DRange#subranges()\nGet copy of subranges\n\n```js\nlet drange = new DRange(1, 4)\ndrange.add(6, 8);\nconsole.log(drange.subranges());\n/*\n[\n  { low: 1, high: 4, length: 4 },\n  { low: 6, high: 8, length: 3 }\n]\n*/\n```\n\n### DRange#clone()\nClones the drange, so that changes to it are not reflected on its clone\n\n\n# Install\n\n    npm install drange\n\n# Tests\n\nTests are written with [mocha](https://mochajs.org)\n\n    npm test\n\n# Integration with TypeScript\n\nDRange includes TypeScript definitions.\n\n```typescript\nimport * as DRange from \"drange\";\nconst range: DRange = new Drange(2, 5);\n```\n\nUse dtslint to check the definition file.\n\n    npm install -g dtslint\n    npm run dtslint\n\n# Security\n\nTo report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.\n","publish_time":1794078850906,"_cnpm_publish_time":1794078850906,"dist-tags":{"latest":"2.1.0"}}