MCPcopy
hub / github.com/alyssaxuu/motionity / convertToUint8Array

Function convertToUint8Array

src/js/webm-writer2.js:269–286  ·  view source on GitHub ↗
(thing)

Source from the content-addressed store, hash-verified

267 }
268
269 function convertToUint8Array(thing) {
270 return new Promise(function(resolve, reject) {
271 if (thing instanceof Uint8Array) {
272 resolve(thing);
273 } else if (thing instanceof ArrayBuffer || ArrayBuffer.isView(thing)) {
274 resolve(new Uint8Array(thing));
275 } else if (thing instanceof Blob) {
276 resolve(readBlobAsBuffer(thing).then(function(buffer) {
277 return new Uint8Array(buffer);
278 }));
279 } else {
280 // Assume that Blob will know how to read this thing
281 resolve(readBlobAsBuffer(new Blob([thing])).then(function(buffer) {
282 return new Uint8Array(buffer);
283 }));
284 }
285 });
286 }
287
288 function measureData(data) {
289 let result = data.byteLength || data.length || data.size;

Callers 1

BlobBufferFunction · 0.85

Calls 2

resolveFunction · 0.85
readBlobAsBufferFunction · 0.85

Tested by

no test coverage detected