{"name":"ip-bigint","version":"4.0.1","keywords":["ip","bigint"],"author":{"name":"silverwind","email":"me@silverwind.io"},"license":"BSD-2-Clause","_id":"ip-bigint@4.0.1","homepage":"https://github.com/silverwind/ip-bigint#readme","bugs":{"url":"https://github.com/silverwind/ip-bigint/issues"},"dist":{"shasum":"73e51a978b36633a6bc2cdefc038e6d91d27f11b","tarball":"http://registry-npm.ywwl.com/ip-bigint/download/ip-bigint-4.0.1.tgz","fileCount":4,"integrity":"sha512-M1czJSN7nOSNzvPFfD1IPz/YBdTqHG8b8vofLIHMI3LfdpSobg1OY7+4a5X3fDqtRbmhvxybqo+exmTEtHKTEw==","signatures":[{"sig":"MEQCIEN4wG0Vo1KXF4JD1jo/yRI5BD79Rufl7094ylew2PdeAiAwvsDrQAw85A1pI5tN74E0Nct6XAc5CmmALdgbo7bqTA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5829,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjINbEACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqnsg/+ORGhpCM4imAw720IEKL26WyzaCsmEvLwRIuVZRD+unG7QVha\r\ndUmgxDSCrmWB1CL68uLz6iwdkWtWvewOcxHU3E+M37+N91utwuHIlEFZ5UYP\r\nyzcTgb6erJXqqYztDJtiH6vQ/Y60qXUF4uNPaTVPS0fIXt2vnyx/ndVz6KAj\r\nflRX/84ZUK0MITMylt/2eEoi2b9s/+0q03hnA97htHD0eomGpih/KzLdwJA6\r\nRVd/aOVLKz2cdqDDPeo+qTsvARToLQMbNbKmfpuDZ+VtF0Cl9mSomIgoRoAm\r\n4Pw/rQ12mFqqAaU3BVvDARdp4VmbL1VVMvkzTr7njMyKyyFumFMrAJVFbxs+\r\nKUApzRXkOuaFTKRlB+XnR6UJDTj2Nz3v2/tt7GgDgDR/oTbIKdTmv3rfx8hE\r\n4XR4U9Wc88J5GYUA/7sMJMPA3mvRhM8DOrS30Br+WRnk+nceYBVsVh0/5SXC\r\nRRQeRA3Hjaa46yP1yKzOyOcfyrclYpcpwDOCFKBfHxVnFWRpwKfEFVkFfwrS\r\ngfZnDb10ueUj9Q6ECFPumwHjX4AAfcxHi1OssVeulBImIH/BdrkFodbESA+H\r\n6mgK28ZI0zXQgiDA/jrC8maqjjPYe1ggC9IltwtTmW7iYqlJTqvCQW80TyoJ\r\nLmRRXnXTJ1HUhyk/qx14QtmZ5i5dJ/3v6WM=\r\n=JdxL\r\n-----END PGP SIGNATURE-----\r\n","size":2674,"noattachment":false,"key":"/ip-bigint/-/ip-bigint-4.0.1.tgz"},"type":"module","engines":{"node":">=14"},"gitHead":"e5f14506ea77ac4fbc0c950f9c8608aad07f5335","_npmUser":{"name":"silverwind","email":"npm@silverwind.io"},"repository":{"url":"git+https://github.com/silverwind/ip-bigint.git","type":"git"},"_npmVersion":"8.19.1","description":"Convert IPv4 and IPv6 addresses to native BigInt and vice-versa","directories":{},"_nodeVersion":"18.8.0","dependencies":{"ip-regex":"5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"29.0.3","eslint":"8.23.1","updates":"13.1.5","versions":"9.3.0","eslint-config-silverwind":"54.0.2"},"_npmOperationalInternal":{"tmp":"tmp/ip-bigint_4.0.1_1663096516084_0.9685998575562758","host":"s3://npm-registry-packages"},"readme":"# ip-bigint\n[![](https://img.shields.io/npm/v/ip-bigint.svg?style=flat)](https://www.npmjs.org/package/ip-bigint) [![](https://img.shields.io/npm/dm/ip-bigint.svg)](https://www.npmjs.org/package/ip-bigint) [![](https://img.shields.io/bundlephobia/minzip/ip-bigint.svg)](https://bundlephobia.com/package/ip-bigint) [![](https://packagephobia.com/badge?p=ip-bigint)](https://packagephobia.com/result?p=ip-bigint)\n\n> Convert IPv4 and IPv6 addresses to and from BigInt\n\n## Usage\n\n```js\nimport {parseIp, stringifyIp, normalizeIp} from \"ip-bigint\";\n\nconst obj = parseIp(\"2001:db8::\");\n// => {number: 42540766411282592856903984951653826560n, version: 6}\n\nstringifyIp(obj);\n// => \"2001:db8::\"\n\nnormalizeIp(\"2001:db8::0:0:1\");\n// => \"2001:db8::1\"\n```\n\n## API\n\n### parseIp(ip)\n\nParse a IP address string to a object (with null prototype).\n\nFor IPv4 returns `{number, version}`.\nFor IPv6 returns `{number, version, [ipv4mapped], [scopeid]}`.\n\nThere is only rudimentary validation that the passed string is actually an IP address. You are encouraged to validate yourself using modules like [`ip-regex`](https://github.com/sindresorhus/ip-regex).\n\n### stringifyIp({number, version, [ipv4mapped], [scopeid]}, [opts])\n\nConvert a parsed object back to an IP address string.\n\n`opts`: Options `Object`\n  - `compress`: Whether to compress the IP. For IPv6, this means the \"best representation\" all-lowercase shortest possible form. Default: `true`.\n  - `hexify`: Whether to convert IPv4-Mapped IPv6 addresses to hex. Default: `false`.\n\n### normalizeIp(ip, [opts])\n\nRound-trip an IP address through `parseIp` and `stringifyIp`, effectively normalizing its representation.\n\n`opts`: Options `Object`\n  - `compress`: Whether to compress the IP. For IPv6, this means the \"best representation\" all-lowercase shortest possible form. Default: `true`.\n  - `hexify`: Whether to convert IPv4-Mapped IPv6 addresses to hex. Default: `false`.\n\n### max4\n\nA `BigInt` value that holds the biggest possible IPv4 address.\n\n### max6\n\nA `BigInt` value that holds the biggest possible IPv6 address.\n\n### ipVersion(ip)\n\nReturns a integer of the IP version, 4, 6 or 0 if it's not an IP. Very rudimentary and should not be used for validation.\n\n## Related\n\n- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses\n- [is-cidr](https://github.com/silverwind/is-cidr) - Check if a string is an IP address in CIDR notation\n- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address\n- [cidr-regex](https://github.com/silverwind/cidr-regex) - Check if a string is an IP address in CIDR notation\n- [cidr-tools](https://github.com/silverwind/cidr-tools) - Tools to work with IPv4 and IPv6 CIDR network lists\n\n## License\n\n© [silverwind](https://github.com/silverwind), distributed under BSD licence\n","publish_time":1663096516253,"maintainers":[{"name":"silverwind","email":"npm@silverwind.io"}],"_cnpm_publish_time":1663096516253,"dist-tags":{"latest":"10.0.4"}}