# piece-length

> piece-length finds the optimal piece length for a given number of bytes. Optimal for what exactly? BitTorrent. [VuzeWiki](http://wiki.vuze.com/w/Torrent_Piece_Size) and [TorrentFreak](http://torrentfreak.com/how-to-make-the-best-torrents-081121/) have bot

Latest version **2.0.1** (published 2019-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install piece-length
pnpm add piece-length
yarn add piece-length
bun add piece-length
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2019-08-14 |
| First published | 2013-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | michaelrhodes |

## Links

- npm: https://www.npmjs.com/package/piece-length
- Repository: https://github.com/michaelrhodes/piece-length
- Homepage: https://github.com/michaelrhodes/piece-length#readme
- Issues: https://github.com/michaelrhodes/piece-length/issues
- npm.io page: https://npm.io/package/piece-length

## Recent versions

- 2.0.1 (latest) — 2019-08-14
- 2.0.0 — 2019-08-14
- 1.0.1 — 2019-08-12
- 1.0.0 — 2017-01-20
- 0.0.0 — 2013-10-25

## README

# piece-length
piece-length finds the optimal piece length for a given number of bytes. Optimal for what exactly? BitTorrent. [VuzeWiki](http://wiki.vuze.com/w/Torrent_Piece_Size) and [TorrentFreak](http://torrentfreak.com/how-to-make-the-best-torrents-081121/) have both released some examples of ideal piece lengths, and this algorithm will reproduce them.

[![build status](https://travis-ci.org/michaelrhodes/piece-length.png?branch=master)](https://travis-ci.org/michaelrhodes/piece-length)

## install
```
npm install piece-length
```
note: you may need to polyfill [`Math.log2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2#Browser_compatibility)

### use
``` js
var optimum = require('piece-length')

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

### obey
[MIT](http://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/piece-length · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
