Skip to content

An ESM package that uses Web Streams API to create v1, v2 or hybrid torrents in your web browser

License

Notifications You must be signed in to change notification settings

Sec-ant/torrefy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

torrefy

GitHub top language npm version npm downloads GitHub search hit counter Rate this package

An ESM package that uses Web Streams API to create v1, v2 or hybrid torrents in your web browser.

🏗This package is under active development.🏗

Install

npm i torrefy # or yarn add torrefy

Basic usage

import { create, encode, decode } from "torrefy";

// create a test file
const testFile = new File(
  ["Hello world. This is the test file content."],
  "testfile.txt"
);

// calculate (hash) the meta info of the test file
const metaInfo = await create([testFile]);

// bencode meta info into a readable stream
const torrentStream = encode(metaInfo);

// tee the readable stream into two readable streams
const [torrentStream1, torrentStream2] = torrentStream.tee();

// consume the first readable stream as an array buffer
const torrentBinary = await new Response(torrentStream1).arrayBuffer();

// decode the second readable stream into meta info
const decodedMetaInfo = await decode(torrentStream2);

Features

Supports Different Web File APIs

This package can handle input files or directories acquired from File API, File and Directory Entries API or File System Access API.

TBD

About

An ESM package that uses Web Streams API to create v1, v2 or hybrid torrents in your web browser

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published