filter-ips

1.0.3 • Public • Published

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 - 🔠 Return the classful network class (A, B, C, D, E) of an IPv4 address

License

MIT © Brandon Him

Package Sidebar

Install

npm i filter-ips

Weekly Downloads

1

Version

1.0.3

License

MIT

Last publish

Collaborators

  • brh55