Merge branch 'master' into refactor
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Jason Miller · committed by GitHub · parents 70e8ad1, 1fbe781 · Browse files · 4 files·+95 added−24 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+95 added−24 removed
- other:+95 added−24 removed
Provenance
- Commit
4799316- Tree
4d6508f- Author
Jason Miller <developit@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent 1
70e8ad1- Parent 2
1fbe781
4 files changed+95 added−24 removed
added:.babelrc+3 added
1+{2+ "presets": ["es2015", "stage-0"]3+}added:LICENSE.md+21 added
123456789101112131415161718192021The MIT License (MIT)
Copyright (c) 2017 Jason Miller
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.modified:package.json+1 added-7 removed
12344567823 unmodified lines323334353637383940413637383931 unmodified lines{ "name": "mitt", "amdName": "mitt", "version": "1.0.0", "version": "1.0.1", "description": "Tiny ~200b functional event emitter / pubsub.", "jsnext:main": "src/index.js", "main": "dist/mitt.js", "umd:main": "dist/mitt.umd.js",23 unmodified lines "files": [ "src", "dist" ], "babel": { "presets": [ "es2015", "stage-0" ] }, "eslintConfig": { "parser": "babel-eslint", "extends": "eslint:recommended", "env": {31 unmodified linesmodified:README.md+70 added-17 removed
1 <p align="center">2- <img src="https://i.imgur.com/BqsX9NT.png" width="256" height="256" alt="mitt">2+ <img src="https://i.imgur.com/BqsX9NT.png" width="300" height="300" alt="mitt">3 <br>4- <b>Mitt</b>: tiny 200b functional event emitter / pubsub.5- <br>6- <a href="https://www.npmjs.org/package/mitt"><img src="https://img.shields.io/npm/v/mitt.svg?style=flat" alt="npm"></a> <a href="https://travis-ci.org/developit/mitt"><img src="https://travis-ci.org/developit/mitt.svg?branch=master" alt="travis"></a>4+ <a href="https://www.npmjs.org/package/mitt"><img src="https://img.shields.io/npm/v/mitt.svg?style=flat" alt="npm"></a> <a href="https://travis-ci.org/developit/mitt"><img src="https://travis-ci.org/developit/mitt.svg?branch=master" alt="travis"></a> <a href="https://david-dm.org/developit/mitt"><img src="https://david-dm.org/developit/mitt/status.svg" alt="dependencies Status"></a>5 </p>6 9-## Why Mitt?7+# Mitt8 9+> Tiny 200b functional event emitter / pubsub.10+11 - **Microscopic:** weighs less than 200 bytes gzipped12 - **Useful:** a wildcard `"*"` event type listens to all events13 - **Familiar:** same names & ideas as [Node's EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)14 - **Functional:** methods don't rely on `this`15 - **Great Name:** somehow [mitt](https://npm.im/mitt) wasn't taken16 17-> Mitt was made for the browser, but works in any JavaScript runtime. It has no dependencies and supports IE9+.17+Mitt was made for the browser, but works in any JavaScript runtime. It has no dependencies and supports IE9+.18 19-## Examples & Demos19+## Table of Contents20+- [Install](#install)21+- [Usage](#usage)22+- [Examples & Demos](#examples--demos)23+- [API](#api)24+- [Contribute](#contribute)25+- [License](#license)26 21-<a href="http://codepen.io/developit/pen/rjMEwW?editors=0110">22- <b>Preact + Mitt Codepen Demo</b>23- <br>24- <img src="https://i.imgur.com/CjBgOfJ.png" width="278" alt="preact + mitt preview">25-</a>27+## Install28 27-* * *29+This project uses [node](http://nodejs.org) and [npm](https://npmjs.com). Go check them out if you don't have them locally installed.30 29-## Usage31+```sh32+$ npm install --save mitt33+```34 31-After installing via `npm install --save mitt`:35+Then with a module bundler like [rollup](http://rollupjs.org/) or [webpack](https://webpack.js.org/), use as you would anything else:36 37+```javascript38+// using ES6 modules39+import mitt from 'mitt'40+41+// using CommonJS modules42+var mitt = require('mitt')43+```44+45+The [UMD](https://github.com/umdjs/umd) build is also available on [unpkg](https://unpkg.com):46+47+```html48+<script src="https://unpkg.com/mitt/dist/mitt.umd.js"></script>49+```50+You can find the library on `window.mitt`.51+52+## Usage53+54 ```js55 import mitt from 'mitt'56 57 let emitter = mitt()12 unmodified lines70 emitter.on('foo', onFoo) // listen71 emitter.off('foo', onFoo) // unlisten72 ```73 53-* * *74+## Examples & Demos75 76+<a href="http://codepen.io/developit/pen/rjMEwW?editors=0110">77+ <b>Preact + Mitt Codepen Demo</b>78+ <br>79+ <img src="https://i.imgur.com/CjBgOfJ.png" width="278" alt="preact + mitt preview">80+</a>81+82 ## API83 84 ### mitt85 86 Mitt: Tiny (~200b) functional event emitter / pubsub.87 61-Returns **Mitt** 88+Returns **Mitt**89 90 #### emit91 92 Invoke all handlers for the given type.26 unmodified lines119 - `type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of event to unregister `handler` from, or `"*"`120 - `handler` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Handler function to remove121 122 Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** the `mitt` instance for chaining123+124+## Contribute125+First off, thanks for taking the time to contribute!126+Now, take a moment to be sure your contributions make sense to everyone else.127+128+### Reporting Issues129+Found a problem? Want a new feature? First of all see if your issue or idea has [already been reported](../../issues).130+If don't, just open a [new clear and descriptive issue](../../issues/new).131+132+### Submitting pull requests133+Pull requests are the greatest contributions, so be sure they are focused in scope, and do avoid unrelated commits.134+135+- Fork it!136+- Clone your fork: `git clone https://github.com/<your-username>/mitt`137+- Navigate to the newly cloned directory: `cd mitt`138+- Create a new branch for the new feature: `git checkout -b my-new-feature`139+- Install the tools necessary for development: `npm install`140+- Make your changes.141+- Commit your changes: `git commit -am 'Add some feature'`142+- Push to the branch: `git push origin my-new-feature`143+- Submit a pull request with full remarks documenting your changes.144+145+## License146+147+[MIT License](LICENSE.md) © [Jason Miller](https://jasonformat.com/)148+