Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

ammo

Package Overview
Dependencies
1
Maintainers
5
Versions
11
Issues
File Explorer

Advanced tools

ammo

HTTP Range processing utilities

    3.0.3latest

Version published
Maintainers
5
Weekly downloads
94,272
increased by10.35%

Weekly downloads

Readme

Source

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.

Keywords

FAQs

What is ammo?

HTTP Range processing utilities

Is ammo popular?

The npm package ammo receives a total of 76,139 weekly downloads. As such, ammo popularity was classified as popular.

Is ammo well maintained?

We found that ammo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 5 open source maintainers collaborating on the project.

Last updated on 03 Nov 2018

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc