Skip to content

Commit af189c4

Browse files
authored
Merge branch 'master' into master
2 parents 3fb2dc2 + 1fbe781 commit af189c4

File tree

5 files changed

+116
-24
lines changed

5 files changed

+116
-24
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015", "stage-0"]
3+
}

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[{package.json,.*rc,*.yml}]
11+
indent_style = space
12+
indent_size = 2
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
indent_style = space
17+
indent_size = 2

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Jason Miller
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,55 @@
11
<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">
33
<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>
75
</p>
86

7+
# Mitt
98

10-
## Why Mitt?
9+
> Tiny 200b functional event emitter / pubsub.
1110
12-
- **Microscopic:** weighs less than 200 bytes gzipped
13-
- **Useful:** a wildcard `"*"` event type listens to all events
14-
- **Famliar:** same names & ideas as [Node's EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
15-
- **Functional:** methods don't rely on `this`
16-
- **Great Name:** somehow [mitt](https://npm.im/mitt) wasn't taken
11+
- **Microscopic:** weighs less than 200 bytes gzipped
12+
- **Useful:** a wildcard `"*"` event type listens to all events
13+
- **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 taken
1716

18-
> Mitt was made for the browser, but works in any JavaScript runtime. It has no dependencies and only uses basic language features. It probably works in Internet Explorer 5.
17+
Mitt was made for the browser, but works in any JavaScript runtime. It has no dependencies and supports IE9+.
1918

19+
## Table of Contents
20+
- [Install](#install)
21+
- [Usage](#usage)
22+
- [Examples & Demos](#examples--demos)
23+
- [API](#api)
24+
- [Contribute](#contribute)
25+
- [License](#license)
2026

21-
* * *
27+
## Install
2228

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.
2330

24-
## Usage
31+
```sh
32+
$ npm install --save mitt
33+
```
34+
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+
```javascript
38+
// using ES6 modules
39+
import mitt from 'mitt'
40+
41+
// using CommonJS modules
42+
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+
```html
48+
<script src="https://unpkg.com/mitt/dist/mitt.umd.js"></script>
49+
```
50+
You can find the library on `window.mitt`.
2551

26-
After installing via `npm install --save mitt`:
52+
## Usage
2753

2854
```js
2955
import mitt from 'mitt'
@@ -45,15 +71,21 @@ emitter.on('foo', onFoo) // listen
4571
emitter.off('foo', onFoo) // unlisten
4672
```
4773

48-
* * *
74+
## Examples & Demos
75+
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>
4981

5082
## API
5183

5284
### mitt
5385

5486
Mitt: Tiny (~200b) functional event emitter / pubsub.
5587

56-
Returns **Mitt**
88+
Returns **Mitt**
5789

5890
#### on
5991

@@ -82,3 +114,28 @@ If present, `"*"` handlers are invoked prior to type-matched handlers.
82114

83115
- `type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The event type to invoke
84116
- `event` **\[Any]** An event object, passed to each handler
117+
118+
## Contribute
119+
First off, thanks for taking the time to contribute!
120+
Now, take a moment to be sure your contributions make sense to everyone else.
121+
122+
### Reporting Issues
123+
Found a problem? Want a new feature? First of all see if your issue or idea has [already been reported](../../issues).
124+
If don't, just open a [new clear and descriptive issue](../../issues/new).
125+
126+
### Submitting pull requests
127+
Pull requests are the greatest contributions, so be sure they are focused in scope, and do avoid unrelated commits.
128+
129+
- Fork it!
130+
- Clone your fork: `git clone https://github.com/<your-username>/mitt`
131+
- Navigate to the newly cloned directory: `cd mitt`
132+
- Create a new branch for the new feature: `git checkout -b my-new-feature`
133+
- Install the tools necessary for development: `npm install`
134+
- Make your changes.
135+
- Commit your changes: `git commit -am 'Add some feature'`
136+
- Push to the branch: `git push origin my-new-feature`
137+
- Submit a pull request with full remarks documenting your changes.
138+
139+
## License
140+
141+
[MIT License](LICENSE.md) &copy; [Jason Miller](https://jasonformat.com/)

package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mitt",
33
"amdName": "mitt",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"description": "Tiny ~200b functional event emitter / pubsub.",
66
"jsnext:main": "src/index.js",
77
"main": "dist/mitt.js",
@@ -24,7 +24,7 @@
2424
"eventemitter",
2525
"pubsub"
2626
],
27-
"homepage": "httsp://github.com/developit/mitt",
27+
"homepage": "https://github.com/developit/mitt",
2828
"authors": [
2929
"Jason Miller <[email protected]>"
3030
],
@@ -33,12 +33,6 @@
3333
"src",
3434
"dist"
3535
],
36-
"babel": {
37-
"presets": [
38-
"es2015",
39-
"stage-0"
40-
]
41-
},
4236
"eslintConfig": {
4337
"parser": "babel-eslint",
4438
"extends": "eslint:recommended",

0 commit comments

Comments
 (0)