0.5.0 • Published 6 years ago
ipv4-address v0.5.0
ipv4-address
A single IPv4 address
Installation
$ npm install --save ipv4-address
Usage
import toIPv4Address from "ipv4-address";
const toIPv4Address = require("ipv4-address");
toIPv4Address([127, 0, 0, 1]); // [0, 0, 0, 0]
toIPv4Address("255.256.300.3000"); // [255, 255, 255, 255]
toIPv4Address("0.0.0.0"); // [0, 0, 0, 0]
toIPv4Address("127.0.0.1").toString(); // "127.0.0.1"
toIPv4Address("0.0.0"); // Throws an error (not long enough)
toIPv4Address("0.0.0.0.0"); // Throws an error (too long)
import IPv4Address from "ipv4-address/IPv4Address"; // Extends Uint8Array
const IPv4Address = require("ipv4-address/IPv4Address"); // Extends Uint8Array
new IPv4Address([0, 0, 0, 0]); // [0, 0, 0, 0]
IPv4Address.parse("127.0.0.1"); // [127, 0, 0, 0]
IPv4Address.from([127, 0, 0, 1]); // [127, 0, 0, 0]
IPv4Address.of(127, 0, 0, 1); // [127, 0, 0, 0]
new IPv4Address([0, 0, 0]); // Throws an error (not long enough)
new IPv4Address([0, 0, 0, 0, 0]); // Throws an error (too long)
License
MIT © Malte-Maurice Dreyer