1.0.3 • Published 8 years ago

filter-ips v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

filter-ips Build Status XO code style

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

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago