{"name":"ip-bigint","version":"8.1.1","description":"Convert IPv4 and IPv6 addresses to and from BigInt","author":{"name":"silverwind","email":"me@silverwind.io"},"repository":{"type":"git","url":"git+https://github.com/silverwind/ip-bigint.git"},"license":"BSD-2-Clause","type":"module","sideEffects":false,"main":"./dist/index.js","exports":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=18"},"devDependencies":{"@types/node":"20.14.7","eslint":"8.57.0","eslint-config-silverwind":"88.1.0","eslint-config-silverwind-typescript":"4.0.2","typescript-config-silverwind":"5.1.1","updates":"16.2.0","versions":"12.1.2","vite":"5.3.1","vite-config-silverwind":"2.2.2","vitest":"1.6.0","vitest-config-silverwind":"9.0.6"},"_id":"ip-bigint@8.1.1","gitHead":"f7355b68002097e68738475d311915b9665cb155","bugs":{"url":"https://github.com/silverwind/ip-bigint/issues"},"homepage":"https://github.com/silverwind/ip-bigint#readme","_nodeVersion":"22.2.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-+/H/+4CyuwGMXtIcjv6R/c0p8xvKIwp5O8EATl49GDXzwCcVz2q+lST8OXFveQONNcESymSTJ3A3Bsq46e8Y/w==","shasum":"48b29e32a358418578072c3518e7b5db4c97faa8","tarball":"http://registry-npm.ywwl.com/ip-bigint/download/ip-bigint-8.1.1.tgz","fileCount":5,"unpackedSize":8422,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA2sJ5llhUmFUY1kBsTAj1UMNCi0mdKUEEHStnBn1xdRAiEAgItJkxREBbxsX7V2H3dvZFdMCCvaMs6ZldeU7zN5uAA="}],"size":3093,"noattachment":false,"key":"/ip-bigint/-/ip-bigint-8.1.1.tgz"},"_npmUser":{"name":"silverwind","email":"npm@silverwind.io"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ip-bigint_8.1.1_1718994850492_0.38743013165394746"},"_hasShrinkwrap":false,"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":1718994850726,"maintainers":[{"name":"silverwind","email":"npm@silverwind.io"}],"_cnpm_publish_time":1718994850726,"dist-tags":{"latest":"10.0.4"}}