filter-ips
Version:
Filter a list of IPv4 addresess based on a list of exclusion ips or addresses containing wildcards.
66 lines (44 loc) • 1.89 kB
Markdown
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']**
```
$ npm install --save filter-ips
```
```js
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'];
```
```js
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'];
```
*Returns a new array of filtered ips*
Type: [`<array>[<string>]`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Indexed_collections_Arrays_and_typed_Arrays)
A list of IPv4 addresses.
Type: [`<array>[<string>]`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Indexed_collections_Arrays_and_typed_Arrays) | [`<string>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
A list of exclusions to be omitted from the list of IPs entered. Exclusion items can be a specific address or address containing wildcards.
[ ](https://github.com/brh55/ip-class) - :capital_abcd: Return the classful network class (A, B, C, D, E) of an IPv4 address
MIT © [Brandon Him](https://github.com/brh55)
> Filter a list of IPv4 addresses based