Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const toUint8Array = async (value: Data, maxBytes: ?number): Promise => {
if (value instanceof Uint8Array) // also matches Buffer instances
return value;
if (value instanceof ArrayBuffer)
return new Uint8Array(value);
const reader = new FileReader(value);
const buffer = await reader.readAsArrayBuffer(maxBytes || value.size);
return new Uint8Array(buffer);
};
_initFileMode = (source: Blob | File) => {
this._mode = 'file';
this._source = source;
this._fileReader = new FileReader(source);
}
const toUint8Array = async (value: Data, maxSize: ?number): Promise => {
if (value instanceof Uint8Array)
return value;
if (value instanceof ArrayBuffer)
return new Uint8Array(value);
const reader = new FileReader(value);
const buffer = await reader.readAsArrayBuffer(maxSize || value.size);
return new Uint8Array(buffer);
};