Noctiflorous Pansy Mulch

    @tanker/file-reader
    TypeScript icon, indicating that this package has built-in type declarations

    2.31.0 • Public • Published

    License NPM Package Minified Size

    A promisified FileReader for browsers

    A promisified FileReader implementation very similar to the browser's FileReader API, with a few differencies:

    • the File or Blob instance is given at construction time;
    • all readAs... methods don't take a Blob or File instance as first argument anymore;
    • all readAs... methods return a Promise that can be awaited;
    • reading in chunks is easy as:
      • you just need to await the next chunk (no event / callback API anymore);
      • the current reading position is automatically tracked.

    Usage

    import FileReader from '@tanker/file-reader';
    
    // Retrieve a file or blob somehow
    const file = new File(
      ['The quick brown fox jumps over the lazy dog'],
      'fox.txt',
      { type: 'plain/text' }
    );
    
    // Create your file reader
    const reader = new FileReader(file);
    
    // Read the whole file
    const text = await reader.readAsText('UTF-8');
    const dataUrl = await reader.readAsDataURL();
    const arrayBuffer = await reader.readAsArrayBuffer();
    
    // Or read binary chunks (ArrayBuffer)
    const chunkSize = 8; // bytes
    let chunk;
    do {
      chunk = await reader.readAsArrayBuffer(chunkSize);
      // do something with the chunk
    } while (chunk.byteLength > 0);

    License

    Developped by Tanker, under the Apache-2.0 license.

    Tanker's client SDKs allow for seamless integration of client-side end-to-end encryption in your application.

    Tanker is available for iOS, Android, and Web apps.

    Read the documentation to get started.

    Go to tanker.io for more information about Tanker.

    Install

    npm i @tanker/file-reader

    Homepage

    tanker.io/

    DownloadsWeekly Downloads

    4,224

    Version

    2.31.0

    License

    Apache-2.0

    Unpacked Size

    13.8 kB

    Total Files

    11

    Last publish

    Collaborators

    • maximerety
    • tankeradmin
    • quentin.vernot.tanker
    • marwyn
    • jeremad