testuser/mitt

Tiny functional event emitter / pubsub

⭐ 0 stars💬 0 comments

Files

📄 .editorconfig302 B
📄 .eslintrc1013 B
📁 .github
📄 .gitignore103 B
📄 LICENSE1 KB
📄 README.md6.1 KB
📄 package.json2.3 KB
📁 src
📁 test
📄 tsconfig.json240 B

README

<p align="center"> <img src="https://i.imgur.com/BqsX9NT.png" width="300" height="300" alt="mitt"> <br> <a href="https://www.npmjs.org/package/mitt"><img src="https://img.shields.io/npm/v/mitt.svg" alt="npm"></a> <img src="https://github.com/developit/mitt/workflows/CI/badge.svg" alt="build status"> <a href="https://unpkg.com/mitt/dist/mitt.js"><img src="https://img.badgesize.io/https://unpkg.com/mitt/dist/mitt.js?compression=gzip" alt="gzip size"></a> </p> # Mitt > Tiny 200b functional event emitter / pubsub. - **Microscopic:** weighs less than 200 bytes gzipped - **Useful:** a wildcard `"*"` event type listens to all events - **Familiar:** same names & ideas as [Node's EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) - **Functional:** methods don't rely on `this` - **Great Name:** somehow [mitt](https://npm.im/mitt) wasn't taken Mitt was made for the browser, but works in any JavaScript runtime. It has no dependencies and supports IE9+. ## Table of Contents - [Install](#install) - [Usage](#usage) - [Examples & Demos](#examples--demos) - [API](#api) - [Contribute](#contribute) - [License](#license) ## Install This project uses [node](http://nodejs.org) and [npm](https://npmjs.com). Go check them out if you don't have them locally installed. ```sh $ npm install --save mitt ``` Then with a module bundler like [rollup](http://rollupjs.org/) or [webpack](https://webpack.js.org/), use as you would anything else: ```javascript // using ES6 modules import mitt from 'mitt' // using CommonJS modules var mitt = require('mitt') ``` The [UMD](https://github.com/umdjs/umd) build is also available on [unpkg](https://unpkg.com): ```html <script src="https://unpkg.com/mitt/dist/mitt.umd.js"></script> ``` You can find the library on `window.mitt`. ## Usage ```js import mitt from 'mitt' const emitter = mitt() // listen to an event emitter.on('foo', e => console.log('foo', e) ) // listen to all events emit
SocialRepo
Login

loading/repo...

Latest Updates

Discussion