@ronomon/deduplication
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -176,2 +176,5 @@ 'use strict'; | ||
while (sourceOffset < sourceLength) { | ||
// If more `source` buffers will follow and if current `source` buffer does | ||
// not have more than `minimum` remaining, then avoid artificial cutpoint: | ||
if (flags === 0 && (sourceLength - sourceOffset) <= minimum) break; | ||
var chunkSize = cut( | ||
@@ -190,6 +193,11 @@ average, | ||
} | ||
if (chunkSize < minimum && flags === 0) { | ||
throw new Error('chunkSize < minimum && flags === 0'); | ||
} | ||
if (chunkSize > maximum) { | ||
throw new Error('chunkSize > maximum'); | ||
} | ||
if (sourceOffset + chunkSize > sourceLength) { | ||
throw new Error('sourceOffset + chunkSize > sourceLength'); | ||
} | ||
if (flags === 0 && (sourceOffset + chunkSize) === sourceLength) break; | ||
if (targetOffset + 32 + 4 > targetLength) { | ||
@@ -196,0 +204,0 @@ throw new Error('target overflow'); |
{ | ||
"name": "@ronomon/deduplication", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Fast multi-threaded content-dependent chunking deduplication for Buffers in C++ with a reference implementation in Javascript. Ships with extensive tests, a fuzz test and a benchmark.", | ||
@@ -5,0 +5,0 @@ "main": "binding.node", |
12
test.js
@@ -82,9 +82,9 @@ var crypto = require('crypto'); | ||
} | ||
var buffers = []; | ||
while (size > 0) { | ||
var buffer = Test.randomBytes(Math.min(1024 * 1024, size)); | ||
buffers.push(buffer); | ||
size -= buffer.length; | ||
if (Test.random() < 0.2) { | ||
// Long repeating runs of the same byte tend to hit the maximum threshold. | ||
// This is good for deduplication ratio (and good for bug-spotting). | ||
return Buffer.alloc(size, Math.floor(Test.random() * 256)); | ||
} else { | ||
return Test.randomBytes(size); | ||
} | ||
return Buffer.concat(buffers); | ||
} | ||
@@ -91,0 +91,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90409
1144