1.0.3 • Published 8 years ago
filter-ips v1.0.3
filter-ips
Filter a list of IPv4 addresses based on a list of exclusion IPs or addresses containing wildcards.
filterIps('1.2.3.4', '1.2.3.5', '1.2.4.5', '1.2.3.*') => '1.2.4.5'
Install
$ npm install --save filter-ips
Usage
Basic
const filterIps = require('filter-ips');
const ips = ['1.2.3.4', '1.2.3.5', '1.2.3.6', '1.2.3.7'];
const exclusions = ['1.2.3.4', '1.2.3.6'];
filterIps(ips, exclusions);
//=> ['1.2.3.5', '1.2.3.7'];
Wildcards
const filterIps = require('filter-ips');
const ips = [
'1.2.3.4',
'240.230.29.1',
'240.230.29.2',
'255.255.255.255',
'255.255.255.254'
];
const exclusions = ['1.2.3.4', '255.*.*.*'];
filterIps(ips, exclusions);
//=> ['240.230.29.1', '240.230.29.2'];
API
filterIps(ips, exclusions)
Returns a new array of filtered ips
ips
Type: <array>[<string>]
A list of IPv4 addresses.
exclusions
Type: <array>[<string>]
| <string>
A list of exclusions to be omitted from the list of IPs entered. Exclusion items can be a specific address or address containing wildcards.
Related
ip-class - :capital_abcd: Return the classful network class (A, B, C, D, E) of an IPv4 address
License
MIT © Brandon Him