ammo

HTTP Range processing utilities.

Latest Version: 5.0.1
hapi-family
Installation:

npm: npm install @hapi/ammo

yarn: yarn add @hapi/ammo

Module Status:
Version License Node Dependencies Travis End of Life
5.0.1
hapi helmet github logo
BSD 12 Dependency Status Build Status
3.1.2
hapi helmet github logo
BSD 12, 10, 8 Dependency Status Build Status
2.1.1
hapi helmet github logo
Commercial 10, 8, 6 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