Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
create-torrent
Advanced tools
This module is used by WebTorrent.
npm install create-torrent
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).
createTorrent(path, [opts], function callback (err, torrent) {})
Create a new .torrent
file.
path
is the path to the file or folder to use.
opts
is optional and allows you to set special settings for the .torrent.
{
comment: '', // free-form textual comments of the author (string)
createdBy: '', // name and version of the program used to create the .torrent (string)
private: false, // is this a private .torrent? (boolean or integer)
pieceLength: 32768 // force a custom piece length (number of bytes)
announceList: [[]] // custom trackers to use (array of arrays of strings) (see [bep12](http://www.bittorrent.org/beps/bep_0012.html))
}
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.
MIT. Copyright (c) Feross Aboukhadijeh.
FAQs
Create .torrent files
The npm package create-torrent receives a total of 2,484 weekly downloads. As such, create-torrent popularity was classified as popular.
We found that create-torrent demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.