Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jsantell/event-target
Simple EventTarget implementation.
https://github.com/jsantell/event-target
Last synced: 3 months ago
JSON representation
Simple EventTarget implementation.
- Host: GitHub
- URL: https://github.com/jsantell/event-target
- Owner: jsantell
- License: mit
- Created: 2018-05-25T01:35:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-24T23:33:33.000Z (over 1 year ago)
- Last Synced: 2024-09-14T10:06:55.946Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 29.3 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# event-target
[![Build Status](http://img.shields.io/npm/v/@jsantell/event-target.svg?style=flat-square)](https://www.npmjs.org/package/@jsantell/event-target)
Simple implementation of [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget). Hosted on [npm](https://npmjs.org) as [@jsantell/event-target](https://www.npmjs.org/package/@jsantell/event-target). ES6-ified for inclusion via module bundler.
## Installation
`$ npm install --save @jsantell/event-target`
## Usage
```js
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