DFS_Shuo_Chen e2eb47a926 V1.16.9 4 місяців тому
..
HISTORY.md e2eb47a926 V1.16.9 4 місяців тому
LICENSE e2eb47a926 V1.16.9 4 місяців тому
README.md e2eb47a926 V1.16.9 4 місяців тому
index.js e2eb47a926 V1.16.9 4 місяців тому
package.json e2eb47a926 V1.16.9 4 місяців тому

README.md

range-parser

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

Range header field parser.

Installation

$ npm install range-parser

API

var parseRange = require('range-parser')

parseRange(size, header)

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 invalid range

    // parse header from request
    var range = parseRange(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
    })
    }
    

License

MIT