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

fb55 / htmlparser2 / 11292752892

11 Oct 2024 12:56PM CUT coverage: 99.264%. First build
11292752892

Pull #1932

github

web-flow
Merge 8a0342b61 into 37726f15e
Pull Request #1932: build(deps): Bump coverallsapp/github-action from 2.3.0 to 2.3.1

339 of 344 branches covered (98.55%)

1214 of 1223 relevant lines covered (99.26%)

1044.92 hits per line

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

100.0
/src/WritableStream.ts
1
import { Parser, type Handler, type ParserOptions } from "./Parser.js";
1✔
2
/*
3
 * NOTE: If either of these two imports produces a type error,
4
 * please update your @types/node dependency!
5
 */
6
import { Writable } from "node:stream";
1✔
7
import { StringDecoder } from "node:string_decoder";
1✔
8

9
// Following the example in https://nodejs.org/api/stream.html#stream_decoding_buffers_in_a_writable_stream
10
function isBuffer(_chunk: string | Buffer, encoding: string): _chunk is Buffer {
15✔
11
    return encoding === "buffer";
15✔
12
}
15✔
13

14
/**
15
 * WritableStream makes the `Parser` interface available as a NodeJS stream.
16
 *
17
 * @see Parser
18
 */
19
export class WritableStream extends Writable {
1✔
20
    private readonly _parser: Parser;
21
    private readonly _decoder = new StringDecoder();
1✔
22

23
    constructor(cbs: Partial<Handler>, options?: ParserOptions) {
1✔
24
        super({ decodeStrings: false });
13✔
25
        this._parser = new Parser(cbs, options);
13✔
26
    }
13✔
27

28
    override _write(
1✔
29
        chunk: string | Buffer,
15✔
30
        encoding: string,
15✔
31
        callback: () => void,
15✔
32
    ): void {
15✔
33
        this._parser.write(
15✔
34
            isBuffer(chunk, encoding) ? this._decoder.write(chunk) : chunk,
15✔
35
        );
15✔
36
        callback();
15✔
37
    }
15✔
38

39
    override _final(callback: () => void): void {
1✔
40
        this._parser.end(this._decoder.end());
13✔
41
        callback();
13✔
42
    }
13✔
43
}
1✔
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