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

IgniteUI / igniteui-angular / 12300330513

12 Dec 2024 04:10PM CUT coverage: 91.592% (-0.03%) from 91.621%
12300330513

push

github

web-flow
Merge pull request #15120 from IgniteUI/19.0.x

Mass Merge 19.0.x to master

12984 of 15225 branches covered (85.28%)

86 of 106 new or added lines in 16 files covered. (81.13%)

12 existing lines in 3 files now uncovered.

26320 of 28736 relevant lines covered (91.59%)

34007.75 hits per line

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

56.25
/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[]) {
6
        const length = data.length;
59✔
7
        if (length === 0) {
59✔
8
            return [];
8✔
9
        }
10

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

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

19
        const keys = new Set(keys1.concat(keys2).concat(keys3));
51✔
20

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

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

30
        a.href = url;
×
NEW
31
        doc.body.appendChild(a);
×
32
        a.click();
×
NEW
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 {
47
        return (typeof data === 'string' ||
466✔
48
            typeof data === 'number' ||
49
            data instanceof Date);
50
    }
51

52
    public static hasValue(value: any): boolean {
53
        return value !== undefined && value !== null;
7,446✔
54
    }
55

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

60
    public static sanitizeValue(value: any): string {
61
        if (!this.hasValue(value)) {
5,803✔
62
            return '';
168✔
63
        } else {
64
            const stringValue = String(value);
5,635✔
65
            return stringValue.replace(/&/g, '&')
5,635✔
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