aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--src/index.js9
-rw-r--r--test/index.js16
3 files changed, 9 insertions, 19 deletions
diff --git a/README.md b/README.md
index da9e627..9527ca5 100644
--- a/README.md
+++ b/README.md
@@ -68,8 +68,7 @@ If present, `"*"` handlers are invoked prior to type-matched handlers.
**Parameters**
- `type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The event type to invoke
-- `arg1` **\[Any]** A value (first argument), passed to each handler
-- `arg2` **\[Any]** A value (second argument), passed to each handler
+- `evt` **\[Any]** Any value (object is recommended and powerful), passed to each handler
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** the `mitt` instance for chaining
diff --git a/src/index.js b/src/index.js
index a67efb2..c4147c1 100644
--- a/src/index.js
+++ b/src/index.js
@@ -39,14 +39,13 @@ export default function mitt () {
* If present, `"*"` handlers are invoked prior to type-matched handlers.
*
* @param {String} type The event type to invoke
- * @param {Any} [arg1] A value (first argument), passed to each handler
- * @param {Any} [arg2] A value (second argument), passed to each handler
+ * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
* @return {Object} the `mitt` instance for chaining
* @memberof mitt
*/
- emit(type, arg1, arg2) {
- (all[type] || []).map((handler) => { handler(arg1, arg2); });
- (all['*'] || []).map((handler) => { handler(type, arg1, arg2); });
+ emit(type, evt) {
+ (all[type] || []).map((handler) => { handler(evt); });
+ (all['*'] || []).map((handler) => { handler(type, evt); });
return ret;
}
};
diff --git a/test/index.js b/test/index.js
index f552392..7c5c429 100644
--- a/test/index.js
+++ b/test/index.js
@@ -111,14 +111,6 @@ describe('mitt#', () => {
inst.emit('foo', event);
});
- it('should invoke handler with multiple (max 2) arguments', () => {
- inst.on('foo', (aaa, bbb) => {
- expect(aaa).to.be.equal(111);
- expect(bbb).to.be.equal(222);
- });
- inst.emit('foo', 111, 222);
- });
-
it('should NOT ignore case', () => {
let foo = spy(),
bar = spy(),
@@ -134,8 +126,8 @@ describe('mitt#', () => {
expect(foo).to.have.been.calledOnce;
expect(bar).to.have.been.calledOnce;
- expect(args1).to.be.deep.equal([num, undefined]);
- expect(args2).to.be.deep.equal([num, undefined]);
+ expect(args1).to.be.deep.equal([num]);
+ expect(args2).to.be.deep.equal([num]);
});
it('should invoke * handlers', () => {
@@ -150,8 +142,8 @@ describe('mitt#', () => {
args2 = star.args[1];
expect(star).to.have.been.calledTwice;
- expect(args1).to.deep.equal(['foo', aa, undefined]);
- expect(args2).to.deep.equal(['bar', aa, undefined]);
+ expect(args1).to.deep.equal(['foo', aa]);
+ expect(args2).to.deep.equal(['bar', aa]);
});
});
});