@angular-wave/angular.ts 0.0.67 → 0.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@angular-wave/angular.ts",
3
3
  "description": "A modern, optimized and typesafe version of AngularJS",
4
4
  "license": "MIT",
5
- "version": "0.0.67",
5
+ "version": "0.0.68",
6
6
  "type": "module",
7
7
  "main": "dist/angular-ts.esm.js",
8
8
  "browser": "dist/angular-ts.umd.js",
@@ -6,7 +6,14 @@ export function $$IntervalFactoryProvider() {
6
6
  "$q",
7
7
  "$$q",
8
8
  "$rootScope",
9
- // TODO Add types
9
+ /**
10
+ *
11
+ * @param {import('../../services/browser').Browser} $browser
12
+ * @param {*} $q
13
+ * @param {*} $$q
14
+ * @param {import('../scope/scope').Scope} $rootScope
15
+ * @returns
16
+ */
10
17
  function ($browser, $q, $$q, $rootScope) {
11
18
  return function intervalFactory(setIntervalFn, clearIntervalFn) {
12
19
  return function intervalFn(fn, delay, count, invokeApply) {
@@ -3,32 +3,47 @@ import { minErr } from "../../shared/utils";
3
3
 
4
4
  const $intervalMinErr = minErr("$interval");
5
5
 
6
+ /**
7
+ * @typedef {number} IntervalId
8
+ * Interval ID which uniquely identifies the interval and can be used to cancel it
9
+ */
10
+
11
+ /**
12
+ * @type {Map<IntervalId, import("../q/q").Deferred<any>>}
13
+ */
14
+ const intervals = new Map();
15
+
6
16
  export function $IntervalProvider() {
7
17
  this.$get = [
8
18
  "$$intervalFactory",
9
19
  // TODO Add type
10
20
  function ($$intervalFactory) {
11
- const intervals = {};
12
- const setIntervalFn = function (tick, delay, deferred) {
21
+ /**
22
+ * @param {TimerHandler} tick
23
+ * @param {number} delay
24
+ * @param {import("../q/q").Deferred<any>} deferred
25
+ * @returns {IntervalId} - This method returns an interval ID which uniquely identifies the interval
26
+ */
27
+ function setIntervalFn(tick, delay, deferred) {
13
28
  const id = window.setInterval(tick, delay);
14
- intervals[id] = deferred;
29
+ intervals.set(id, deferred);
15
30
  return id;
16
- };
17
- const clearIntervalFn = function (id) {
31
+ }
32
+
33
+ /**s
34
+ * @param {IntervalId} id
35
+ */
36
+ function clearIntervalFn(id) {
18
37
  window.clearInterval(id);
19
- delete intervals[id];
20
- };
38
+ intervals.delete(id);
39
+ }
21
40
 
22
41
  const interval = $$intervalFactory(setIntervalFn, clearIntervalFn);
23
42
 
24
43
  /**
25
- * @ngdoc method
26
- * @name $interval#cancel
27
- *
28
- * @description
29
44
  * Cancels a task associated with the `promise`.
30
45
  *
31
- * @param {Promise=} promise returned by the `$interval` function.
46
+ * @param {!import("../q/q").QPromise<any>} promise returned by the `$interval` function.
32
47
  * @returns {boolean} Returns `true` if the task was successfully canceled.
33
48
  */
34
49
  interval.cancel = function (promise) {
@@ -41,13 +56,12 @@ export function $IntervalProvider() {
41
56
  );
42
57
  }
43
58
 
44
- if (
45
- !Object.prototype.hasOwnProperty.call(intervals, promise.$$intervalId)
46
- )
59
+ if (!intervals.has(promise.$$intervalId)) {
47
60
  return false;
61
+ }
48
62
 
49
63
  const id = promise.$$intervalId;
50
- const deferred = intervals[id];
64
+ const deferred = intervals.get(id);
51
65
 
52
66
  // Interval cancels should not report an unhandled promise.
53
67
  markQExceptionHandled(deferred.promise);