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

C2FO / fast-csv / 12025003900

26 Nov 2024 06:20AM CUT coverage: 95.889%. Remained the same
12025003900

push

github

web-flow
chore(deps): update dependency @types/node to v22.10.0 (#1067)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

321 of 349 branches covered (91.98%)

Branch coverage included in aggregate %.

752 of 770 relevant lines covered (97.66%)

2179022.73 hits per line

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

94.74
/packages/format/src/FormatterOptions.ts
1
import { Row, RowTransformFunction } from './types';
2

3
interface QuoteColumnMap {
4
    [s: string]: boolean;
5
}
6

7
type QuoteColumns = boolean | boolean[] | QuoteColumnMap;
8

9
export interface FormatterOptionsArgs<I extends Row, O extends Row> {
10
    objectMode?: boolean;
11
    delimiter?: string;
12
    rowDelimiter?: string;
13
    quote?: string | boolean;
14
    escape?: string;
15
    quoteColumns?: QuoteColumns;
16
    quoteHeaders?: QuoteColumns;
17
    headers?: null | boolean | string[];
18
    writeHeaders?: boolean;
19
    includeEndRowDelimiter?: boolean;
20
    writeBOM?: boolean;
21
    transform?: RowTransformFunction<I, O>;
22
    alwaysWriteHeaders?: boolean;
23
}
24

25
export class FormatterOptions<I extends Row, O extends Row> {
66✔
26
    public readonly objectMode: boolean = true;
1,398✔
27

28
    public readonly delimiter: string = ',';
1,398✔
29

30
    public readonly rowDelimiter: string = '\n';
1,398✔
31

32
    public readonly quote: string = '"';
1,398✔
33

34
    public readonly escape: string = this.quote;
1,398✔
35

36
    public readonly quoteColumns: QuoteColumns = false;
1,398✔
37

38
    public readonly quoteHeaders: QuoteColumns = this.quoteColumns;
1,398✔
39

40
    public readonly headers: null | string[] = null;
1,398✔
41

42
    public readonly includeEndRowDelimiter: boolean = false;
1,398✔
43

44
    public readonly transform?: RowTransformFunction<I, O>;
45

46
    public readonly shouldWriteHeaders: boolean;
47

48
    public readonly writeBOM: boolean = false;
1,398✔
49

50
    public readonly escapedQuote: string;
51

52
    public readonly BOM: string = '\ufeff';
1,398✔
53

54
    public readonly alwaysWriteHeaders: boolean = false;
1,398✔
55

56
    public constructor(opts: FormatterOptionsArgs<I, O> = {}) {
×
57
        Object.assign(this, opts || {});
1,398!
58

59
        if (typeof opts?.quoteHeaders === 'undefined') {
1,398✔
60
            this.quoteHeaders = this.quoteColumns;
1,236✔
61
        }
62
        if (opts?.quote === true) {
1,398✔
63
            this.quote = '"';
6✔
64
        } else if (opts?.quote === false) {
1,392✔
65
            this.quote = '';
24✔
66
        }
67
        if (typeof opts?.escape !== 'string') {
1,398✔
68
            this.escape = this.quote;
1,392✔
69
        }
70
        this.shouldWriteHeaders = !!this.headers && (opts.writeHeaders ?? true);
1,398✔
71
        this.headers = Array.isArray(this.headers) ? this.headers : null;
1,398✔
72
        this.escapedQuote = `${this.escape}${this.quote}`;
1,398✔
73
    }
74
}
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