> For the complete documentation index, see [llms.txt](https://bryan-guner.gitbook.io/my-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bryan-guner.gitbook.io/my-docs/redux/repos/examples/real-world/node_modules/range-parser.md).

# range-parser

[![NPM Version](https://badgen.net/npm/v/range-parser)](https://npmjs.org/package/range-parser) [![NPM Downloads](https://badgen.net/npm/dm/range-parser)](https://npmjs.org/package/range-parser) [![Node.js Version](https://badgen.net/npm/node/range-parser)](https://nodejs.org/en/download) [![Build Status](https://badgen.net/travis/jshttp/range-parser/master)](https://travis-ci.org/jshttp/range-parser) [![Test Coverage](https://badgen.net/coveralls/c/github/jshttp/range-parser/master)](https://coveralls.io/r/jshttp/range-parser?branch=master)

Range header field parser.

## Installation

This is a [Node.js](https://nodejs.org/en/) module available through the [npm registry](https://www.npmjs.com/). Installation is done using the [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):

```
$ npm install range-parser
```

## API

```js
var parseRange = require('range-parser')
```

### parseRange(size, header, options)

Parse the given `header` string where `size` is the maximum size of the resource. An array of ranges will be returned or negative numbers indicating an error parsing.

* `-2` signals a malformed header string
* `-1` signals an unsatisfiable range

```js
// parse header from request
var range = parseRange(size, req.headers.range)

// the type of the range
if (range.type === 'bytes') {
  // the ranges
  range.forEach(function (r) {
    // do something with r.start and r.end
  })
}
```

#### Options

These properties are accepted in the options object.

**combine**

Specifies if overlapping & adjacent ranges should be combined, defaults to `false`. When `true`, ranges will be combined and returned as if they were specified that way in the header.

```js
parseRange(100, 'bytes=50-55,0-10,5-10,56-60', { combine: true })
// => [
//      { start: 0,  end: 10 },
//      { start: 50, end: 60 }
//    ]
```

## License

[MIT](https://github.com/bgoonz/Learning-Redux/blob/master/repos/examples/real-world/node_modules/range-parser/LICENSE/README.md)
