1.2.7 • Published 2 months ago

inet_xtoy v1.2.7

Weekly downloads
90
License
MIT
Repository
github
Last release
2 months ago

node-inet-xtoy

Build and Test CodeQL

inet_ntop() and inet_pton() bindings for Node.js

Installation

npm install inet_xtoy

Example

const { inet_ntop, inet_pton } = require('inet_xtoy');

console.log(inet_pton('127.0.0.1'));
console.log(inet_pton('::1'));
console.log(inet_ntop(inet_pton('127.0.0.1')));
console.log(inet_ntop(inet_pton('::1')));

API

inet_ntop(buf) converts an IPv4 or IPv6 address buf from binary to text form.

buf is expected to be a 4 (IPv4) or 16 (IPv6) bytes long String or Buffer.

Returns the IP address as a string or throws an Error in case the call to inet_ntop(3) fails.

Throws TypeError when the number of arguments is not 1, when buf is neither String nor Buffer or when the length of buf is neither 4 nor 16.

inet_pton(ip) converts an IPv4 or IPv6 address buf from text to binary form.

ip is expected to be a string. The function returns null if ip is not a valid IP address.

Returns Buffer with the binary form of the given ip; the length of the buffer is either 4 or 16 bytes.

Throws TypeError when the number of arguments is not 1 or when ip is not a string.

Throws Error when a call to inet_pton(3) fails.

1.2.7

2 months ago

1.2.6

6 months ago

1.2.5

9 months ago

1.2.4

11 months ago

1.2.3

11 months ago

1.2.2

1 year ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.5

4 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago