source: trip-planner-front/node_modules/range-parser/README.md@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.2 KB
Line 
1# range-parser
2
3[![NPM Version][npm-version-image]][npm-url]
4[![NPM Downloads][npm-downloads-image]][npm-url]
5[![Node.js Version][node-image]][node-url]
6[![Build Status][travis-image]][travis-url]
7[![Test Coverage][coveralls-image]][coveralls-url]
8
9Range header field parser.
10
11## Installation
12
13This is a [Node.js](https://nodejs.org/en/) module available through the
14[npm registry](https://www.npmjs.com/). Installation is done using the
15[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
16
17```sh
18$ npm install range-parser
19```
20
21## API
22
23<!-- eslint-disable no-unused-vars -->
24
25```js
26var parseRange = require('range-parser')
27```
28
29### parseRange(size, header, options)
30
31Parse the given `header` string where `size` is the maximum size of the resource.
32An array of ranges will be returned or negative numbers indicating an error parsing.
33
34 * `-2` signals a malformed header string
35 * `-1` signals an unsatisfiable range
36
37<!-- eslint-disable no-undef -->
38
39```js
40// parse header from request
41var range = parseRange(size, req.headers.range)
42
43// the type of the range
44if (range.type === 'bytes') {
45 // the ranges
46 range.forEach(function (r) {
47 // do something with r.start and r.end
48 })
49}
50```
51
52#### Options
53
54These properties are accepted in the options object.
55
56##### combine
57
58Specifies if overlapping & adjacent ranges should be combined, defaults to `false`.
59When `true`, ranges will be combined and returned as if they were specified that
60way in the header.
61
62<!-- eslint-disable no-undef -->
63
64```js
65parseRange(100, 'bytes=50-55,0-10,5-10,56-60', { combine: true })
66// => [
67// { start: 0, end: 10 },
68// { start: 50, end: 60 }
69// ]
70```
71
72## License
73
74[MIT](LICENSE)
75
76[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/range-parser/master
77[coveralls-url]: https://coveralls.io/r/jshttp/range-parser?branch=master
78[node-image]: https://badgen.net/npm/node/range-parser
79[node-url]: https://nodejs.org/en/download
80[npm-downloads-image]: https://badgen.net/npm/dm/range-parser
81[npm-url]: https://npmjs.org/package/range-parser
82[npm-version-image]: https://badgen.net/npm/v/range-parser
83[travis-image]: https://badgen.net/travis/jshttp/range-parser/master
84[travis-url]: https://travis-ci.org/jshttp/range-parser
Note: See TracBrowser for help on using the repository browser.