ammo

HTTP Range processing utilities

This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
Last updated 7 years ago by hueniverse .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ammo 
SYNC missed versions from official npm registry.

ammo

HTTP Range processing utilities.

Npm Version Build Status

Lead Maintainer - Gil Pedersen

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 = async Wreck.read(source.pipe(stream));

// buffer is the portion of source within range

API

header(header, length)

Parses the range from a HTTP header.

  • header - A string in the form of bytes=from-to, where from and to are integers specifying the range. Both are optional. Multiple ranges can be passed as a comma delimited list.
  • length - A positive integer specifying the maximum length the range can cover. If a to value passed in the header string is greater than length, the to value is set as length - 1.

Returns an array of objects with the properties from and to, which specify the beginning and ending of the range. Overlapping ranges are combined into one object. Returns null for invalid input.

new Ammo.Stream(range)

Creates a Transform Stream that extracts the portion of a piped in stream within range.

  • range - an object with the properties from and to that specify the range of the piped in stream to read. Objects returned by Ammo.header can be passed into range.

Current Tags

  • 3.0.3                                ...           latest (7 years ago)
  • 2.1.2                                ...           v2-legacy (2 years ago)

12 Versions

  • 2.1.2 [deprecated]           ...           2 years ago
  • 3.0.3 [deprecated]           ...           7 years ago
  • 3.0.2 [deprecated]           ...           7 years ago
  • 3.0.1 [deprecated]           ...           8 years ago
  • 3.0.0 [deprecated]           ...           9 years ago
  • 2.0.4 [deprecated]           ...           9 years ago
  • 2.0.3 [deprecated]           ...           9 years ago
  • 2.0.2 [deprecated]           ...           10 years ago
  • 2.0.1 [deprecated]           ...           10 years ago
  • 2.0.0 [deprecated]           ...           10 years ago
  • 1.0.1 [deprecated]           ...           11 years ago
  • 1.0.0 [deprecated]           ...           11 years ago
Downloads
Today 0
This Week 0
This Month 5
Last Day 0
Last Week 5
Last Month 1
Dependencies (1)
Dev Dependencies (3)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |