Finds the optimal piece length for a given number of bytes.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
.travis.yml
index.js
package.json
readme.md

readme.md

piece-length

piece-length finds the optimal piece length for a given number of bytes. Optimal for what exactly? BitTorrent. VuzeWiki and TorrentFreak have both released some examples of ideal piece lengths, and this algorithm will reproduce them.

Build status

Browser support

Install

npm install piece-length

Example

var optimum = require('piece-length')

// 350mb should be 256kb
optimum(367001600) // => 262144

License

MIT