code: function getRange(str, size) {
    let index = str ? str.indexOf('=') : -1
    if (index === -1) {
      return -2
    }
    // 把range转换为数组
    let arr = str.slice(index + 1).split(',')
    let ranges = []
    // 记录range的类型
    ranges.AcceptRanges = str.slice(0, index)
    // 获取文件长度
    for (let i = 0; i < arr.length; i++) {
      let range = arr[i].split('-')
      let start = parseInt(range[0], 10)
      let end = parseInt(range[1], 10)
      // start为数字时
      if (isNaN(start)) {
        start = size - end
        end = size - 1
        // end为数字时
      } else if (isNaN(end)) {
        end = size - 1
      }
      // 结束不得大于文件大小
      if (end > size - 1) {
        end = size - 1
      }
      // start与end都为数字,且0<=start<=end
      if (!isNaN(start) && !isNaN(end) && start >= 0 && start <= end) {
        ranges.push({
          ContentRange:
            ranges.AcceptRanges + ' ' + start + '-' + end + '/' + size,
          ContentLength: end - start + 1,
          start: start,
          end: end
        })
      }
    }
    // 没有获取到有效的range值
    if (ranges.length < 1) {
      return -1
    }
    return ranges
  }
docs: 获取range信息
  @param  {String} str  request header range
  @param  {Number} size file size
  @return {Object}