MCPcopy Create free account
hub / github.com/Vanilagy/webcodecs-polyfill / toUint8Array

Function toUint8Array

src/misc.ts:327–335  ·  view source on GitHub ↗
(source: AllowSharedBufferSource)

Source from the content-addressed store, hash-verified

325};
326
327export const toUint8Array = (source: AllowSharedBufferSource): Uint8Array => {
328 if (source.constructor === Uint8Array) { // We want a true Uint8Array, not something that extends it like Buffer
329 return source;
330 } else if (ArrayBuffer.isView(source)) {
331 return new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
332 } else {
333 return new Uint8Array(source);
334 }
335};
336
337export const toDataView = (source: AllowSharedBufferSource): DataView => {
338 if (source.constructor === DataView) {

Callers 10

createCodecContextMethod · 0.85
constructorMethod · 0.85
copyToMethod · 0.85
createCodecContextMethod · 0.85
outputChunkMethod · 0.85
constructorMethod · 0.85
constructorMethod · 0.85
copyToMethod · 0.85
constructorMethod · 0.85
copyToMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected