source: trip-planner-front/node_modules/zone.js/dist/task-tracking.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.4 KB
Line 
1'use strict';
2/**
3 * @license Angular v12.0.0-next.0
4 * (c) 2010-2020 Google LLC. https://angular.io/
5 * License: MIT
6 */
7(function (factory) {
8 typeof define === 'function' && define.amd ? define(factory) :
9 factory();
10}((function () {
11 'use strict';
12 /**
13 * @license
14 * Copyright Google LLC All Rights Reserved.
15 *
16 * Use of this source code is governed by an MIT-style license that can be
17 * found in the LICENSE file at https://angular.io/license
18 */
19 /**
20 * A `TaskTrackingZoneSpec` allows one to track all outstanding Tasks.
21 *
22 * This is useful in tests. For example to see which tasks are preventing a test from completing
23 * or an automated way of releasing all of the event listeners at the end of the test.
24 */
25 var TaskTrackingZoneSpec = /** @class */ (function () {
26 function TaskTrackingZoneSpec() {
27 this.name = 'TaskTrackingZone';
28 this.microTasks = [];
29 this.macroTasks = [];
30 this.eventTasks = [];
31 this.properties = { 'TaskTrackingZone': this };
32 }
33 TaskTrackingZoneSpec.get = function () {
34 return Zone.current.get('TaskTrackingZone');
35 };
36 TaskTrackingZoneSpec.prototype.getTasksFor = function (type) {
37 switch (type) {
38 case 'microTask':
39 return this.microTasks;
40 case 'macroTask':
41 return this.macroTasks;
42 case 'eventTask':
43 return this.eventTasks;
44 }
45 throw new Error('Unknown task format: ' + type);
46 };
47 TaskTrackingZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) {
48 task['creationLocation'] = new Error("Task '" + task.type + "' from '" + task.source + "'.");
49 var tasks = this.getTasksFor(task.type);
50 tasks.push(task);
51 return parentZoneDelegate.scheduleTask(targetZone, task);
52 };
53 TaskTrackingZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) {
54 var tasks = this.getTasksFor(task.type);
55 for (var i = 0; i < tasks.length; i++) {
56 if (tasks[i] == task) {
57 tasks.splice(i, 1);
58 break;
59 }
60 }
61 return parentZoneDelegate.cancelTask(targetZone, task);
62 };
63 TaskTrackingZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) {
64 if (task.type === 'eventTask')
65 return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs);
66 var tasks = this.getTasksFor(task.type);
67 for (var i = 0; i < tasks.length; i++) {
68 if (tasks[i] == task) {
69 tasks.splice(i, 1);
70 break;
71 }
72 }
73 return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs);
74 };
75 TaskTrackingZoneSpec.prototype.clearEvents = function () {
76 while (this.eventTasks.length) {
77 Zone.current.cancelTask(this.eventTasks[0]);
78 }
79 };
80 return TaskTrackingZoneSpec;
81 }());
82 // Export the class so that new instances can be created with proper
83 // constructor params.
84 Zone['TaskTrackingZoneSpec'] = TaskTrackingZoneSpec;
85})));
Note: See TracBrowser for help on using the repository browser.