opusdev/vector-similarity-api
1
1# range-parser2 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## Installation12 13This is a [Node.js](https://nodejs.org/en/) module available through the14[npm registry](https://www.npmjs.com/). Installation is done using the15[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):16 17```sh18$ npm install range-parser19```20 21## API22 23<!-- eslint-disable no-unused-vars -->24 25```js26var 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 string35 * `-1` signals an unsatisfiable range36 37<!-- eslint-disable no-undef -->38 39```js40// parse header from request41var range = parseRange(size, req.headers.range)42 43// the type of the range44if (range.type === 'bytes') {45 // the ranges46 range.forEach(function (r) {47 // do something with r.start and r.end48 })49}50```51 52#### Options53 54These properties are accepted in the options object.55 56##### combine57 58Specifies if overlapping & adjacent ranges should be combined, defaults to `false`.59When `true`, ranges will be combined and returned as if they were specified that60way in the header.61 62<!-- eslint-disable no-undef -->63 64```js65parseRange(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## License73 74[MIT](LICENSE)75 76[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/range-parser/master77[coveralls-url]: https://coveralls.io/r/jshttp/range-parser?branch=master78[node-image]: https://badgen.net/npm/node/range-parser79[node-url]: https://nodejs.org/en/download80[npm-downloads-image]: https://badgen.net/npm/dm/range-parser81[npm-url]: https://npmjs.org/package/range-parser82[npm-version-image]: https://badgen.net/npm/v/range-parser83[travis-image]: https://badgen.net/travis/jshttp/range-parser/master84[travis-url]: https://travis-ci.org/jshttp/range-parser85 