webtorrent/parse-torrent

filereader instead of 'fs'

sibiraj-s opened this issue · 1 comments

Is it possible to use filereader API to parse the torrent file? since fs is not supported in browser and in browserify too

parseTorrent(fs.readFileSync(__dirname + '/torrents/leaves.torrent'))

can we do something like this?

const parseTorrent = require('parse-torrent');
const reader = new FileReader();

reader.readAsArrayBuffer(file);

reader.onload = function () {
      const result = new Int8Array(reader.result);
      var data = parseTorrent(result)
 };

This module works with browserify. It works for webtorrent. Just pass it File's buffer