{"name":"ip-cidr","version":"4.0.1","keywords":["ip","cidr","range","from","to","array"],"author":{"name":"Alexander Balasyan","email":"mywebstreet@gmail.com"},"license":"MIT","_id":"ip-cidr@4.0.1","homepage":"https://github.com/ortexx/ip-cidr#readme","bugs":{"url":"https://github.com/ortexx/ip-cidr/issues"},"dist":{"shasum":"d018e7bd193fd5a2c2971330d8419d0ddf653123","tarball":"http://registry-npm.ywwl.com/ip-cidr/download/ip-cidr-4.0.1.tgz","fileCount":9,"integrity":"sha512-V5Nce94SVJ7NtyT/UKUeTM7sY3V7TEk48hURhtBgTiGduOa5t6p9Hd+zBOGvr4Gu7iWPxFVYNl017p0akQA84w==","signatures":[{"sig":"MEYCIQCFeIpYjrQQNfOjNJh+hfHq0IzwmwlOIE/lKs9XoC41FgIhAJK3P/sblLV2N4DSFdWWgrOajdDK1MbL/5shWLRf7oHM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":133575,"size":29953,"noattachment":false,"key":"/ip-cidr/-/ip-cidr-4.0.1.tgz"},"main":"./index.js","type":"module","husky":{"hooks":{"pre-commit":"npm run test && npm run build && git add ./dist/*"}},"types":"./index.d.ts","engines":{"node":">=16.14.0"},"gitHead":"8a0fe47a713017577fb2ef45a621a8e9d10f7854","scripts":{"test":"mocha","build":"browserify ./ip-cidr.js -p esmify > ./dist/ip-cidr.js"},"_npmUser":{"name":"ortex","email":"mywebstreet@gmail.com"},"repository":{"url":"git+https://github.com/ortexx/ip-cidr.git","type":"git"},"_npmVersion":"10.5.1","description":"Module for working with CIDR (v4, v6)","directories":{},"_nodeVersion":"20.12.1","dependencies":{"ip-address":"^9.0.5"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.0","husky":"^4.2.3","mocha":"^10.0.0","esmify":"^2.1.1","browserify":"^17.0.0"},"_npmOperationalInternal":{"tmp":"tmp/ip-cidr_4.0.1_1719563213114_0.7694400107908972","host":"s3://npm-registry-packages"},"readme":"# Install  \n`npm install ip-cidr`\n\n# About  \nModule for working with CIDR (v4, v6). Based on [ip-address](https://github.com/beaugunderson/ip-address).\nSince v4+ using javascript BigInt for big numbers handling.\n\n# Example  \n\n```js\nimport IPCIDR from 'ip-cidr';\nconst address = \"50.165.190.0/23\";\n\nif(!IPCIDR.isValidCIDR(address)) {\n  return;\n}\n\nconst cidr = new IPCIDR(address); \n\n// get start ip address as a string\ncidr.start(); \n\n// get end ip address as a big integer\ncidr.end({ type: \"bigInteger\" }); \n\n// do something with each element of the range  \ncidr.loop(ip => console.log(ip), { type: \"addressObject\" });\n\n// get an array of all ip addresses in the range as a big integer;\ncidr.toArray({ type: \"bigInteger\" }); \n\n// get an array by chunks using from/limit\ncidr.toArray({ from: 1, limit: 2n });\n\n// get an array by chunks using from/to\ncidr.toArray({ from: BigInt('1'), to: 3 });\ncidr.toArray({ from: '50.165.190.1', to: '50.165.190.3' });\n\n// get an array of start and end ip addresses as a string [startIpAsString, endIpAsString]\ncidr.toRange(); \n```\n\n## Client side\nLoad __/dist/ip-cidr.js__ as a script and you can get the library in __window.IPCIDR__\n\n# API  \n### .formatIP(address, [options])  \nto return an \"ip-address\" module object in the necessary format \n\n### .isValidAddress(address)  \nto check the address is valid or not (ip or cidr)\n\n### .isValidCIDR(address)  \nto check the address is valid (only cidr)\n\n### .createAddress(address)  \nto create an object address from the string\n\n### .prototype.contains(address)  \nto check the address belongs to the range\n\n### .prototype.start([options])  \nto get the start ip address\n\n### .prototype.end([options])  \nto get the end ip address\n\n### .prototype.toString()   \nto convert the cidr to a string like \"50.165.190.0/23\"\n\n### .prototype.toRange([options])  \nto convert the cidr to an array with start and end ip addresses [startIp, endIp]\n\n### .prototype.toObject([options])   \nto convert the cidr to an object with start and end ip addresses {start: startIp, end: endIp}\n\n### .prototype.toArray([options], [results])  \nto convert the cidr to an array with all ip addresses in the range  \nyou can get information by chunks using **options.from/options.limit** or **options.from/options.to**  \nyou can pass the second argument \"results\" (object) to get all chunk pagination information\n\n### .prototype.loop(fn, [options], [results])  \nto run __fn__ for each element of the range  \nyou can use the same chunk options as in __.toArray()__\n\n\n\n","publish_time":1719563213298,"maintainers":[{"name":"ortex","email":"mywebstreet@gmail.com"}],"_cnpm_publish_time":1719563213298,"dist-tags":{"latest":"4.0.2"}}