rx-player
Version:
Canal+ HTML5 Video Player
16 lines (15 loc) • 392 B
JavaScript
/**
* Convert a vague "BufferSource" binary data into a more exploitable and known
* `Uint8Array`.
* @param {BufferSource} bs
* @returns {Uint8Array}
*/
export default function bufferSourceToUint8(bs) {
if (bs instanceof Uint8Array) {
return bs;
}
else if (bs instanceof ArrayBuffer) {
return new Uint8Array(bs);
}
return new Uint8Array(bs.buffer);
}