ammo

HTTP Range processing utilities.

Latest Version: 6.0.1
hapi-family
Installation:

npm: npm install @hapi/ammo

yarn: yarn add @hapi/ammo

Module Status:
Version License Node Dependencies CI
6.0.1
hapi helmet github logo
BSD 16, 18, 20 Dependency Status Build Status
5.0.1
hapi helmet github logo
BSD 16, 18, 20 Dependency Status Build Status

Usage

// basic usage
const range = Ammo.header('bytes=1-5', 10);
// range --> [{ from: 1, to: 5 }]

// multiple ranges
const range = Ammo.header('bytes=1-5,7-10', 10);
// range --> [{ from: 1, to: 5 }, { from: 7, to: 9 }]

// streams (get range within a `source`)
const range = Ammo.header('bytes=1000-4000', 5000);
const stream = new Ammo.Stream(range[0]);
const buffer = await Wreck.read(source.pipe(stream));

// buffer is the portion of source within range