{"_id":"drange@2.1.0","bugs":{"url":"https://github.com/fent/node-drange/issues"},"dist":{"shasum":"3aaadb901241b391d29158c31655449495ae2a59","tarball":"http://registry-npm.ywwl.com/drange/download/drange-2.1.0.tgz","fileCount":6,"integrity":"sha512-iCkOtdldk0yyAtCCXfCOFtrbFBrkk2kn/rIY/W8mlH30IIIm7jfGtqnmZ6BIGuhqOWGo4H+Rbj+k5UO+tL/oPw==","signatures":[{"sig":"MEYCIQDArpsjSVvq6jXQzv6l/ZC/MPl5DINhVOvoFqnouDhFGQIhAJ8tEawEjx5PEdVFB2fob8HoQ16a6BX96R8DSlmA50ZX","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD9whJBsi3kvGwoxoXFlo6K9B1zy9pGYeZ6qTq0m+J4xQIhAKqaUIRpF7QAiIT1Bibvk3NEnTzgIWAuvSga7m9iy+vo"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/drange@2.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":19169,"size":5155,"noattachment":false,"key":"/drange/-/drange-2.1.0.tgz"},"main":"./dist/index.js","name":"drange","types":"./dist/index.d.ts","author":{"url":"https://github.com/fent","name":"fent","email":"fentbox@gmail.com"},"engines":{"node":">=20"},"gitHead":"e572531c338fe2c73370de3d21b24e4dd43d71f8","license":"MIT","scripts":{"lint":"biome check .","test":"nyc --extension .ts --reporter=lcov --reporter=text-summary npm run test:unit && npm run test:package","build":"tsc -p tsconfig.build.json","prepare":"tsc -p tsconfig.build.json","pretest":"npm run build","lint:fix":"biome check --write .","test:unit":"mocha --require ts-node/register --ignore test/export-test.ts test/*-test.ts","test:types":"npm run build && tsc -p test/types","test:package":"mocha --require ts-node/register test/export-test.ts"},"version":"2.1.0","_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.1","contributors":[{"url":"https://github.com/fent","name":"fent"}],"_hasShrinkwrap":false,"devDependencies":{"nyc":"^18.0.0","mocha":"^12.0.3","ts-node":"^10.9.2","typescript":"^5.9.3","@types/node":"^22.20.5","@types/mocha":"^10.0.10","@biomejs/biome":"^2.5.15"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/drange_2.1.0_1794519796923_0.21240945106914533"},"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# TypeScript\n\nDRange ships with TypeScript definitions.\n\n```typescript\nimport DRange from 'drange'; // requires esModuleInterop\n```\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":1794519797017,"_cnpm_publish_time":1794519797017,"dist-tags":{"latest":"2.1.0"}}