# compact2string

> Convert BitTorrent compact hostname & port buffer to a string 'hostname:port'

Latest version **1.4.1** (published 2019-02-25) · BSD license · 0 weekly downloads

## Install

```sh
npm install compact2string
pnpm add compact2string
yarn add compact2string
bun add compact2string
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2019-02-25 |
| First published | 2012-12-06 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Ben Evans |
| Maintainers | bencevans |
| Keywords | torrent, compact, tracker, bittorrent, binary, convert |

## Links

- npm: https://www.npmjs.com/package/compact2string
- Repository: https://github.com/bencevans/node-compact2string
- Homepage: https://github.com/bencevans/node-compact2string#readme
- Issues: https://github.com/bencevans/node-compact2string/issues
- npm.io page: https://npm.io/package/compact2string

## Dependencies (1)

- [ipaddr.js](https://npm.io/package/ipaddr.js.md) >= 0.1.5

## Recent versions

- 1.4.1 (latest) — 2019-02-25
- 1.4.0 — 2014-12-09
- 1.3.0 — 2014-11-26
- 1.2.0 — 2014-01-19
- 1.1.0 — 2013-10-28
- 1.0.0 — 2012-12-08
- 0.1.0 — 2012-12-06

## README

# compact2string

Convert bittorrent's [compact](http://wiki.theory.org/BitTorrent_Tracker_Protocol#Peer_Dictionary_Format) ip/host binary returned by Trackers to 'hostname:port' string.

[![Build Status](https://travis-ci.org/bencevans/node-compact2string.png?branch=master)](https://travis-ci.org/bencevans/node-compact2string)
[![Coverage Status](https://coveralls.io/repos/bencevans/node-compact2string/badge.png?branch=master)](https://coveralls.io/r/bencevans/node-compact2string?branch=master)
[![Dependency Status](https://david-dm.org/bencevans/node-compact2string.png)](https://david-dm.org/bencevans/node-compact2string)

[![browser support](https://ci.testling.com/bencevans/node-compact2string.png)
](https://ci.testling.com/bencevans/node-compact2string)

Need the reverse of this? Checkout https://github.com/feross/string2compact

## Installation

```npm install compact2string```

## Usage

### Single compact2string	

```javascript
var compact2string = require("compact2string");
var Buffer = require("buffer").Buffer;
var ipport = compact2string(new Buffer("0A0A0A05FF80", "hex"));
console.log(ipport);
```

=> ```"10.10.10.5:65408" ```

```javascript
ipport = compact2string(new Buffer("2a03288021109f07faceb00c000000010050", "hex"));
console.log(ipport);
```

=> ```"[2a03:2880:2110:9f07:face:b00c::1]:80" ```

### Multiple in same buffer
	
```javascript
var hostports = compact2string.multi(new Buffer("0A0A0A05008064383a636f6d", "hex"));
console.log(hostports);
```

=> ```[ '10.10.10.5:128', '100.56.58.99:28525' ]```

IPv6 version: `compact2string.multi6()`

## Licence

(MIT Licence)

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