Skip to content

Commit 05f4ce6

Browse files
committed
apply prettier formatting to all files
1 parent 3f81679 commit 05f4ce6

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

src/index.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export type WildcardHandler<T = Record<string, unknown>> = (
1010

1111
// An array of all currently registered event handlers for a type
1212
export type EventHandlerList<T = unknown> = Array<Handler<T>>;
13-
export type WildCardEventHandlerList<T = Record<string, unknown>> = Array<WildcardHandler<T>>;
13+
export type WildCardEventHandlerList<T = Record<string, unknown>> = Array<
14+
WildcardHandler<T>
15+
>;
1416

1517
// A map of event types and their corresponding event handlers.
1618
export type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<
@@ -24,11 +26,16 @@ export interface Emitter<Events extends Record<EventType, unknown>> {
2426
on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;
2527
on(type: '*', handler: WildcardHandler<Events>): void;
2628

27-
off<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void;
29+
off<Key extends keyof Events>(
30+
type: Key,
31+
handler?: Handler<Events[Key]>
32+
): void;
2833
off(type: '*', handler: WildcardHandler<Events>): void;
2934

3035
emit<Key extends keyof Events>(type: Key, event: Events[Key]): void;
31-
emit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;
36+
emit<Key extends keyof Events>(
37+
type: undefined extends Events[Key] ? Key : never
38+
): void;
3239
}
3340

3441
/**
@@ -45,7 +52,6 @@ export default function mitt<Events extends Record<EventType, unknown>>(
4552
all = all || new Map();
4653

4754
return {
48-
4955
/**
5056
* A Map of event names to registered handler functions.
5157
*/
@@ -61,8 +67,7 @@ export default function mitt<Events extends Record<EventType, unknown>>(
6167
const handlers: Array<GenericEventHandler> | undefined = all!.get(type);
6268
if (handlers) {
6369
handlers.push(handler);
64-
}
65-
else {
70+
} else {
6671
all!.set(type, [handler] as EventHandlerList<Events[keyof Events]>);
6772
}
6873
},
@@ -79,8 +84,7 @@ export default function mitt<Events extends Record<EventType, unknown>>(
7984
if (handlers) {
8085
if (handler) {
8186
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
82-
}
83-
else {
87+
} else {
8488
all!.set(type, []);
8589
}
8690
}

test/index_test.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,13 @@ describe('mitt#', () => {
4444

4545
describe('properties', () => {
4646
it('should expose the event handler map', () => {
47-
expect(inst)
48-
.to.have.property('all')
49-
.that.is.a('map');
47+
expect(inst).to.have.property('all').that.is.a('map');
5048
});
5149
});
5250

5351
describe('on()', () => {
5452
it('should be a function', () => {
55-
expect(inst)
56-
.to.have.property('on')
57-
.that.is.a('function');
53+
expect(inst).to.have.property('on').that.is.a('function');
5854
});
5955

6056
it('should register handler for new type', () => {
@@ -111,9 +107,7 @@ describe('mitt#', () => {
111107

112108
describe('off()', () => {
113109
it('should be a function', () => {
114-
expect(inst)
115-
.to.have.property('off')
116-
.that.is.a('function');
110+
expect(inst).to.have.property('off').that.is.a('function');
117111
});
118112

119113
it('should remove handler for type', () => {
@@ -165,9 +159,7 @@ describe('mitt#', () => {
165159

166160
describe('emit()', () => {
167161
it('should be a function', () => {
168-
expect(inst)
169-
.to.have.property('emit')
170-
.that.is.a('function');
162+
expect(inst).to.have.property('emit').that.is.a('function');
171163
});
172164

173165
it('should invoke handler for type', () => {

0 commit comments

Comments
 (0)