ram-chunker

Rapid Asymmetric Maximum (RAM) is a high throughput, hash-less, byte shift-resistant content-defined chunking algorithm for data deduplication.

Usage no npm install needed!

<script type="module">
  import ramChunker from 'https://cdn.skypack.dev/ram-chunker';
</script>

README

ram-chunker

Rapid Asymmetric Maximum (RAM) is a high throughput, hash-less, byte shift-resistant content-defined chunking algorithm for data deduplication.

This package is a JavaScript implementation of RAM as described in the paper "A new content-defined chunking algorithm for data deduplication in cloud storage".

Installation

npm install ram-chunker

Usage

Get chunk indices

const { getCutPoints } = require("ram-chunker");

const data = "This is a test sentence.";
const windowSize = 4;
const cutPoints = getCutPoints(data, windowSize);

console.log(cutPoints); // [ 0, 7, 14, 19 ]

Get chunks from indices

const result = [];

for (let i = 0; i < cutPoints.length; i++) {
  const cutPoint = cutPoints[i];
  const nextcutPoint = cutPoints[i + 1];

  result[result.length] = data.slice(cutPoint, nextcutPoint);
}

console.log(result); // [ 'This is', ' a test', ' sent', 'ence.' ]