0.1.0 • Published 1 year ago

ip-port-address v0.1.0

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

node-ip-port-address

Parse IP address and port from a string.

Installation

npm install ip-port-address

Usage

var parseAddress = require('ip-port-address');

parseAddress('127.0.0.1:8080');
// { ip: '127.0.0.1', port: 8080, family: 'ipv4' }

parseAddress('[::1]:8080');
// { ip: '::1', port: 8080, family: 'ipv6' }

parseAddress('localhost:8080');
// null

parseAddress('127.0.0.1:8080', 'ipv4');
// { ip: '127.0.0.1', port: 8080, family: 'ipv4' }

parseAddress('[::1]:8080', 'ipv4');
// null