# @types/ipv4-peers

> TypeScript definitions for ipv4-peers

Latest version **2.0.2** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/ipv4-peers
pnpm add @types/ipv4-peers
yarn add @types/ipv4-peers
bun add @types/ipv4-peers
```

## Health

**Score 45/100 (D)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2023-11-07 |
| First published | 2022-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51437 |
| Maintainers | types |

## Links

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

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) *

## Recent versions

- 2.0.2 (latest) — 2023-11-07
- 2.0.0 (ts4.1) — 2022-11-02
- 2.0.1 — 2023-10-18

## README

# Installation
> `npm install --save @types/ipv4-peers`

# Summary
This package contains type definitions for ipv4-peers (https://github.com/mafintosh/ipv4-peers).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ipv4-peers.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ipv4-peers/index.d.ts)
````ts
/// <reference types="node" />

/**
 * Create a new ipv4-peers decoder that encodes/decodes a fixed size peer id in addition to host/port.
 * The peer id is exposed as the `.id` property on a peer object.
 */
declare function create(idLength?: number): {
    idLength: typeof create;
    encodingLength: typeof encodingLength;
    encode: typeof encode;
    decode: typeof decode;
};

export { create as idLength };

/**
 * @returns The amount of bytes needed to encode the peers into a buffer.
 */
export function encodingLength(peers: readonly Peer[]): number;

/**
 * Encode a list of ipv4 peers into a buffer.
 *
 * @example
 * import * as peers from 'ipv4-peers'
 *
 * const buf = peers.encode([{
 *   host: '127.0.0.1',
 *   port: 8080
 * }, {
 *   host: '127.0.0.1',
 *   port: 9090
 * }])
 *
 * console.log(buf) // 12 byte buffer
 */
export function encode(peers: readonly Peer[], buffer?: Buffer, offset?: number): Buffer;
export namespace encode {
    const bytes: number;
}

/**
 * Decode a buffer into a list of peers.
 *
 * @example
 * import * as peers from 'ipv4-peers'
 *
 * const buf = peers.encode([{
 *   host: '127.0.0.1',
 *   port: 8080
 * }, {
 *   host: '127.0.0.1',
 *   port: 9090
 * }])
 *
 * console.log(peers.decode(buf)) // the peer list
 */
export function decode(buffer: Buffer, offset?: number, end?: number): Peer[];
export namespace decode {
    const bytes: number;
}

export interface Peer {
    host: string;
    port: number;
    id?: Buffer | undefined;
}

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 03:09:37 GMT
 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)

# Credits
These definitions were written by [BendingBender](https://github.com/BendingBender).

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