# ip-address-utils

> ## Installation

Latest version **1.0.2** (published 2019-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install ip-address-utils
pnpm add ip-address-utils
yarn add ip-address-utils
bun add ip-address-utils
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-07-03 |
| First published | 2019-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 34.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Stan Guo |
| Maintainers | oathihs |

## Links

- npm: https://www.npmjs.com/package/ip-address-utils
- Repository: https://github.com/oathihs/ip-address-utils
- npm.io page: https://npm.io/package/ip-address-utils

## Dependencies (1)

- [ms](https://npm.io/package/ms.md) ^2.0.0

## Recent versions

- 1.0.2 (latest) — 2019-07-03
- 1.0.1 — 2019-07-03

## README

# ip-address-utils

## Installation

npm:

```bash
    $ npm install ip-address-utils --save
```

yarn:

```bash
    $ yarn add ip-address-utils
```

browser:

```html
<script src="ip-address-utils/dist/ip-address-utils.umd.min.js"></script>

<script>
  window.ipAddressUtils.ipv4.subnet('192.168.0.1/26');
  // {
  //   bitmask: 26,
  //   netmask: '255.255.255.192',
  //   hostCount: 62,
  //   networkAddress: '192.168.0.0',
  //   broadcastAddress: '192.168.0.63',
  //   firstHost: '192.168.0.1',
  //   lastHost: '192.168.0.62'
  // }
</script>
```

## Usage

```js
import { ipv4 } from 'ip-address-utils';

ipv4.isValid('192.168.1.0'); // true
ipv4.isSubnet('192.168.1.0/24'); // true
ipv4.isIpHost('192.168.1.0'); // true
ipv4.isValidIpRange('0.0.0.1-192.168.1.191', {
  subnet: '192.168.1.134/26'
}); // false
ipv4.toBuffer('192.168.0.1'); // new Buffer([192.168.0.1])
ipv4.fromBuffer(new Buffer([192, 168, 0, 1])); // '192.168.0.1'
ipv4.toBitmask('255.255.0.0'); // 16
ipv4.fromBitmask(16); //'255.255.0.0'
ipv4.toDecimal('192.168.0.1'); // 3232235521
ipv4.fromDecimal(3232235521); // '192.168.0.1'
ipv4.subnet('192.168.0.1/26');
// {
//   bitmask: 26,
//   netmask: '255.255.255.192',
//   hostCount: 62,
//   networkAddress: '192.168.0.0',
//   broadcastAddress: '192.168.0.63',
//   firstHost: '192.168.0.1',
//   lastHost: '192.168.0.62'
// }
```

> IPv6 is still WIP

---
_Source: https://npm.io/package/ip-address-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
