Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # range-parser
  2. [![NPM Version][npm-image]][npm-url]
  3. [![NPM Downloads][downloads-image]][downloads-url]
  4. [![Node.js Version][node-version-image]][node-version-url]
  5. [![Build Status][travis-image]][travis-url]
  6. [![Test Coverage][coveralls-image]][coveralls-url]
  7. Range header field parser.
  8. ## Installation
  9. ```
  10. $ npm install range-parser
  11. ```
  12. ## API
  13. ```js
  14. var parseRange = require('range-parser')
  15. ```
  16. ### parseRange(size, header, options)
  17. Parse the given `header` string where `size` is the maximum size of the resource.
  18. An array of ranges will be returned or negative numbers indicating an error parsing.
  19. * `-2` signals a malformed header string
  20. * `-1` signals an unsatisfiable range
  21. ```js
  22. // parse header from request
  23. var range = parseRange(size, req.headers.range)
  24. // the type of the range
  25. if (range.type === 'bytes') {
  26. // the ranges
  27. range.forEach(function (r) {
  28. // do something with r.start and r.end
  29. })
  30. }
  31. ```
  32. #### Options
  33. These properties are accepted in the options object.
  34. ##### combine
  35. Specifies if overlapping & adjacent ranges should be combined, defaults to `false`.
  36. When `true`, ranges will be combined and returned as if they were specified that
  37. way in the header.
  38. ```js
  39. parseRange(100, 'bytes=50-55,0-10,5-10,56-60', { combine: true })
  40. // => [
  41. // { start: 0, end: 10 },
  42. // { start: 50, end: 60 }
  43. // ]
  44. ```
  45. ## License
  46. [MIT](LICENSE)
  47. [npm-image]: https://img.shields.io/npm/v/range-parser.svg
  48. [npm-url]: https://npmjs.org/package/range-parser
  49. [node-version-image]: https://img.shields.io/node/v/range-parser.svg
  50. [node-version-url]: https://nodejs.org/endownload
  51. [travis-image]: https://img.shields.io/travis/jshttp/range-parser.svg
  52. [travis-url]: https://travis-ci.org/jshttp/range-parser
  53. [coveralls-image]: https://img.shields.io/coveralls/jshttp/range-parser.svg
  54. [coveralls-url]: https://coveralls.io/r/jshttp/range-parser
  55. [downloads-image]: https://img.shields.io/npm/dm/range-parser.svg
  56. [downloads-url]: https://npmjs.org/package/range-parser