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

IgniteUI / igniteui-angular / 13331632524

14 Feb 2025 02:51PM CUT coverage: 22.015% (-69.6%) from 91.622%
13331632524

Pull #15372

github

web-flow
Merge d52d57714 into bcb78ae0a
Pull Request #15372: chore(*): test ci passing

1990 of 15592 branches covered (12.76%)

431 of 964 new or added lines in 18 files covered. (44.71%)

19956 existing lines in 307 files now uncovered.

6452 of 29307 relevant lines covered (22.02%)

249.17 hits per line

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

0.0
/projects/igniteui-angular/src/lib/services/exporter-common/export-utilities.ts
1
/**
2
 * @hidden
3
 */
4
export class ExportUtilities {
5
    public static getKeysFromData(data: any[]) {
UNCOV
6
        const length = data.length;
×
UNCOV
7
        if (length === 0) {
×
UNCOV
8
            return [];
×
9
        }
10

UNCOV
11
        const dataEntry = data[0];
×
UNCOV
12
        const dataEntryMiddle = data[Math.floor(length / 2)];
×
UNCOV
13
        const dataEntryLast = data[length - 1];
×
14

UNCOV
15
        const keys1 = Object.keys(dataEntry);
×
UNCOV
16
        const keys2 = Object.keys(dataEntryMiddle);
×
UNCOV
17
        const keys3 = Object.keys(dataEntryLast);
×
18

UNCOV
19
        const keys = new Set(keys1.concat(keys2).concat(keys3));
×
20

UNCOV
21
        return !ExportUtilities.isSpecialData(dataEntry) ? Array.from(keys) : ['Column 1'];
×
22
    }
23

24
    public static saveBlobToFile(blob: Blob, fileName) {
25
        const doc = globalThis.document;
×
26
        const a = doc.createElement('a');
×
27
        const url = window.URL.createObjectURL(blob);
×
28
        a.download = fileName;
×
29

30
        a.href = url;
×
31
        doc.body.appendChild(a);
×
32
        a.click();
×
33
        doc.body.removeChild(a);
×
34
        window.URL.revokeObjectURL(url);
×
35
    }
36

37
    public static stringToArrayBuffer(s: string): ArrayBuffer {
38
        const buf = new ArrayBuffer(s.length);
×
39
        const view = new Uint8Array(buf);
×
40
        for (let i = 0; i !== s.length; ++i) {
×
41
            view[i] = s.charCodeAt(i) & 0xFF;
×
42
        }
43
        return buf;
×
44
    }
45

46
    public static isSpecialData(data: any): boolean {
UNCOV
47
        return (typeof data === 'string' ||
×
48
            typeof data === 'number' ||
49
            data instanceof Date);
50
    }
51

52
    public static hasValue(value: any): boolean {
UNCOV
53
        return value !== undefined && value !== null;
×
54
    }
55

56
    public static isNullOrWhitespaces(value: string): boolean {
UNCOV
57
        return value === undefined || value === null || !value.trim();
×
58
    }
59

60
    public static sanitizeValue(value: any): string {
UNCOV
61
        if (!this.hasValue(value)) {
×
UNCOV
62
            return '';
×
63
        } else {
UNCOV
64
            const stringValue = String(value);
×
UNCOV
65
            return stringValue.replace(/&/g, '&')
×
66
                              .replace(/</g, '&lt;')
67
                              .replace(/>/g, '&gt;')
68
                              .replace(/"/g, '&quot;')
69
                              .replace(/'/g, '&apos;')
70
                              // Bug #14944 - Remove the not supported null character (\u0000, \x00)
71
                              .replace(/\x00/g, '');
72
        }
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