Socket
Socket
Sign inDemoInstall

piece-length

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 2.0.0

bench/index.js

6

index.js
module.exports = length
function length (bytes, p) {
bytes /= 1024
for (p = 20; 13 < p && bytes < 2 << p; p--);
return 2 << p + (bytes >= ((2 << p) + (2 << p + 1)) / 2)
function length (bytes) {
return Math.max(16384, 1 << Math.log2(bytes / 1024) + 0.5 | 0)
}
{
"name": "piece-length",
"author": ["Michael Rhodes", "Jimmy Wärting <jimmy@warting.se>"],
"version": "1.0.1",
"author": ["Jimmy Wärting <jimmy@warting.se>", "Michael Rhodes"],
"version": "2.0.0",
"main": "index.js",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -10,2 +10,3 @@ # 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)

@@ -12,0 +13,0 @@ ### use

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc