{"_id":"@leichtgewicht/ip-codec","_rev":"4579059","name":"@leichtgewicht/ip-codec","description":"Small package to encode or decode IP addresses from buffers to strings.","dist-tags":{"latest":"2.0.5"},"maintainers":[{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"}],"time":{"modified":"2026-04-10T15:52:54.000Z","created":"2021-07-01T06:11:06.252Z","2.0.5":"2024-03-27T04:42:14.678Z","2.0.4":"2022-05-09T16:58:42.800Z","2.0.3":"2021-07-17T09:48:12.765Z","2.0.2":"2021-07-01T10:00:25.877Z","2.0.1":"2021-07-01T08:27:45.649Z","2.0.0":"2021-07-01T08:10:16.947Z","1.0.0":"2021-07-01T06:11:06.252Z"},"users":{},"author":{"name":"Martin Heidegger"},"repository":{"type":"git","url":"git+https://github.com/martinheidegger/ip-codec.git"},"versions":{"2.0.5":{"name":"@leichtgewicht/ip-codec","version":"2.0.5","description":"Small package to encode or decode IP addresses from buffers to strings.","main":"index.cjs","types":"types","exports":{".":{"types":"./types/index.d.ts","import":"./index.mjs","require":"./index.cjs"}},"scripts":{"lint":"standard && dtslint --localTs node_modules/typescript/lib types","test":"npm run lint && npm run unit","unit":"fresh-tape test.mjs","coverage":"c8 npm run unit","prepare":"npx @leichtgewicht/esm2umd ipCodec"},"repository":{"type":"git","url":"git+https://github.com/martinheidegger/ip-codec.git"},"keywords":["ip","ipv4","ipv6","codec","codecs","buffer","conversion"],"author":{"name":"Martin Heidegger"},"license":"MIT","bugs":{"url":"https://github.com/martinheidegger/ip-codec/issues"},"homepage":"https://github.com/martinheidegger/ip-codec#readme","devDependencies":{"@definitelytyped/dtslint":"0.2.19","@leichtgewicht/esm2umd":"^0.4.0","c8":"^9.1.0","fresh-tape":"^5.5.3","standard":"^17.1.0","typescript":"^5.4.3"},"_id":"@leichtgewicht/ip-codec@2.0.5","gitHead":"7312f356342ec0728767fb0a1d9a4b25a053f8e5","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"shasum":"4fc56c15c580b9adb7dc3c333a134e540b44bfb1","size":5013,"noattachment":false,"key":"/@leichtgewicht/ip-codec/-/@leichtgewicht/ip-codec-2.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/@leichtgewicht/ip-codec/download/@leichtgewicht/ip-codec-2.0.5.tgz"},"_npmUser":{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"},"directories":{},"maintainers":[{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ip-codec_2.0.5_1711514534522_0.9941210286100588"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-03-27T04:42:14.678Z","publish_time":1711514534678,"_source_registry_name":"default","_cnpm_publish_time":1711514534678},"2.0.4":{"name":"@leichtgewicht/ip-codec","version":"2.0.4","description":"Small package to encode or decode IP addresses from buffers to strings.","main":"index.cjs","types":"types","exports":{".":{"import":"./index.mjs","require":"./index.cjs"}},"scripts":{"lint":"standard && dtslint --localTs node_modules/typescript/lib types","test":"npm run lint && npm run unit","unit":"fresh-tape test.mjs","coverage":"c8 npm run unit","prepare":"node ./scripts/esm2umd.mjs ipCodec"},"repository":{"type":"git","url":"git+https://github.com/martinheidegger/ip-codec.git"},"keywords":["ip","ipv4","ipv6","codec","codecs","buffer","conversion"],"author":{"name":"Martin Heidegger"},"license":"MIT","bugs":{"url":"https://github.com/martinheidegger/ip-codec/issues"},"homepage":"https://github.com/martinheidegger/ip-codec#readme","devDependencies":{"@definitelytyped/dtslint":"0.0.112","c8":"^7.11.2","esm2umd":"^0.2.0","fresh-tape":"^5.5.3","standard":"^17.0.0","typescript":"^4.6.4"},"gitHead":"49c204316b0ad107e958ff9b07131e1595156be0","_id":"@leichtgewicht/ip-codec@2.0.4","_nodeVersion":"14.17.5","_npmVersion":"6.14.14","dist":{"shasum":"b2ac626d6cb9c8718ab459166d4bb405b8ffa78b","size":5059,"noattachment":false,"key":"/@leichtgewicht/ip-codec/-/@leichtgewicht/ip-codec-2.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/@leichtgewicht/ip-codec/download/@leichtgewicht/ip-codec-2.0.4.tgz"},"_npmUser":{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"},"directories":{},"maintainers":[{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ip-codec_2.0.4_1652115522635_0.6431655472954532"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-09T16:58:47.647Z","publish_time":1652115522800,"_cnpm_publish_time":1652115522800},"2.0.3":{"name":"@leichtgewicht/ip-codec","version":"2.0.3","description":"Small package to encode or decode IP addresses from buffers to strings.","main":"index.js","types":"types","scripts":{"lint":"standard && dtslint --localTs node_modules/typescript/lib types","test":"fresh-tape test.js","test-cov":"c8 npm run test"},"repository":{"type":"git","url":"git+https://github.com/martinheidegger/ip-codec.git"},"keywords":["ip","ipv4","ipv6","codec","codecs","buffer","conversion"],"author":{"name":"Martin Heidegger"},"license":"MIT","bugs":{"url":"https://github.com/martinheidegger/ip-codec/issues"},"homepage":"https://github.com/martinheidegger/ip-codec#readme","devDependencies":{"c8":"^7.7.3","dtslint":"^4.1.1","fresh-tape":"^5.2.4","standard":"^16.0.3","typescript":"^4.3.5"},"gitHead":"473f3ba49a5d31fe3899f5d74c446422fe25349f","_id":"@leichtgewicht/ip-codec@2.0.3","_nodeVersion":"16.4.0","_npmVersion":"7.18.1","dist":{"shasum":"0300943770e04231041a51bd39f0439b5c7ab4f0","size":6334,"noattachment":false,"key":"/@leichtgewicht/ip-codec/-/@leichtgewicht/ip-codec-2.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/@leichtgewicht/ip-codec/download/@leichtgewicht/ip-codec-2.0.3.tgz"},"_npmUser":{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"},"directories":{},"maintainers":[{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ip-codec_2.0.3_1626515292634_0.8654720488593579"},"_hasShrinkwrap":false,"publish_time":1626515292765,"_cnpm_publish_time":1626515292765},"2.0.2":{"name":"@leichtgewicht/ip-codec","version":"2.0.2","description":"Small package to encode or decode IP addresses from buffers to strings.","main":"index.js","types":"types","scripts":{"lint":"standard && dtslint --localTs node_modules/typescript/lib types","test":"fresh-tape test.js","test-cov":"c8 npm run test"},"repository":{"type":"git","url":"git+https://github.com/martinheidegger/ip-codec.git"},"keywords":["ip","ipv4","ipv6","codec","codecs","buffer","conversion"],"author":{"name":"Martin Heidegger"},"license":"MIT","bugs":{"url":"https://github.com/martinheidegger/ip-codec/issues"},"homepage":"https://github.com/martinheidegger/ip-codec#readme","devDependencies":{"c8":"^7.7.3","dtslint":"^4.1.1","fresh-tape":"^5.2.4","standard":"^16.0.3","typescript":"^4.3.5"},"gitHead":"5b9aeebdd2acd0a0bb3f46c91731827d6c9982b3","_id":"@leichtgewicht/ip-codec@2.0.2","_nodeVersion":"16.4.0","_npmVersion":"7.18.1","dist":{"shasum":"862a66b3e0197109c11ddf2082a8db4c66ba6bd2","size":3747,"noattachment":false,"key":"/@leichtgewicht/ip-codec/-/@leichtgewicht/ip-codec-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@leichtgewicht/ip-codec/download/@leichtgewicht/ip-codec-2.0.2.tgz"},"_npmUser":{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"},"directories":{},"maintainers":[{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ip-codec_2.0.2_1625133625687_0.8987495300480688"},"_hasShrinkwrap":false,"publish_time":1625133625877,"_cnpm_publish_time":1625133625877},"2.0.1":{"name":"@leichtgewicht/ip-codec","version":"2.0.1","description":"Small package to encode or decode IP addresses from buffers to strings.","main":"index.js","types":"types","scripts":{"lint":"standard && dtslint --localTs node_modules/typescript/lib types","test":"fresh-tape test.js","test-cov":"c8 npm run test"},"repository":{"type":"git","url":"git+https://github.com/martinheidegger/ip-codec.git"},"keywords":["ip","ipv4","ipv6","codec","codecs","buffer","conversion"],"author":{"name":"Martin Heidegger"},"license":"MIT","bugs":{"url":"https://github.com/martinheidegger/ip-codec/issues"},"homepage":"https://github.com/martinheidegger/ip-codec#readme","devDependencies":{"c8":"^7.7.3","dtslint":"^4.1.1","fresh-tape":"^5.2.4","standard":"^16.0.3","typescript":"^4.3.5"},"gitHead":"5a60cf5e77243abc0fbf3ec0f0dd3870ea8c1711","_id":"@leichtgewicht/ip-codec@2.0.1","_nodeVersion":"16.4.0","_npmVersion":"7.18.1","dist":{"shasum":"a29f6bc26b6b4bc10dab78b2da52550fd432d74b","size":3721,"noattachment":false,"key":"/@leichtgewicht/ip-codec/-/@leichtgewicht/ip-codec-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@leichtgewicht/ip-codec/download/@leichtgewicht/ip-codec-2.0.1.tgz"},"_npmUser":{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"},"directories":{},"maintainers":[{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ip-codec_2.0.1_1625128065547_0.43722304706542947"},"_hasShrinkwrap":false,"publish_time":1625128065649,"_cnpm_publish_time":1625128065649},"2.0.0":{"name":"@leichtgewicht/ip-codec","version":"2.0.0","description":"Small package to encode or decode IP addresses from buffers to strings.","main":"index.js","types":"types","scripts":{"lint":"standard && dtslint --localTs node_modules/typescript/lib types","test":"fresh-tape test.js","test-cov":"c8 npm run test"},"repository":{"type":"git","url":"git+https://github.com/martinheidegger/ip-codec.git"},"keywords":["ip","ipv4","ipv6","codec","codecs","buffer","conversion"],"author":{"name":"Martin Heidegger"},"license":"MIT","bugs":{"url":"https://github.com/martinheidegger/ip-codec/issues"},"homepage":"https://github.com/martinheidegger/ip-codec#readme","devDependencies":{"c8":"^7.7.3","dtslint":"^4.1.1","fresh-tape":"^5.2.4","standard":"^16.0.3","typescript":"^4.3.5"},"gitHead":"71fb675b4fe016abcbdeb17d48a307bfbdadf586","_id":"@leichtgewicht/ip-codec@2.0.0","_nodeVersion":"16.4.0","_npmVersion":"7.18.1","dist":{"shasum":"7060cb38312c6268f5f7ba77a0d69999e83d2d17","size":4435,"noattachment":false,"key":"/@leichtgewicht/ip-codec/-/@leichtgewicht/ip-codec-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@leichtgewicht/ip-codec/download/@leichtgewicht/ip-codec-2.0.0.tgz"},"_npmUser":{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"},"directories":{},"maintainers":[{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ip-codec_2.0.0_1625127016845_0.886924448238269"},"_hasShrinkwrap":false,"publish_time":1625127016947,"_cnpm_publish_time":1625127016947},"1.0.0":{"name":"@leichtgewicht/ip-codec","version":"1.0.0","description":"Small package to encode or decode IP addresses from buffers to strings.","main":"index.js","types":"types","scripts":{"lint":"standard && dtslint --localTs node_modules/typescript/lib types","test":"fresh-tape test.js","test-cov":"c8 npm run test"},"repository":{"type":"git","url":"git+https://github.com/martinheidegger/ip-codec.git"},"keywords":["ip","ipv4","ipv6","codec","codecs","buffer","conversion"],"author":{"name":"Martin Heidegger"},"license":"MIT","bugs":{"url":"https://github.com/martinheidegger/ip-codec/issues"},"homepage":"https://github.com/martinheidegger/ip-codec#readme","devDependencies":{"c8":"^7.7.3","dtslint":"^4.1.1","fresh-tape":"^5.2.4","standard":"^16.0.3","typescript":"^4.3.5"},"gitHead":"fa42bb9f99af5564b8963a43e81debdc0773e34c","_id":"@leichtgewicht/ip-codec@1.0.0","_nodeVersion":"16.4.0","_npmVersion":"7.18.1","dist":{"shasum":"3b153fdbfb2d7ada087ff9ad9bcc045d9deabf5e","size":4374,"noattachment":false,"key":"/@leichtgewicht/ip-codec/-/@leichtgewicht/ip-codec-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@leichtgewicht/ip-codec/download/@leichtgewicht/ip-codec-1.0.0.tgz"},"_npmUser":{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"},"directories":{},"maintainers":[{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ip-codec_1.0.0_1625119866106_0.5899376372888863"},"_hasShrinkwrap":false,"publish_time":1625119866252,"_cnpm_publish_time":1625119866252}},"readme":"# @leichtgewicht/ip-codec\n\nSmall package to encode or decode IP addresses from buffers to strings.\nSupports IPV4 and IPV6.\n\n## Usage\n\nThe basics are straigthforward\n\n```js\nimport { encode, decode, sizeOf, familyOf } from '@leichtgewicht/ip-codec'\n\nconst uint8Array = encode(\"127.0.0.1\")\nconst str = decode(uint8Array)\n\ntry {\n  switch sizeOf(str) {\n    case 4: // IPv4\n    case 16: // IPv6\n  }\n  switch familyOf(str) {\n    case: 1: // IPv4\n    case: 2: // IPv6\n  }\n} catch (err) {\n  // Invalid IP\n}\n```\n\nBy default the library will work with Uint8Array's but you can bring your own buffer:\n\n```js\nconst buf = Buffer.alloc(4)\nencode('127.0.0.1', buf)\n```\n\nIt is also possible to de-encode at a location inside a given buffer\n\n```js\nconst buf = Buffer.alloc(10)\nencode('127.0.0.1', buf, 4)\n```\n\nAllocation of a buffer may be difficult if you don't know what type the buffer:\nyou can pass in a generator to allocate it for you:\n\n```js\nencode('127.0.0.1', Buffer.alloc)\n```\n\nYou can also de/encode ipv4 or ipv6 specifically:\n\n```js\nimport { v4, v6 } from '@leichtgewicht/ip-codec'\n\nv4.decode(v4.encode('127.0.0.1'))\nv6.decode(v6.encode('::'))\n```\n\n## History\n\nThe code in this package was originally extracted from [node-ip](https://github.com/indutny/node-ip) and since improved.\n\nNotable changes are the removal of the `Buffer` dependency and better support for detection of\nformats and allocation of buffers.\n\n## License\n\n[MIT](./LICENSE)\n","_attachments":{},"homepage":"https://github.com/martinheidegger/ip-codec#readme","bugs":{"url":"https://github.com/martinheidegger/ip-codec/issues"},"license":"MIT"}