How to use the @tanker/file-reader function in @tanker/file-reader

To help you get started, we’ve selected a few @tanker/file-reader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TankerHQ / sdk-js / packages / types / src / data-types.js View on Github external
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);
};
github TankerHQ / sdk-js / packages / stream / base / src / SlicerStream.js View on Github external
_initFileMode = (source: Blob | File) => {
    this._mode = 'file';
    this._source = source;
    this._fileReader = new FileReader(source);
  }
github TankerHQ / sdk-js / packages / client-browser / src / dataHelpers.js View on Github external
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);
};

@tanker/file-reader

A promisified FileReader for browsers

Apache-2.0
Latest version published 5 months ago

Package Health Score

65 / 100
Full package analysis

Popular @tanker/file-reader functions