0.5.0 • Published 6 years ago

ipv6-address v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

ipv6-address NPM version Build Status Dependency Status Coverage percentage

A single IPv6 address

Installation

$ npm install --save ipv6-address

Usage

import toIPv6Address from "ipv6-address";
const toIPv6Address = require("ipv6-address");

toIPv6Address([1, 2, 3, 4, 5, 6, 7, 8]); // [1, 2, 3, 4, 5, 6, 7, 8]
toIPv6Address("::"); // [0, 0, 0, 0, 0, 0, 0, 0]
toIPv6Address("1::2"); // [1, 0, 0, 0, 0, 0, 0, 2]
toIPv6Address("::dead:1234"); // 0, 0, 0, 0, 0, 0, 57005, 4660]
String(toIPv6Address("0:0:0:0:0:0:0:0")); // "::"
toIPv6Address("1:2:3:4:0:5:6:7").toString(); // "1:2:3:4:0:5:6:7", a single zero field must not be omitted
toIPv6Address("::dead:1234").toString(true); // "0000:0000:0000:0000:0000:0000:dead:1234"
toIPv6Address("0:0"); // Throws an error (not long enough)
toIPv6Address("0:0:0:0:0:0:0:0:0"); // Throws an error (too long)
Number(toIPv6Address("0:0:0:0:0:0:0:0:0")); // Throws an error (2^[16 * 8] is too long for JS)
import IPv6Address from "ipv6-address/IPv6Address"; // Extends Uint8Array
const IPv6Address = require("ipv6-address/IPv6Address"); // Extends Uint8Array

new IPv6Address([0, 0, 0, 0, 0, 0, 0, 0]); // [0, 0, 0, 0, 0, 0, 0, 0]
IPv6Address.parse("::dead:1234"); // [0, 0, 0, 0, 0, 0, 57005, 4660]
IPv6Address.from([0, 0, 0, 0, 0, 0, 57005, 4660]); // [0, 0, 0, 0, 0, 0, 57005, 4660]
IPv6Address.of(0, 0, 0, 0, 0, 0, 57005, 4660); // [0, 0, 0, 0, 0, 0, 57005, 4660]
new IPv6Address([0, 0, 0]); // Throws an error (not long enough)
new IPv6Address([0, 0, 0, 0, 0, 0, 0, 0, 0]); // Throws an error (too long)

License

MIT © Malte-Maurice Dreyer

0.5.0

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.0

9 years ago