Wondering what’s next for npm?Check out our public roadmap! »

    This package has been deprecated

    Author message:

    This component is deprecated

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

    3.0.1 • Public • Published

    Build Status Published on webcomponents.org Published on NPM

    file-reader

    A web component that reads files.

    Usage

    Installation

    npm install --save @advanced-rest-client/file-reader
    

    In an html file

    <html>
      <head>
        <script type="module">
          import '@advanced-rest-client/file-reader/file-reader.js';
        </script> 
      </head>
      <body>
        <file-reader readas="array-buffer" auto></file-reader>
     
        <script>
        {
          const reader = document.querySelector('file-reader');
          reader.onprogress = (e) => {
            console.log(e.target.progress);
          };
          reader.onread = (e) => {
            console.log(e.detail.result);
          };
          reader.onerror = () => {
            console.log('file is corrupted');
          };
          reader.blob = new Blob(['some text'], {
            type: 'plain/text'
          });
        }
        </script> 
      </body>
    </html>

    In a LitElement

    import { LitElement, html } from 'lit-element';
    import '@advanced-rest-client/file-reader/file-reader.js';
     
    class SampleElement extends PolymerElement {
      render() {
        return html`
        <file-reader
          readas="text"
          @progress="${this._progressHandler}"
          @read="${this._readHandler}"
          @error="${this._errorHandler}"></file-reader>
        `;
      }
     
      _progressHandler(e) {
        ...
      }
     
      _readHandler(e) {
        ...
      }
     
      _errorHandler() {
        ...
      }
    }
    customElements.define('sample-element', SampleElement);

    Development

    git clone https://github.com/advanced-rest-client/file-reader
    cd file-reader
    npm install

    Running the tests

    npm test

    API components

    This components is a part of API components ecosystem

    Install

    npm i @advanced-rest-client/file-reader

    DownloadsWeekly Downloads

    0

    Version

    3.0.1

    License

    Apache-2.0

    Unpacked Size

    33.5 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar