Gathering detailed insights and metrics for @leichtgewicht/ip-codec
Gathering detailed insights and metrics for @leichtgewicht/ip-codec
Gathering detailed insights and metrics for @leichtgewicht/ip-codec
Gathering detailed insights and metrics for @leichtgewicht/ip-codec
Small package to encode or decode IP addresses from buffers to strings. Supports IPV4 and IPV6.
npm install @leichtgewicht/ip-codec
Typescript
Module System
Node Version
NPM Version
99.8
Supply Chain
89.9
Quality
75.7
Maintenance
100
Vulnerability
100
License
JavaScript (95.44%)
TypeScript (4.56%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
4 Stars
41 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Dec 01, 2022
Latest Version
2.0.5
Package Id
@leichtgewicht/ip-codec@2.0.5
Unpacked Size
17.29 kB
Size
4.90 kB
File Count
6
NPM Version
10.2.4
Node Version
20.11.1
Published on
Mar 27, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Small package to encode or decode IP addresses from buffers to strings. Supports IPV4 and IPV6.
The basics are straigthforward
1import { encode, decode, sizeOf, familyOf } from '@leichtgewicht/ip-codec' 2 3const uint8Array = encode("127.0.0.1") 4const str = decode(uint8Array) 5 6try { 7 switch sizeOf(str) { 8 case 4: // IPv4 9 case 16: // IPv6 10 } 11 switch familyOf(str) { 12 case: 1: // IPv4 13 case: 2: // IPv6 14 } 15} catch (err) { 16 // Invalid IP 17}
By default the library will work with Uint8Array's but you can bring your own buffer:
1const buf = Buffer.alloc(4) 2encode('127.0.0.1', buf)
It is also possible to de-encode at a location inside a given buffer
1const buf = Buffer.alloc(10) 2encode('127.0.0.1', buf, 4)
Allocation of a buffer may be difficult if you don't know what type the buffer: you can pass in a generator to allocate it for you:
1encode('127.0.0.1', Buffer.alloc)
You can also de/encode ipv4 or ipv6 specifically:
1import { v4, v6 } from '@leichtgewicht/ip-codec' 2 3v4.decode(v4.encode('127.0.0.1')) 4v6.decode(v6.encode('::'))
The code in this package was originally extracted from node-ip and since improved.
Notable changes are the removal of the Buffer
dependency and better support for detection of
formats and allocation of buffers.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More