1.1.3 • Published 4 years ago

@jsantell/event-target v1.1.3

Weekly downloads
21
License
MIT
Repository
github
Last release
4 years ago

event-target

Build Status

Simple implementation of EventTarget. Hosted on npm as @jsantell/event-target. ES6-ified for inclusion via module bundler.

Installation

$ npm install --save @jsantell/event-target

Usage

import EventTarget from '@jsantell/event-target';

class ChunkReader extends EventTarget {
  constructor(data) {
    this.data = data;

    requestAnimationFrame(() => this.read(data));
  }

  read() {
    for (let i = 0; i < this.data.length; i += 4) {
      this.dispatchEvent('chunk', this.data.substr(i, 4));
    }
    this.dispatchEvent('end');
  }
}

const reader = new ChunkReader('hello world!');
reader.addEventListener('chunk', c => console.log('chunk!'));
reader.addEventListener('end', () => console.log('end!'));

Build

$ npm run build

Publish

$ npm run version

License

MIT License, Copyright © 2018 Jordan Santell

1.1.3

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

6 years ago