How to use the ip-address.v4 function in ip-address

To help you get started, we’ve selected a few ip-address examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PaddeK / node-maxmind-db / lib / IPAddress.js View on Github external
'use strict';

var IPv6 = require('ip-address').v6;
var IPv4 = require('ip-address').v4;

exports.parseIPv4 = function parseIPv4(ip) {
    var v4Address = new IPv4.Address(ip);
    if (!v4Address.isValid()) {
        throw new Error("Invalid IPv4 address");
    return v4Address.parsedAddress;

exports.parseIPv6 = function parseIPv6(ip) {
    var v6Address = new IPv6.Address(ip);
    if (!v6Address.isValid()) {
        throw new Error("Invalid IPv6 address");
    return v6Address.parsedAddress;


A library for parsing IPv4 and IPv6 IP addresses in node and the browser.

Latest version published 7 months ago

Package Health Score

84 / 100
Full package analysis