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

microsoft / botbuilder-js / 11579379955

29 Oct 2024 05:34PM UTC coverage: 84.703% (-0.5%) from 85.23%
11579379955

push

github

web-flow
refactor: [#4684] Replace browserify with tsup (#4774)

* Replace browserify with tsup in adaptive-expressions

* Remove remaining browserify packages

* Fix streaming tests

* Fix yarn.lock

* fix depcheck

8186 of 10820 branches covered (75.66%)

Branch coverage included in aggregate %.

2 of 2 new or added lines in 1 file covered. (100.0%)

23 existing lines in 13 files now uncovered.

20514 of 23063 relevant lines covered (88.95%)

7296.87 hits per line

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

87.5
/libraries/botframework-streaming/src/disassemblers/payloadDisassembler.ts
1
/**
8✔
2
 * @module botframework-streaming
3
 */
4
/**
5
 * Copyright (c) Microsoft Corporation. All rights reserved.
6
 * Licensed under the MIT License.
7
 */
8
import { PayloadTypes } from '../payloads';
9
import { PayloadSender } from '../payloadTransport';
10
import { SubscribableStream } from '../subscribableStream';
2✔
11
import { IStreamWrapper } from '../interfaces';
12

13
/**
14
 * Base class streaming payload disassembling.
15
 */
16
export abstract class PayloadDisassembler {
2✔
17
    abstract payloadType: PayloadTypes;
18
    private stream: SubscribableStream;
19
    private streamLength?: number;
20

21
    /**
22
     * Initializes a new instance of the [PayloadDisassembler](xref:botframework-streaming.PayloadDisassembler) class.
23
     *
24
     * @param sender The [PayloadSender](xref:botframework-streaming.PayloadSender) used to send the disassembled payload chunks.
25
     * @param id The ID of this disassembler.
26
     */
27
    constructor(private readonly sender: PayloadSender, private readonly id: string) {}
74✔
28

29
    /**
30
     * Serializes the item into the [IStreamWrapper](xref:botframework-streaming.IStreamWrapper) that exposes the stream and length of the result.
31
     *
32
     * @param item The item to be serialized.
33
     * @returns The stream containing the serialized item and the length of the stream.
34
     */
35
    protected static serialize<T>(item: T): IStreamWrapper {
36
        const stream: SubscribableStream = new SubscribableStream();
38✔
37

38
        stream.write(JSON.stringify(item));
38✔
39
        stream.end();
38✔
40

41
        return { stream, streamLength: stream.length };
38✔
42
    }
43

44
    /**
45
     * Gets the stream this disassembler is operating on.
46
     *
47
     * @returns An [IStreamWrapper](xref:botframework-streaming.IStreamWrapper) with a Subscribable Stream.
48
     */
49
    abstract getStream(): Promise<IStreamWrapper>;
50

51
    /**
52
     * Begins the process of disassembling a payload and sending the resulting chunks to the [PayloadSender](xref:botframework-streaming.PayloadSender) to dispatch over the transport.
53
     *
54
     * @returns A completed Promise after the disassembled payload has been sent.
55
     */
UNCOV
56
    async disassemble(): Promise<void> {
×
57
        const { stream, streamLength } = await this.getStream();
72✔
58

59
        this.stream = stream;
72✔
60
        this.streamLength = streamLength;
72✔
61

62
        return this.send();
72✔
63
    }
64

65
    /**
66
     * Begins the process of disassembling a payload and signals the [PayloadSender](xref:botframework-streaming.PayloadSender).
67
     */
UNCOV
68
    private async send(): Promise<void> {
×
69
        const header = {
72✔
70
            payloadType: this.payloadType,
71
            payloadLength: this.streamLength,
72
            id: this.id,
73
            end: true,
74
        };
75
        this.sender.sendPayload(header, this.stream);
72✔
76
    }
77
}
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

© 2025 Coveralls, Inc