# ipv4-peers

> An abstract-encoding compliant encoder for encoding a list of ipv4 peers to buffers

Latest version **2.0.0** (published 2019-07-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install ipv4-peers
pnpm add ipv4-peers
yarn add ipv4-peers
bun add ipv4-peers
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-07-22 |
| First published | 2016-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/ipv4-peers) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/ipv4-peers
- Repository: https://github.com/mafintosh/ipv4-peers
- Issues: https://github.com/mafintosh/ipv4-peers/issues
- npm.io page: https://npm.io/package/ipv4-peers

## Recent versions

- 2.0.0 (latest) — 2019-07-22
- 1.1.1 — 2016-09-06
- 1.1.0 — 2016-09-05
- 1.0.0 — 2016-08-12

## README

# ipv4-peers

An [abstract-encoding](https://github.com/mafintosh/abstract-encoding) compliant encoder for encoding a list of ipv4 peers to buffers.

```
npm install ipv4-peers
```

[![build status](http://img.shields.io/travis/mafintosh/ipv4-peers.svg?style=flat)](http://travis-ci.org/mafintosh/ipv4-peers)

## Usage

``` js
var peers = require('ipv4-peers')

var buf = peers.encode([{
  host: '127.0.0.1',
  port: 8080
}, {
  host: '127.0.0.1',
  port: 9090
}])

console.log(buf) // 12 byte buffer
console.log(peers.decode(buf)) // the peer list
```

## API

#### `var buf = peers.encode(peerList, [buffer], [offset])`

Encode a list of ipv4 peers into a buffer.

#### `var peers = peers.decode(buffer, [offset], [end])`

Decode a buffer into a list of peers.

#### `var length = peers.encodingLength(peerList)`

Returns the amount of bytes needed to encode the peers into a buffer

#### `peers = peers.idLength(idByteLength)`

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.

## License

MIT

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