You could use torque. It's not pure javascript, but quite powerful.
http://torque.bittorrent.com/labs/
Check out http://onehash.com/ for an example of exactly what you want to do.
For a pure javascript implementation (I believe limited to chrome), check out jstorrent:
https://github.com/kzahel/jstorrent
And here it is deployed: http://jstorrent.com/