Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

string2compact

webtorrent38.8kMIT2.0.1

Convert 'hostname:port' strings to BitTorrent's compact ip/host binary returned by Trackers

binary, bittorrent, compact, convert, hostname, peer-to-peer, port, torrent, tracker, webtorrent

readme

string2compact ci npm downloads javascript style guide

Convert 'hostname:port' strings to BitTorrent's compact ip/host binary returned by Trackers

This module is the opposite of compact2string. It works in the browser with browserify. It is used by WebTorrent, and more specifically, the bittorrent-tracker and bittorrent-dht modules.

install

npm install string2compact

usage

single string2compact

var string2compact = require('string2compact')
var compact = string2compact('10.10.10.5:65408')
console.log(compact) // new Buffer('0A0A0A05FF80', 'hex')

tranform multiple into one buffer

var compacts = string2compact([ '10.10.10.5:128', '100.56.58.99:28525' ])
console.log(compacts) // new Buffer('0A0A0A05008064383a636f6d', 'hex')

license

MIT. Copyright (c) Feross Aboukhadijeh and WebTorrent, LLC.

changelog

2.0.1 (2023-01-25)

Bug Fixes

  • deps: update dependency addr-to-ip-port to v2 (#34) (935bae0)

2.0.0 (2022-12-05)

Features

BREAKING CHANGES

  • ESM only

1.3.2 (2021-08-04)

Bug Fixes

  • deps: update dependency ipaddr.js to v2 (#15) (6786178)

1.3.1 (2021-07-23)

Bug Fixes

  • add semantic release, switch CI (3ede327)