4.0.0 • Published 2 months ago

@ctrl/torrent-file v4.0.0

Weekly downloads
15
License
MIT
Repository
github
Last release
2 months ago

torrent-file npm coverage bundlesize

Parse a torrent file and read encoded data.

This project is based on parse-torrent and node-bencode to parse the data of a torrent file. This library implements its own bencode encoder and decoder that does not use Buffer.

Install

npm install @ctrl/torrent-file

API

info

The content of the metainfo file.

import fs from 'fs';
import { info } from '@ctrl/torrent-file';

const torrentInfo = info(fs.readFileSync('myfile'));
console.log({ torrentInfo });
files

data about the files described in the torrent file, includes hashes of the pieces

import fs from 'fs';
import { files } from '@ctrl/torrent-file';

const torrentFiles = files(fs.readFileSync('myfile'));
console.log({ torrentFiles });
hash

sha1 of torrent file info. This hash is commenly used by torrent clients as the ID of the torrent. It is async and sha1 encoding is handled by crypto-hash

import fs from 'fs';
import { hash } from '@ctrl/torrent-file';

(async () => {
  const torrentHash = await hash(fs.readFileSync('myfile'));
  console.log({ torrentHash });
})()

See Also

parse-torrent - "@ctrl/torrent-file" torrent parsing based very heavily off this project
node-bencode - bencoder built into this project heavily based off this project

4.0.0

2 months ago

3.0.0

8 months ago

2.0.3

1 year ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago