Files
music-platform/node_modules/range-parser/README.md
hz4th_coder 595670b6ce feat: 音乐展示平台 v1.0.0
- 响应式设计,支持桌面端和手机端自适应
- 首页展示轮播图、推荐歌单、热门歌曲、新碟上架、热门歌手
- 歌曲/歌手/专辑/歌单详情页
- 底部播放器:播放/暂停、上下首、进度拖动、音量控制
- 歌词同步滚动显示
- 搜索功能
- 后台管理 /admin
- JSON文件存储
2026-07-07 23:57:31 +08:00

2.2 KiB

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