# @types/netmask

> TypeScript definitions for netmask

Latest version **2.0.6** (published 2025-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/netmask
pnpm add @types/netmask
yarn add @types/netmask
bun add @types/netmask
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2025-11-23 |
| First published | 2016-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51442 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/netmask
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/netmask
- npm.io page: https://npm.io/package/@types/netmask

## Recent versions

- 2.0.6 (latest) — 2025-11-23
- 2.0.5 (ts4.5) — 2023-11-07
- 2.0.2 (ts4.3) — 2023-06-28
- 2.0.0 (ts4.2) — 2023-03-08
- 1.0.30 (ts3.5) — 2017-08-21
- 2.0.4 — 2023-10-18
- 2.0.3 — 2023-09-23
- 2.0.1 — 2023-06-19
- 1.0.29 — 2016-09-19
- 1.0.28 — 2016-07-14
- 1.0.27-alpha — 2016-07-08
- 1.0.26-alpha — 2016-07-04
- 1.0.25-alpha — 2016-07-02
- 1.0.24-alpha — 2016-07-01
- 1.0.23-alpha — 2016-07-01
- … 4 more at https://npm.io/package/@types/netmask/versions

## README

# Installation
> `npm install --save @types/netmask`

# Summary
This package contains type definitions for netmask (https://github.com/rs/node-netmask).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/netmask.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/netmask/index.d.ts)
````ts
/**
 * converts long to an ip address
 */
export function long2ip(long: number): string;
/**
 * converts ip address to long
 */
export function ip2long(ip: string): number;

export class Netmask {
    /**
     * The base address of the network block as a string (eg: 216.240.32.0). Base does not give an indication of the size of the network block.
     */
    base: string;
    /**
     * The netmask as a string (eg: 255.255.255.0).
     */
    mask: string;
    /**
     * The netmask as a number of bits in the network portion of the address for this block (eg: 24).
     */
    bitmask: number;
    /**
     * The host mask which is the opposite of the netmask (eg: 0.0.0.255).
     */
    hostmask: string;
    /**
     * The blocks broadcast address (eg: 192.168.1.0/24 => 192.168.1.255)
     */
    broadcast: string | undefined;
    /**
     * The number of IP addresses in a block (eg: 256).
     */
    size: number;
    /**
     * First useable address
     */
    first: string;
    /**
     * Last useable address
     */
    last: string;

    maskLong: number;
    netLong: number;

    /**
     * Returns a true if the IP number ip is part of the network. That is, a true value is returned if ip is between base and broadcast.
     * If a Netmask object or a block is given, it returns true only of the given block fits inside the network.
     */
    contains(address: string | Netmask | number): boolean;
    /**
     * Similar to the Array prototype method. It loops through all the useable addresses, ie between first and last.
     */
    forEach(cb: (ip: string, long: number, index: number) => void): void;
    /**
     * Without a count, return the next block of the same size after the current one. With a count, return the Nth block after the current one.
     * A count of -1 returns the previous block. Undef will be returned if out of legal address space.
     */
    next(count?: number): Netmask;
    /**
     * The netmask in base/bitmask format (e.g., '216.240.32.0/24')
     */
    toString(): string;

    /**
     * @param net A network - e.g 216.240.32.0/24
     * @param mask - optional netmask if not provided in `net`
     */
    constructor(net: string, mask?: string | number);
}

````

### Additional Details
 * Last updated: Sun, 23 Nov 2025 19:02:02 GMT
 * Dependencies: none

# Credits
These definitions were written by [Matt Frantz](https://github.com/mhfrantz), [JanST123](https://github.com/JanST123), and [Junxiao Shi](https://github.com/yoursunny).

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