1.2.1 • Published 5 years ago

range-parser v1.2.1

Weekly downloads
17,823,285
License
MIT
Repository
github
Last release
5 years ago

range-parser

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

Range header field parser.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install range-parser

API

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
// 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.

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

License

MIT

sendexpresswebpack-dev-middlewarekarmacomponennentteasy-select-rnchinjowwchinjowvuedragdropuploadimagesreact-native-bluetooth2killi8n-react-native-fast-image@applitools/snapshot-server-appextensible-node-server@yanneves/serve-handlerrn-send-smsyoukuohao-files@arisageha/react-lazyload@arisageha/react-lazyload-fixwebtorrent-jaliranar-fileswebtorrent-forkreact-native-template-rfbasekarma-3fangwell-comboairscanairscan-examplewebpack-passive-middlewarebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-module@wgytcraft/express@frxf/frxfdeneme323112@texttree/demo-bsa-reference-rcl@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjames@activetheory/serve-handler@oknesar/expressreact-native-covid-sdkanime-random@foldsh/sdk@jginsburgn/karmaeni-chatreact-native-thanh-toast-librarypmswebserve@thanhnguyen14797/react-native-thanh-toast-library@l1nyanm1ng/react-picture-viewercthpb-plugin-social@signalchain/expressexpress-easy-staticreact-native-printer-brothersrn-pdf-reader-offlinereact-native-shekhar-bridge-test@kotx/renderlevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29wilscanner@oiti/documentoscopy-react-nativequoc-testreact-native-slider-kfnodejs-filesharet-flix-serverunblock-block-save-variableswatchnowhexa-node-commoncclibyarntest@saaspe/componentshyperpass-sdkexpress-api-pack-tropea-bootstraapluminos-ui-corewebtorrent-fixsklif-ui-kitsklif-api@everything-registry/sub-chunk-2530jawwy-sdkjawwy_gamification_release@314oner_npm/universal-components-libraryreact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgondp149-tablesklif-uireact-native-jawwy_sample@igniswap/igni-swap-lib@idas1/ui-component-lib@hyperspace/cli@innoswap/core@hieuquang2212/form@hawkingnetwork/react-native-tab-view@homey/server
1.2.1

5 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.3

8 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago