{"id":31805111,"url":"https://github.com/shahradelahi/ip-address","last_synced_at":"2025-10-15T07:07:20.909Z","repository":{"id":318640523,"uuid":"1072129009","full_name":"shahradelahi/ip-address","owner":"shahradelahi","description":"🌐 An immutable IP address (IPv4, IPv6, CIDR) utility for JavaScript \u0026 TypeScript.","archived":false,"fork":false,"pushed_at":"2025-10-08T10:43:09.000Z","size":102,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T12:08:27.458Z","etag":null,"topics":["address","ip","ipv4","ipv6","network","validator"],"latest_commit_sha":null,"homepage":"https://npmjs.com/@se-oss/ip-address","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shahradelahi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-08T09:50:47.000Z","updated_at":"2025-10-08T11:51:32.000Z","dependencies_parsed_at":"2025-10-08T12:08:39.627Z","dependency_job_id":"b9aa74c7-dd68-4714-98d2-657711b538d9","html_url":"https://github.com/shahradelahi/ip-address","commit_stats":null,"previous_names":["shahradelahi/ip-address"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/shahradelahi/ip-address","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fip-address","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fip-address/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fip-address/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fip-address/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shahradelahi","download_url":"https://codeload.github.com/shahradelahi/ip-address/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fip-address/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002681,"owners_count":26083442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["address","ip","ipv4","ipv6","network","validator"],"created_at":"2025-10-11T02:46:37.010Z","updated_at":"2025-10-11T02:46:37.764Z","avatar_url":"https://github.com/shahradelahi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @se-oss/ip-address\n\n[![CI](https://github.com/shahradelahi/ip-address/actions/workflows/ci.yml/badge.svg?branch=main\u0026event=push)](https://github.com/shahradelahi/ip-address/actions/workflows/ci.yml)\n[![NPM Version](https://img.shields.io/npm/v/@se-oss/ip-address.svg)](https://www.npmjs.com/package/@se-oss/ip-address)\n[![MIT License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](/LICENSE)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/@se-oss/ip-address)\n[![Install Size](https://packagephobia.com/badge?p=@se-oss/ip-address)](https://packagephobia.com/result?p=@se-oss/ip-address)\n\n_@se-oss/ip-address_ is a modern, immutable, and zero-dependency library for working with IPv4 and IPv6 addresses in JavaScript and TypeScript.\n\n---\n\n- [Installation](#-installation)\n- [Usage](#-usage)\n- [Documentation](#-documentation)\n- [Contributing](#-contributing)\n- [License](#license)\n\n## 📦 Installation\n\n```bash\nnpm install @se-oss/ip-address\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eInstall using your favorite package manager\u003c/summary\u003e\n\n**pnpm**\n\n```bash\npnpm install @se-oss/ip-address\n```\n\n**yarn**\n\n```bash\nyarn add @se-oss/ip-address\n```\n\n\u003c/details\u003e\n\n## 📖 Usage\n\nThis library makes working with IP addresses a breeze. Here are a few common scenarios:\n\n### Parsing and Validation\n\nYou can easily parse any IP address string. The library will automatically figure out the version and throw an error if the address is invalid.\n\n```typescript\nimport { IPv4, IPv6, parseIP } from '@se-oss/ip-address';\n\n// Let the factory do the work\nconst ip = parseIP('192.168.1.1'); // Returns an IPv4 instance\nconst ip6 = parseIP('2001:db8::1'); // Returns an IPv6 instance\n\nconsole.log(ip.version); // 4\nconsole.log(ip6.version); // 6\n\n// Or validate without creating an instance\nif (IPv4.isValid('10.0.0.1')) {\n  console.log('Yep, a valid IPv4 address.');\n}\n\ntry {\n  parseIP('not.an.ip');\n} catch (error) {\n  console.error(error.message); // \"Invalid IP address: not.an.ip\"\n}\n```\n\n### Working with IPv4 Addresses\n\nOnce you have an `IPv4` instance, you can perform all sorts of checks and conversions.\n\n```typescript\nimport { IPv4 } from '@se-oss/ip-address';\n\nconst ip = new IPv4('192.168.1.1');\n\n// Check its type\nconsole.log(ip.isPrivate()); // true\nconsole.log(ip.isLoopback()); // false\n\n// Convert it\nconsole.log(ip.toBigInt()); // 3232235777n\nconsole.log(ip.toBytes()); // [192, 168, 1, 1]\nconsole.log(ip.toArpa()); // \"1.1.168.192.in-addr.arpa\"\n\n// Get the next IP\nconst nextIp = ip.next();\nconsole.log(nextIp.address); // \"192.168.1.2\"\n```\n\n### Working with IPv6 Addresses\n\nIPv6 is just as easy, with full support for its unique features.\n\n```typescript\nimport { IPv6 } from '@se-oss/ip-address';\n\nconst ip6 = new IPv6('2001:db8::8a2e:370:7334');\n\n// Get compressed vs. expanded address\nconsole.log(ip6.address); // \"2001:db8::8a2e:370:7334\"\nconsole.log(ip6.expandedAddress); // \"2001:0db8:0000:0000:0000:8a2e:0370:7334\"\n\n// Check its type\nconsole.log(ip6.isGlobalUnicast()); // true\nconsole.log(ip6.isLinkLocal()); // false\n\n// Handle IPv4-mapped addresses\nconst mappedIp = new IPv6('::ffff:192.168.1.1');\nconsole.log(mappedIp.isIPv4Mapped()); // true\nconst ipv4 = mappedIp.toIPv4();\nconsole.log(ipv4.address); // \"192.168.1.1\"\n```\n\n### Handling CIDR Blocks\n\nNeed to work with subnets? The `CIDR` class has you covered.\n\n```typescript\nimport { CIDR } from '@se-oss/ip-address';\n\nconst cidr = new CIDR('10.0.0.0/24');\n\n// Get network details\nconsole.log(cidr.network.address); // \"10.0.0.0\"\nconsole.log(cidr.broadcast.address); // \"10.0.0.255\"\nconsole.log(cidr.first.address); // \"10.0.0.1\"\nconsole.log(cidr.last.address); // \"10.0.0.254\"\n\n// Check if an IP falls within the range\nconsole.log(cidr.contains('10.0.0.123')); // true\nconsole.log(cidr.contains('10.0.1.1')); // false\n```\n\n## 📚 Documentation\n\nFor all configuration options, please see [the API docs](https://www.jsdocs.io/package/@se-oss/ip-address).\n\n## 🤝 Contributing\n\nWant to contribute? Awesome! To show your support is to star the project, or to raise issues on [GitHub](https://github.com/shahradelahi/ip-address)\n\nThanks again for your support, it is much appreciated! 🙏\n\n## License\n\n[MIT](/LICENSE) © [Shahrad Elahi](https://github.com/shahradelahi) and [contributors](https://github.com/shahradelahi/ip-address/graphs/contributors).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahradelahi%2Fip-address","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshahradelahi%2Fip-address","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahradelahi%2Fip-address/lists"}