{"_id":"drange","_rev":"303486","name":"drange","description":"For adding, subtracting, and indexing discontinuous ranges of numbers","dist-tags":{"latest":"2.0.1"},"maintainers":[{"name":"fent","email":"fentbox@gmail.com"}],"time":{"modified":"2021-06-03T19:23:36.000Z","created":"2018-02-11T14:47:12.283Z","2.0.1":"2020-07-21T19:26:49.822Z","2.0.0":"2018-09-20T14:12:53.824Z","1.1.1":"2018-09-20T14:06:25.835Z","1.1.0":"2018-09-15T19:24:03.434Z","1.0.2":"2018-06-06T05:10:11.930Z","1.0.1":"2018-03-05T14:14:19.033Z","1.0.0":"2018-02-11T14:47:12.283Z"},"users":{},"author":{"name":"fent","email":"fentbox@gmail.com","url":"https://github.com/fent"},"repository":{"type":"git","url":"git+https://github.com/fent/node-drange.git"},"versions":{"2.0.1":{"name":"drange","version":"2.0.1","description":"For adding, subtracting, and indexing discontinuous ranges of numbers","keywords":["discontinuous","range","set"],"main":"lib/index.js","scripts":{"test":"istanbul cover node_modules/.bin/_mocha -- test/*-test.js","dtslint":"dtslint types"},"repository":{"type":"git","url":"git+https://github.com/fent/node-drange.git"},"author":{"name":"fent","email":"fentbox@gmail.com","url":"https://github.com/fent"},"contributors":[{"name":"fent","url":"https://github.com/fent"}],"devDependencies":{"istanbul":"^0.4.5","mocha":"^6.2.0"},"engines":{"node":">=6"},"license":"MIT","types":"./types","gitHead":"3546637a6188df35c2dcb25a9aefeef7be77f8b2","bugs":{"url":"https://github.com/fent/node-drange/issues"},"homepage":"https://github.com/fent/node-drange#readme","_id":"drange@2.0.1","_nodeVersion":"14.3.0","_npmVersion":"6.14.6","_npmUser":{"name":"fent","email":"fentbox@gmail.com"},"dist":{"shasum":"a1d831c5216359cd0993730b77d140ef3a3734e9","size":3406,"noattachment":false,"key":"/drange/-/drange-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/drange/download/drange-2.0.1.tgz"},"maintainers":[{"name":"fent","email":"fentbox@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/drange_2.0.1_1595359609689_0.6556495402532494"},"_hasShrinkwrap":false,"publish_time":1595359609822,"_cnpm_publish_time":1595359609822},"2.0.0":{"name":"drange","version":"2.0.0","description":"For adding, subtracting, and indexing discontinuous ranges of numbers","keywords":["discontinuous","range","set"],"main":"lib/index.js","scripts":{"test":"istanbul cover node_modules/.bin/_mocha -- test/*-test.js","dtslint":"dtslint types"},"repository":{"type":"git","url":"git+https://github.com/fent/node-drange.git"},"author":{"name":"David Tudury","email":"david.tudury@gmail.com"},"contributors":[{"name":"fent","url":"https://github.com/fent"}],"devDependencies":{"istanbul":"^0.4.5","mocha":"^5.0.0"},"engines":{"node":">=6"},"license":"MIT","types":"./types","gitHead":"0bd798884733bde47446d5ac4ab23add45da534d","bugs":{"url":"https://github.com/fent/node-drange/issues"},"homepage":"https://github.com/fent/node-drange#readme","_id":"drange@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"fent","email":"fentbox@gmail.com"},"dist":{"shasum":"2c2e70a58f2865eb5e70ed8a276273a5a3564b56","size":3350,"noattachment":false,"key":"/drange/-/drange-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/drange/download/drange-2.0.0.tgz"},"maintainers":[{"name":"fent","email":"fentbox@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/drange_2.0.0_1537452773722_0.41039513435070285"},"_hasShrinkwrap":false,"publish_time":1537452773824,"_cnpm_publish_time":1537452773824},"1.1.1":{"name":"drange","version":"1.1.1","description":"For adding, subtracting, and indexing discontinuous ranges of numbers","keywords":["discontinuous","range","set"],"main":"lib/index.js","scripts":{"test":"istanbul cover node_modules/.bin/_mocha -- test/*-test.js","dtslint":"dtslint types"},"repository":{"type":"git","url":"git+https://github.com/fent/node-drange.git"},"author":{"name":"David Tudury","email":"david.tudury@gmail.com"},"contributors":[{"name":"fent","url":"https://github.com/fent"}],"devDependencies":{"istanbul":"^0.4.5","mocha":"^5.0.0"},"engines":{"node":">=4"},"license":"MIT","types":"./types","gitHead":"fc4fcdb7a341c43285004c95863da168ed8d1f8f","bugs":{"url":"https://github.com/fent/node-drange/issues"},"homepage":"https://github.com/fent/node-drange#readme","_id":"drange@1.1.1","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"fent","email":"fentbox@gmail.com"},"dist":{"shasum":"b2aecec2aab82fcef11dbbd7b9e32b83f8f6c0b8","size":3343,"noattachment":false,"key":"/drange/-/drange-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/drange/download/drange-1.1.1.tgz"},"maintainers":[{"name":"fent","email":"fentbox@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/drange_1.1.1_1537452385688_0.011037290877220274"},"_hasShrinkwrap":false,"publish_time":1537452385835,"_cnpm_publish_time":1537452385835},"1.1.0":{"name":"drange","version":"1.1.0","description":"For adding, subtracting, and indexing discontinuous ranges of numbers","keywords":["discontinuous","range","set"],"main":"lib/index.js","scripts":{"test":"istanbul cover node_modules/.bin/_mocha -- test/*-test.js","dtslint":"dtslint types"},"repository":{"type":"git","url":"git+https://github.com/fent/node-drange.git"},"author":{"name":"David Tudury","email":"david.tudury@gmail.com"},"contributors":[{"name":"fent","url":"https://github.com/fent"}],"devDependencies":{"istanbul":"^0.4.5","mocha":"^5.0.0"},"engines":{"node":">=6"},"license":"MIT","types":"./types","gitHead":"3cbd9531c52658c933658ad206e318ce6830da04","bugs":{"url":"https://github.com/fent/node-drange/issues"},"homepage":"https://github.com/fent/node-drange#readme","_id":"drange@1.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"fent","email":"fentbox@gmail.com"},"dist":{"shasum":"ea6ff1b222d74661ffecb8ef97522b9593d7b7bc","size":3352,"noattachment":false,"key":"/drange/-/drange-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/drange/download/drange-1.1.0.tgz"},"maintainers":[{"name":"fent","email":"fentbox@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/drange_1.1.0_1537039443278_0.3578010011468975"},"_hasShrinkwrap":false,"publish_time":1537039443434,"_cnpm_publish_time":1537039443434},"1.0.2":{"name":"drange","version":"1.0.2","description":"For adding, subtracting, and indexing discontinuous ranges of numbers","keywords":["discontinuous","range","set"],"main":"lib/index.js","files":["lib","types/index.d.ts"],"scripts":{"test":"istanbul cover node_modules/.bin/_mocha -- test/*-test.js","dtslint":"dtslint types"},"repository":{"type":"git","url":"git+https://github.com/fent/node-drange.git"},"author":{"name":"David Tudury","email":"david.tudury@gmail.com"},"contributors":[{"name":"fent","url":"https://github.com/fent"}],"devDependencies":{"istanbul":"^0.4.5","mocha":"^5.0.0"},"engines":{"node":">=4"},"license":"MIT","types":"./types","gitHead":"018a9418f49ece301346d28a6787cddf2c9c24a9","bugs":{"url":"https://github.com/fent/node-drange/issues"},"homepage":"https://github.com/fent/node-drange#readme","_id":"drange@1.0.2","_npmVersion":"6.1.0","_nodeVersion":"10.2.0","_npmUser":{"name":"fent","email":"fentbox@gmail.com"},"dist":{"shasum":"a7390ad5869c6f69eabdc42e0a5b516bd100966e","size":3089,"noattachment":false,"key":"/drange/-/drange-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/drange/download/drange-1.0.2.tgz"},"maintainers":[{"name":"fent","email":"fentbox@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/drange_1.0.2_1528261811776_0.518485345358856"},"_hasShrinkwrap":false,"publish_time":1528261811930,"_cnpm_publish_time":1528261811930},"1.0.1":{"name":"drange","version":"1.0.1","description":"For adding, subtracting, and indexing discontinuous ranges of numbers","keywords":["discontinuous","range","set"],"main":"lib/index.js","files":["lib"],"scripts":{"test":"istanbul cover node_modules/.bin/_mocha -- test/*-test.js"},"repository":{"type":"git","url":"git+https://github.com/fent/node-drange.git"},"author":{"name":"David Tudury","email":"david.tudury@gmail.com"},"contributors":[{"name":"fent","url":"https://github.com/fent"}],"devDependencies":{"istanbul":"^0.4.5","mocha":"^5.0.0"},"engines":{"node":">=4"},"license":"MIT","gitHead":"45a9f0b4aec93b5bf432d33be54764bfe304deae","bugs":{"url":"https://github.com/fent/node-drange/issues"},"homepage":"https://github.com/fent/node-drange#readme","_id":"drange@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"9.7.1","_npmUser":{"name":"fent","email":"fentbox@gmail.com"},"dist":{"shasum":"26311e99ecbe3cd831a8d12a34a0b0e931c63a87","size":2776,"noattachment":false,"key":"/drange/-/drange-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/drange/download/drange-1.0.1.tgz"},"maintainers":[{"name":"fent","email":"fentbox@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/drange_1.0.1_1520259258984_0.6044480214429082"},"_hasShrinkwrap":false,"publish_time":1520259259033,"_cnpm_publish_time":1520259259033},"1.0.0":{"name":"drange","version":"1.0.0","description":"For adding, subtracting, and indexing discontinuous ranges of numbers","keywords":["discontinuous","range","set"],"main":"lib/index.js","files":["lib"],"scripts":{"test":"mocha test/*-test.js"},"repository":{"type":"git","url":"git+https://github.com/fent/node-drange.git"},"author":{"name":"David Tudury","email":"david.tudury@gmail.com"},"contributors":[{"name":"fent","url":"https://github.com/fent"}],"devDependencies":{"mocha":"^5.0.0"},"license":"MIT","gitHead":"8e0a04aff3324686ebdb6b133d99c0bad4cd2fe9","bugs":{"url":"https://github.com/fent/node-drange/issues"},"homepage":"https://github.com/fent/node-drange#readme","_id":"drange@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.5.0","_npmUser":{"name":"fent","email":"fentbox@gmail.com"},"dist":{"shasum":"753d6b1242866d112d2918ba9162e395a2bc74d6","size":2562,"noattachment":false,"key":"/drange/-/drange-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/drange/download/drange-1.0.0.tgz"},"maintainers":[{"name":"fent","email":"fentbox@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/drange_1.0.0_1518360431604_0.6144681136569408"},"_hasShrinkwrap":false,"publish_time":1518360432283,"_cnpm_publish_time":1518360432283}},"readme":"# drange\n\nFor adding/subtracting sets of range of numbers.\n\n[![Build Status](https://secure.travis-ci.org/fent/node-drange.svg)](http://travis-ci.org/fent/node-drange)\n[![Dependency Status](https://david-dm.org/fent/node-drange.svg)](https://david-dm.org/fent/node-drange)\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","_attachments":{},"homepage":"https://github.com/fent/node-drange#readme","bugs":{"url":"https://github.com/fent/node-drange/issues"},"license":"MIT"}