Socket
Socket
Sign inDemoInstall

@hapi/ammo

Package Overview
Dependencies
1
Maintainers
6
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hapi/ammo


Version published
Maintainers
6
Install size
58.5 kB
Created

Package description

What is @hapi/ammo?

@hapi/ammo is a utility library for HTTP payload processing, specifically designed to handle HTTP payload ranges. It is part of the hapi ecosystem and is used to parse and validate HTTP Range headers, which are often used for partial content delivery.

What are @hapi/ammo's main functionalities?

Range Parsing

This feature allows you to parse the 'Range' HTTP header and determine the byte ranges requested by the client. The `Ammo.header` function takes the range header and the total length of the resource, returning an array of ranges.

const Ammo = require('@hapi/ammo');

const rangeHeader = 'bytes=0-4,9-15';
const length = 20;
const ranges = Ammo.header(rangeHeader, length);

console.log(ranges);

Range Validation

This feature validates the parsed ranges to ensure they are within the bounds of the resource length. If the ranges are valid, it returns an array of ranges; otherwise, it returns null.

const Ammo = require('@hapi/ammo');

const rangeHeader = 'bytes=0-4,9-15';
const length = 20;
const ranges = Ammo.header(rangeHeader, length);

if (ranges) {
  console.log('Valid ranges:', ranges);
} else {
  console.log('Invalid range header');
}

Other packages similar to @hapi/ammo

Readme

Source

@hapi/ammo

HTTP Range processing utilities.

ammo is part of the hapi ecosystem and was designed to work seamlessly with the hapi web framework and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out hapi – they work even better together.

Visit the hapi.dev Developer Portal for tutorials, documentation, and support

Useful resources

Keywords

FAQs

Last updated on 09 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc