push
travis-ci
1401 of 2206 branches covered (63.51%)
2390 of 2595 relevant lines covered (92.1%)
16180.92 hits per line
1 |
/**
|
|
2 |
* Message |
|
3 |
* |
|
4 |
* @param {String|Message|MessageEvent} event message event name or Message or MessageEvent |
|
5 |
* @param {Object} body message contents |
|
6 |
*/ |
|
7 |
|
|
8 |
export class Message { |
|
9 |
constructor (event, body = {}) { |
|
10 |
if (event instanceof Message) return event; |
|
11 |
if (event instanceof window.MessageEvent) { |
|
12 |
body = event.data.body; |
|
13 |
event = event.data.event; |
|
14 |
} |
|
15 |
this.event = event;
|
1✔ |
16 |
this.body = body;
|
|
17 |
} |
|
18 |
|
|
19 |
format () { |
2,110,922✔ |
20 |
return {
|
|
21 |
event: this.event, |
|
22 |
body: this.body |
|
23 |
} |
|
24 |
} |
1,000,562✔ |
25 |
} |
1,000,562✔ |