Install
npm i torrefy
Basic usage
import { create, encode, decode } from "torrefy";
const testFile = new File(
["Hello world. This is the test file content."],
"testfile.txt"
);
const metaInfo = await create([testFile]);
const torrentStream = encode(metaInfo);
const [torrentStream1, torrentStream2] = torrentStream.tee();
const torrentBinary = await new Response(torrentStream1).arrayBuffer();
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