npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

create-raidtorrent

v3.24.8

Published

Create .torrent files

Downloads

30

Readme

create-torrent travis npm downloads

Create .torrent files

Sauce Test Status

creation

This module is used by WebTorrent! This module works in node.js and the browser (with browserify).

install

npm install create-torrent

usage

The simplest way to use create-torrent is like this:

var createTorrent = require('create-torrent')
var fs = require('fs')

createTorrent('/path/to/folder', function (err, torrent) {
  if (!err) {
    // `torrent` is a Buffer with the contents of the new .torrent file
    fs.writeFile('my.torrent', torrent)
  }
})

A reasonable piece length (~1024 pieces) will automatically be selected for the .torrent file, or you can override it if you want a different size (See API docs below).

api

createTorrent(input, [opts], function callback (err, torrent) {})

Create a new .torrent file.

input can be any of the following:

  • path to the file or folder on filesystem (string)
  • W3C File object (from an <input> or drag and drop)
  • W3C FileList object (basically an array of File objects)
  • Node Buffer object
  • Node stream.Readable object

Or, an array of string, File, Buffer, or stream.Readable objects.

opts is optional and allows you to set special settings on the produced .torrent file.

{
  name: String,            // name of the torrent (default = basename of `path`, or 1st file's name)
  comment: String,         // free-form textual comments of the author
  createdBy: String,       // name and version of program used to create torrent
  creationDate: Date       // creation time in UNIX epoch format (default = now)
  private: Boolean,        // is this a private .torrent? (default = false)
  pieceLength: Number      // force a custom piece length (number of bytes)
  announceList: [[String]] // custom trackers (array of arrays of strings) (see [bep12](http://www.bittorrent.org/beps/bep_0012.html))
  urlList: [String]        // web seed urls (see [bep19](http://www.bittorrent.org/beps/bep_0019.html))
}

If announceList is omitted, the following trackers will be included automatically:

  • udp://tracker.openbittorrent.com:80
  • udp://tracker.internetwarriors.net:1337
  • udp://tracker.leechers-paradise.org:6969
  • udp://tracker.coppersurfer.tk:6969
  • udp://exodus.desync.com:6969
  • wss://tracker.webtorrent.io
  • wss://tracker.btorrent.xyz
  • wss://tracker.openwebtorrent.com
  • wss://tracker.fastcast.nz

Trackers that start with wss:// are for WebRTC peers. See WebTorrent to learn more.

callback is called with an error and a Buffer of the torrent data. It is up to you to save it to a file if that's what you want to do.

Note: Every torrent is required to have a name. If one is not explicitly provided through opts.name, one will be determined automatically using the following logic:

  • If all files share a common path prefix, that will be used. For example, if all file paths start with /imgs/ the torrent name will be imgs.
  • Otherwise, the first file that has a name will determine the torrent name. For example, if the first file is /foo/bar/baz.txt, the torrent name will be baz.txt.
  • If no files have names (say that all files are Buffer or Stream objects), then a name like "Unnamed Torrent " will be generated.

Note: Every file is required to have a name. For filesystem paths or W3C File objects, the name is included in the object. For Buffer or Readable stream types, a name property can be set on the object, like this:

var buf = new Buffer('Some file content')
buf.name = 'Some file name'

command line

usage: create-torrent <directory OR file> {-o outfile.torrent}

Create a torrent file from a directory or file.

If an output file isn\'t specified with `-o`, the torrent file will be
written to stdout.

license

MIT. Copyright (c) Feross Aboukhadijeh.