{"_id":"@1-/ipv4","name":"@1-/ipv4","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@1-/ipv4","version":"0.1.0","description":"Convert IPv4 addresses to and from 32-bit integers / 将 IPv4 地址与 32 位整数相互转换","keywords":[],"homepage":"https://github.com/webc-site/npm/tree/main/ipv4","license":"MulanPSL-2.0","author":{"name":"x-at-01@googlegroups.com"},"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"type":"module","exports":{"./*":"./*"},"dependencies":{"@3-/int":"^0.1.1"},"_id":"@1-/ipv4@0.1.0","bugs":{"url":"https://github.com/webc-site/npm/issues"},"_nodeVersion":"26.2.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-da6355E+tbKPd53Rz6BTmknNg36HbTLmwKI3ZffmlTZf9lkiKpa5LLVM9L6q+FbaN0lrr4gcTucptN3KNDxk6Q==","shasum":"90944b36132e474cb4c7bf78b6f45d9852eafa01","tarball":"https://registry.npmjs.org/@1-/ipv4/-/ipv4-0.1.0.tgz","fileCount":4,"unpackedSize":5776,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCNCETpbdQ2aTXLh3aVLMp9vYiR7k4lKL9NjG+WtVikZwIhAOL0Y6SZmpHL0M6ha7Jksdv+oqObXqhSkNAZqtR/oUMT"}]},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"directories":{},"maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ipv4_0.1.0_1781437212140_0.2859848073048705"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-14T11:40:11.987Z","0.1.0":"2026-06-14T11:40:12.262Z","modified":"2026-06-14T11:40:12.478Z"},"maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"description":"Convert IPv4 addresses to and from 32-bit integers / 将 IPv4 地址与 32 位整数相互转换","homepage":"https://github.com/webc-site/npm/tree/main/ipv4","keywords":[],"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"author":{"name":"x-at-01@googlegroups.com"},"bugs":{"url":"https://github.com/webc-site/npm/issues"},"license":"MulanPSL-2.0","readme":"[English](#en) | [中文](#zh)\n\n---\n\n<a id=\"en\"></a>\n# @1-/ipv4 : Convert IPv4 addresses to and from 32-bit integers\n\n- [@1-/ipv4 : Convert IPv4 addresses to and from 32-bit integers](#1-ipv4-convert-ipv4-addresses-to-and-from-32-bit-integers)\n  - [Functionality](#functionality)\n  - [Usage demonstration](#usage-demonstration)\n  - [Design rationale](#design-rationale)\n  - [Technology stack](#technology-stack)\n  - [Code structure](#code-structure)\n  - [Historical context](#historical-context)\n  - [About](#about)\n\n## Functionality\nConvert IPv4 address strings to 32-bit unsigned integers and vice versa. Enables efficient IP address arithmetic, range calculations, and compact storage.\n\n## Usage demonstration\nInstall the package:\n```bash\nnpm install @1-/ipv4\n```\n\nUse in JavaScript modules:\n```javascript\nimport ipv4ToU32 from '@1-/ipv4/ipv4_u32';\nimport u32ToIpv4 from '@1-/ipv4/u32_ipv4';\n\n// Convert IPv4 string to integer\nconst ipInt = ipv4ToU32('192.168.1.1'); // 3232235777\n\n// Convert integer back to IPv4 string\nconst ipStr = u32ToIpv4(3232235777); // '192.168.1.1'\n\n// Perform IP address arithmetic\nconst networkStart = ipv4ToU32('192.168.0.0');\nconst networkEnd = ipv4ToU32('192.168.255.255');\nconst totalAddresses = networkEnd - networkStart + 1; // 65536\n```\n\n## Design rationale\nThe library uses bit manipulation for optimal performance:\n- IPv4 string parsing splits by dots and converts each octet\n- Bit shifting combines octets into 32-bit integer representation\n- Bitwise AND operations extract octets from integer representation\n- Uses unsigned right shift (`>>>`) to handle 32-bit integer boundaries correctly\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@QM/iFdsdzXORfPYxEHONDpw.svg)\n\n## Technology stack\n- JavaScript ES modules\n- Node.js runtime\n- @3-/int dependency for integer conversion\n\n## Code structure\n```\nsrc/\n├── ipv4_u32.js    # Converts IPv4 string → 32-bit integer\n└── u32_ipv4.js    # Converts 32-bit integer → IPv4 string\n```\n\n## Historical context\nThe IPv4 addressing scheme was standardized in 1981 with RFC 791. Its 32-bit design allowed approximately 4.3 billion unique addresses, which seemed abundant at the time. The conversion between dotted-decimal notation and integer representation became essential for network programming, enabling efficient subnet calculations and routing table implementations. This library implements the fundamental conversion operations that underpin modern network infrastructure.\n\n## About\n\nThis library is developed by [WebC.site](https://webc.site).\n\n[WebC.site](https://webc.site): A new paradigm of web development for AI\n\n\n---\n\n<a id=\"zh\"></a>\n# @1-/ipv4 : IPv4 地址与 32 位整数双向转换\n\n- [@1-/ipv4 : IPv4 地址与 32 位整数双向转换](#1-ipv4-ipv4-地址与-32-位整数双向转换)\n  - [功能介绍](#功能介绍)\n  - [使用演示](#使用演示)\n  - [设计思路](#设计思路)\n  - [技术栈](#技术栈)\n  - [代码结构](#代码结构)\n  - [历史故事](#历史故事)\n  - [关于](#关于)\n\n## 功能介绍\n实现 IPv4 地址字符串与 32 位无符号整数之间的双向转换。支持高效 IP 地址算术运算、范围计算及紧凑存储。\n\n## 使用演示\n安装包：\n```bash\nnpm install @1-/ipv4\n```\n\n在 JavaScript 模块中使用：\n```javascript\nimport ipv4ToU32 from '@1-/ipv4/ipv4_u32';\nimport u32ToIpv4 from '@1-/ipv4/u32_ipv4';\n\n// 将 IPv4 字符串转换为整数\nconst ipInt = ipv4ToU32('192.168.1.1'); // 3232235777\n\n// 将整数转换回 IPv4 字符串\nconst ipStr = u32ToIpv4(3232235777); // '192.168.1.1'\n\n// 执行 IP 地址算术运算\nconst networkStart = ipv4ToU32('192.168.0.0');\nconst networkEnd = ipv4ToU32('192.168.255.255');\nconst totalAddresses = networkEnd - networkStart + 1; // 65536\n```\n\n## 设计思路\n库采用位操作实现最优性能：\n- IPv4 字符串解析通过点号分割并转换各八位组\n- 位移操作将八位组组合为 32 位整数表示\n- 位与操作从整数表示中提取八位组\n- 使用无符号右移（`>>>`）正确处理 32 位整数边界\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@W4/lo7JYRHL_JGmdUICecwg.svg)\n\n## 技术栈\n- JavaScript ES 模块\n- Node.js 运行时\n- @3-/int 依赖项用于整数转换\n\n## 代码结构\n```\nsrc/\n├── ipv4_u32.js    # IPv4 字符串 → 32 位整数转换\n└── u32_ipv4.js    # 32 位整数 → IPv4 字符串转换\n```\n\n## 历史故事\nIPv4 地址方案于 1981 年 RFC 791 标准化。其 32 位设计可提供约 43 亿个唯一地址，在当时看似充足。IPv4 点分十进制表示法与整数表示法之间的转换成为网络编程基础，支撑子网计算和路由表实现。本库实现了现代网络基础设施所依赖的核心转换操作。\n\n## 关于\n\n本库由 [WebC.site](https://webc.site) 开发。\n\n[WebC.site](https://webc.site) : 面向人工智能的网站开发新范式\n\n","readmeFilename":"README.md","_rev":"1-a649a6e492a4c60c72cbe5429559a441"}