https://github.com/uphold/range-specifier-parser
Range Specifier Parser
https://github.com/uphold/range-specifier-parser
Last synced: 10 months ago
JSON representation
Range Specifier Parser
- Host: GitHub
- URL: https://github.com/uphold/range-specifier-parser
- Owner: uphold
- License: mit
- Created: 2015-01-27T18:21:35.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-04-09T21:33:55.000Z (about 3 years ago)
- Last Synced: 2025-06-02T09:09:30.878Z (about 1 year ago)
- Language: JavaScript
- Size: 78.1 KB
- Stars: 1
- Watchers: 55
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Range Specifier Parser
[![npm version][npm-image]][npm-url] [![build status][travis-image]][travis-url]
A parser to handle [Range Pagination Headers](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
_Inspired by [range-parser](https://github.com/jshttp/range-parser)_.
## Installation
`npm install --save range-specifier-parser`
## Usage
The parser receives a `byte-ranges-specifier` as its only argument.
```javascript
import parser from 'range-specifier-parser';
parser('bytes=0-499');
```
## Output
The parser outputs an object with the following properties according to the [Byte Ranges](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1) spec:
```javascript
{
first: 0, // `first-byte-pos`.
last: 499, // `last-byte-pos`.
unit: 'bytes' // `bytes-unit`.
}
```
## Running tests
```sh
npm test
```
## Release
`npm version [ | major | minor | patch] -m "Release %s"`
## License
MIT
[npm-image]: https://img.shields.io/npm/v/range-specifier-parser.svg?style=flat-square
[npm-url]: https://npmjs.org/package/range-specifier-parser
[travis-image]: https://img.shields.io/travis/seegno/range-specifier-parser.svg?style=flat-square
[travis-url]: https://travis-ci.org/seegno/range-specifier-parser