• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

streetsidesoftware / cspell / 21266375958

22 Jan 2026 09:58PM UTC coverage: 92.828% (+0.003%) from 92.825%
21266375958

Pull #8423

github

web-flow
Merge 56ea18baa into 278340a00
Pull Request #8423: fix: Add NotifyEmitter

8864 of 10610 branches covered (83.54%)

34 of 36 new or added lines in 2 files covered. (94.44%)

4 existing lines in 2 files now uncovered.

17706 of 19074 relevant lines covered (92.83%)

31559.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/packages/cspell-lib/src/rpc/MessagePortEvents.ts
1
import type { MessagePortLike } from './messagePort.js';
2
import type { NotifyEvent } from './notify.js';
3
import { NotifyEmitter } from './notify.js';
4

5
/**
6
 * Wraps a {@link MessagePortLike} and exposes its key events through a
7
 * {@link NotifyEmitter}-based interface.
8
 *
9
 * This class listens to the underlying port's {@code message},
10
 * {@code messageerror}, and {@code close} events and re-emits them as
11
 * {@link NotifyEvent} instances, making it easier to subscribe to and manage
12
 * notifications from a message port.
13
 */
14
export class MessagePortEvents {
15
    #notifyMessage: NotifyEmitter<unknown> = new NotifyEmitter();
1✔
16
    #notifyClose: NotifyEmitter<Event> = new NotifyEmitter();
1✔
17
    #notifyMessageError: NotifyEmitter<Error> = new NotifyEmitter();
1✔
18
    #port: MessagePortLike;
19

20
    constructor(port: MessagePortLike) {
21
        this.#port = port;
1✔
22
        this.#port.addListener('message', this.#notifyMessage.notify);
1✔
23
        this.#port.addListener('messageerror', this.#notifyMessageError.notify);
1✔
24
        this.#port.addListener('close', this.#notifyClose.notify);
1✔
25
    }
26

27
    [Symbol.dispose](): void {
28
        this.#port.removeListener('message', this.#notifyMessage.notify);
1✔
29
        this.#port.removeListener('messageerror', this.#notifyMessageError.notify);
1✔
30
        this.#port.removeListener('close', this.#notifyClose.notify);
1✔
31
        this.#notifyMessage[Symbol.dispose]();
1✔
32
        this.#notifyClose[Symbol.dispose]();
1✔
33
        this.#notifyMessageError[Symbol.dispose]();
1✔
34
    }
35

36
    /**
37
     * Event fired when a message is received.
38
     */
39
    get event(): NotifyEvent<unknown> {
40
        return this.#notifyMessage.event;
7✔
41
    }
42

43
    /**
44
     * Event fired when the port is closed.
45
     */
46
    get eventClose(): NotifyEvent<Event> {
NEW
47
        return this.#notifyClose.event;
×
48
    }
49

50
    /**
51
     * Event fired when a message error is received.
52
     */
53
    get eventMessageError(): NotifyEvent<Error> {
NEW
54
        return this.#notifyMessageError.event;
×
55
    }
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc