piece-length
Advanced tools
Comparing version 1.0.1 to 2.0.0
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
5458
10
148
22
0