npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

torrent-manager

v2.0.7

Published

Bittorent client api

Downloads

3

Readme

Torrent Manager

Install

npm install torrent-manager

Usage :

import { Manager, Torrent } from 'torrent-manager';

// Managed
const torrentManager = new Manager();
torrentManager
  .add('magnet:?xt=urn:btih:7c312dd630e216b10e87c82a9624e38eac4bac4b&dn=archlinux-2019.11.01-x86_64.iso&tr=udp://tracker.archlinux.org:6969&tr=http://tracker.archlinux.org:6969/announce');

// Standalone
const torrent = new Torrent('magnet:?xt=urn:btih:7c312dd630e216b10e87c82a9624e38eac4bac4b&dn=archlinux-2019.11.01-x86_64.iso&tr=udp://tracker.archlinux.org:6969&tr=http://tracker.archlinux.org:6969/announce');

API

Manager

Manager(options?)

options
allowDuplicate

Type : boolean Default: false

Throw exception if torrent already exists

downloadRate

Type : number Default : Infinity

Define the download rate (in bytes), affects all downloads managed by this manager

uploadRate

Type : number Default : Infinity

Define upload rate (in bytes), affects all uploads managed by this manager

retry

Type : object Default :

{
  limit: 0,
}

See got retry options

timeout

Type : object Default :

{
  request: 5000,
}

See got timeout options

defaultTorrentOptions

Type : object

Define default torrent options (see torrent options)

Properties

numPeers

Number of peers for managed torrents

progress

Average progression for managed torrents

ratio

Average ratio for managed torrents

torrents

Return an array of managed torrent

Methods

add(source, options?)
source

Type : Torrent uri <string> | Magnet uri <string> | File path <String>

options

Type : object Default: {}

See torrent options

remove(torrentHash)
torrentHash

Type : string

Stop and remove torrent from manager

start(torrentHash)
torrentHash

Type : string

Start/Resume torrent download

Stop(torrentHash)
torrentHash

Type : string

Stop torrent download

check(torrentHash)
torrentHash

Type : string

Check torrent pieces

startAll()

Start/Resume all managed torrents

stopAll()

Stop all torrents

checkAll()

Check all managed torrents pieces

get(torrentHash)

Return a Torrent if exists else undefined

Torrent

Torrent(source, options?)

source

Type : File content <buffer> | Magnet uri <string> | Torrent parse <object>

options
peerId

Type : string Length :20 Default: -TMXXXX-YYYYYYYYYYYY XXXX base on version YYYYYYYYYYYY randomized

Define peer identifier

name

Type : string Default : torrent-manager

Define torrent client name (used in user agent)

port

Type : number Default : 4242

Define listening port

userAgent

Type : string Default : ${name}/${version}

Define user agent use to request trackers

maxPeers

Type : number Default: 50

Define maximum peers

complete

Type : boolean Default : false

Define state ready to share, skip pieces check and set progress to 100%

verify

Type : boolean Default : true

Skip pieces check, download will start from 0% (unused when set complete to true)

dht

Type : boolean Default: true

Use DHT to discover peers

dhtPort

Type : number Default: 0

Define DHT port

LSD

Type : boolean Default: true

Use local service discovery to discover peers

tracker

Type : boolean Default : true

Use trackers to discover peers

trackers

Type : Array<string> Default : []

Override the list of trackers to announce

announce

Type : Array<string> Default : []

Add tracker to existing trackers list to announce

speed

Type : number Default : 5

Define the length of buffer for speed measurement (in seconds)

path

Type : string Default : current directory

Set download path

downloadRate

Type : number Default : Infinity

Set maximum download rate (in bytes)

uploadRate

Type : number Default : Infinity

Set maximum upload rate (in bytes)

blocklist

Type : Array<string> Default : []

Define a blocked ip list

autostart

Type : boolean Default : true

Define whether torrent will start immediatly

Properties

infoHash

Type : string

Return torrent hash

id

Return infoHash

shortId

Return first ìnfohash 8 characters

debugId

Return shortId

metadata

Type : Object

Return torrent metadata

wires

Type : Array<Object>

Return wires known in swarm

peers

Type : Array<Object>

Return connected peers

numPeers

Type : number

Return number of connected peers

downloaded

Type : number

Return downloaded data length (in bytes)

downloadSpeed

Type : number

Return download speed

received

Type : number

Return received data length (in bytes)

uploaded

Type : number

Return uploaded data length (in bytes)

uploadSpeed

Type : number

Return upload speed

progress

Type : number

Return progression (between 0 and 1)

timeRemaining

Type : number

Return remaining time in seconds

ratio

Type : number

Return ratio downloaded/uploaded

Methods

check

Check pieces integrity

start

Start download

stop

Stop Download

connect

Add a peer

diconnect

Remove a peer

reannounce

Force annoucement to tracker outside interval period

block(ip)
ip

Type : String

Block specified ip

setDownloadRate(rate)
rate

Type : number

Set download max speed to rate (in bytes)

setUploadRate(rate)
rate

Type : number

Set upload max speed to rate (in bytes)

setPath(path)

path

Type : string

Set download path

toTorrentFile

Return buffer of torrent metadata

toMagnetURI

Return magnet uri based on metadata