dist/wavefile.js
function unpackArrayTo(
    buffer, theType, output, start=0, end=buffer.length, safe=false) {
  theType = theType || {};
  /** @type {NumberBuffer} */
  let packer = new NumberBuffer(theType.bits, theType.fp, theType.signed);
  /** @type {number} */
  let offset = packer.offset;
  // getUnpackLen_ will either fix the length of the input buffer
  // according to the byte offset of the type (on unsafe mode) or
  // throw a Error if the input buffer has a bad length (on safe mode)
  end = getUnpackLen_(buffer, start, end, offset, safe);
  /** @type {number} */
  let index = 0;
  let j = start;
  try {
    if (theType.be) {
      endianness(buffer, offset, start, end);
    }
    for (; j < end; j += offset, index++) {
      output[index] = packer.unpack(buffer, j);
    }
    if (theType.be) {
      endianness(buffer, offset, start, end);
    }
  } catch (e) {
    throwValueError_(e, buffer.slice(j, j + offset), j, theType.fp);
  }
}
function unpackArrayTo(
    buffer, theType, output, start=0, end=buffer.length, safe=false) {
  theType = theType || {};
  /** @type {NumberBuffer} */
  let packer = new NumberBuffer(theType.bits, theType.fp, theType.signed);
  /** @type {number} */
  let offset = packer.offset;
  // getUnpackLen_ will either fix the length of the input buffer
  // according to the byte offset of the type (on unsafe mode) or
  // throw a Error if the input buffer has a bad length (on safe mode)
  end = getUnpackLen_(buffer, start, end, offset, safe);
  /** @type {number} */
  let index = 0;
  let j = start;
  try {
    if (theType.be) {
      endianness(buffer, offset, start, end);
    }
    for (; j < end; j += offset, index++) {
      output[index] = packer.unpack(buffer, j);
    }
    if (theType.be) {
      endianness(buffer, offset, start, end);
    }
  } catch (e) {
    throwValueError_(e, buffer.slice(j, j + offset), j, theType.fp);
  }
}
function unpackArrayTo ( buffer , theType , output , start = 0 , end = buffer . length , safe = false ) { theType = theType || { } ; /** @type {NumberBuffer} */ let packer = new NumberBuffer ( theType . bits , theType . fp , theType . signed ) ; /** @type {number} */ let offset = packer . offset ; // getUnpackLen_ will either fix the length of the input buffer // according to the byte offset of the type (on unsafe mode) or // throw a Error if the input buffer has a bad length (on safe mode) end = getUnpackLen_ ( buffer , start , end , offset , safe ) ; /** @type {number} */ let index = 0 ; let j = start ; try { if ( theType . be ) { endianness ( buffer , offset , start , end ) ; } for ( ; j < end ; j += offset , index ++ ) { output [ index ] = packer . unpack ( buffer , j ) ; } if ( theType . be ) { endianness ( buffer , offset , start , end ) ; } } catch ( e ) { throwValueError_ ( e , buffer . slice ( j , j + offset ) , j , theType . fp ) ; } }
Unpack a array of numbers to a typed array.
All other unpacking functions are interfaces to this function.
@param {!Uint8Array|!Array<number>} buffer The byte buffer.
@param {!Object} theType The type definition.
@param {!TypedArray|!Array<number>} output The output array.
@param {number=} start The buffer index to start reading.
Assumes zero if undefined.
@param {number=} end The buffer index to stop reading.
Assumes the buffer length if undefined.
@param {boolean=} safe If set to false, extra bytes in the end of
the array are ignored and input buffers with insufficient bytes will
write nothing to the output array. If safe is set to true the function
will throw a 'Bad buffer length' error. Defaults to false.
@throws {Error} If the type definition is not valid
@throws {Error} On overflow
Unpack a array of numbers to a typed array . All other unpacking functions are interfaces to this function .