• 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

22.73
/projects/igniteui-angular/src/lib/core/setImmediate.ts
1
/* Copyright (c) 2014-2020 Denis Pushkarev
2
 *
3
 * Permission is hereby granted, free of charge, to any person obtaining a copy
4
 * of this software and associated documentation files (the "Software"), to deal
5
 * in the Software without restriction, including without limitation the rights
6
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
 * copies of the Software, and to permit persons to whom the Software is
8
 * furnished to do so, subject to the following conditions:
9
 *
10
 * The above copyright notice and this permission notice shall be included in
11
 * all copies or substantial portions of the Software.
12
 *
13
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
 * THE SOFTWARE
20
 */
21

22
// Note: Originally copied from core-js-pure package and modified. (https://github.com/zloirock/core-js)
23

24
const queue = {};
2✔
25
let counter = 0;
2✔
26
let eventListenerAdded = false;
2✔
27

28
declare global {
29
    interface Window {
30
        setImmediate: any;
31
        clearImmediate: any;
32
    }
33
}
34

35
const run = (id) => {
2✔
UNCOV
36
    if (queue.hasOwnProperty(id)) {
×
UNCOV
37
        const fn = queue[id];
×
UNCOV
38
        delete queue[id];
×
UNCOV
39
        fn();
×
40
    }
41
};
42

43
const listener = (event) => run(event.data);
2✔
44

45
// Use function instead of arrow function to workaround an issue in codesandbox
46
export function setImmediate(cb: () => void, ...args) {
UNCOV
47
    if (window.setImmediate) {
×
48
        return window.setImmediate(cb);
×
49
    }
50

UNCOV
51
    if (!eventListenerAdded) {
×
UNCOV
52
        eventListenerAdded = true;
×
UNCOV
53
        window.addEventListener('message', listener, false);
×
54
    }
55

UNCOV
56
    queue[++counter] = () => {
×
UNCOV
57
        cb.apply(undefined, args);
×
58
    };
59

UNCOV
60
    const windowLocation = window.location;
×
UNCOV
61
    window.postMessage(counter + '', windowLocation.protocol + '//' + windowLocation.host);
×
62

UNCOV
63
    return counter;
×
64
}
65

66
export function clearImmediate(id: any) {
67
    if (window.clearImmediate) {
×
68
        return window.clearImmediate(id);
×
69
    }
70

71
    delete queue[id];
×
72
}
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