@angular-wave/angular.ts 0.0.60 → 0.0.62

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.
Files changed (128) hide show
  1. package/README.md +1 -1
  2. package/dist/angular-ts.esm.js +2 -2
  3. package/dist/angular-ts.umd.js +2 -2
  4. package/package.json +2 -1
  5. package/src/angular.spec.js +2 -2
  6. package/src/core/parser/parse.js +14 -0
  7. package/src/core/parser/parse.spec.js +7 -5
  8. package/src/core/parser/parser.js +1 -1
  9. package/src/core/q/q.js +46 -289
  10. package/src/core/q/q.md +229 -0
  11. package/src/core/sanitize/sanitize-uri.js +2 -3
  12. package/src/core/scope/scope.js +18 -8
  13. package/src/directive/if/if.js +6 -1
  14. package/src/filters/limit-to.js +5 -2
  15. package/src/filters/order-by.js +1 -2
  16. package/src/index.js +1 -1
  17. package/src/loader.js +1 -55
  18. package/src/router/params/param-type.js +2 -1
  19. package/src/router/state/views.js +3 -0
  20. package/src/router/state-provider.js +1 -1
  21. package/src/router/transition/reject-factory.js +1 -0
  22. package/src/router/url/url-rule.js +1 -1
  23. package/src/router/url/url-service.js +4 -4
  24. package/src/router/url/url-service.spec.js +4 -3
  25. package/src/services/http/http.js +7 -5
  26. package/src/services/template-request.js +2 -7
  27. package/src/shared/common.js +1 -1
  28. package/src/shared/utils.js +2 -11
  29. package/src/types.js +9 -1
  30. package/types/core/parser/parse.d.ts +3 -4
  31. package/types/core/parser/parser.d.ts +1 -1
  32. package/types/core/q/q.d.ts +2 -2
  33. package/types/core/sanitize/sanitize-uri.d.ts +4 -5
  34. package/types/core/scope/scope.d.ts +19 -7
  35. package/types/index.d.ts +5 -1
  36. package/types/loader.d.ts +0 -52
  37. package/types/router/params/param-type.d.ts +2 -1
  38. package/types/router/state/views.d.ts +2 -0
  39. package/types/router/state-provider.d.ts +1 -1
  40. package/types/router/transition/reject-factory.d.ts +1 -0
  41. package/types/router/url/url-rule.d.ts +0 -1
  42. package/types/router/url/url-service.d.ts +7 -7
  43. package/types/services/template-request.d.ts +4 -9
  44. package/types/shared/utils.d.ts +1 -7
  45. package/types/types.d.ts +6 -1
  46. package/types-back/README.md +0 -2
  47. package/types-back/angular.d.ts +0 -146
  48. package/types-back/index.d.ts +0 -2126
  49. package/types-back/jqlite.d.ts +0 -374
  50. package/types-back/router/core/common/common.d.ts +0 -416
  51. package/types-back/router/core/common/coreservices.d.ts +0 -77
  52. package/types-back/router/core/common/glob.d.ts +0 -60
  53. package/types-back/router/core/common/hof.d.ts +0 -168
  54. package/types-back/router/core/common/index.d.ts +0 -8
  55. package/types-back/router/core/common/predicates.d.ts +0 -25
  56. package/types-back/router/core/common/queue.d.ts +0 -15
  57. package/types-back/router/core/common/safeConsole.d.ts +0 -5
  58. package/types-back/router/core/common/strings.d.ts +0 -66
  59. package/types-back/router/core/common/trace.d.ts +0 -126
  60. package/types-back/router/core/globals.d.ts +0 -43
  61. package/types-back/router/core/hooks/coreResolvables.d.ts +0 -6
  62. package/types-back/router/core/hooks/ignoredTransition.d.ts +0 -4
  63. package/types-back/router/core/hooks/invalidTransition.d.ts +0 -4
  64. package/types-back/router/core/hooks/lazyLoad.d.ts +0 -17
  65. package/types-back/router/core/hooks/onEnterExitRetain.d.ts +0 -10
  66. package/types-back/router/core/hooks/redirectTo.d.ts +0 -4
  67. package/types-back/router/core/hooks/resolve.d.ts +0 -11
  68. package/types-back/router/core/hooks/updateGlobals.d.ts +0 -4
  69. package/types-back/router/core/hooks/url.d.ts +0 -4
  70. package/types-back/router/core/hooks/views.d.ts +0 -7
  71. package/types-back/router/core/index.d.ts +0 -11
  72. package/types-back/router/core/interface.d.ts +0 -91
  73. package/types-back/router/core/params/index.d.ts +0 -12
  74. package/types-back/router/core/params/interface.d.ts +0 -606
  75. package/types-back/router/core/params/param.d.ts +0 -77
  76. package/types-back/router/core/params/paramType.d.ts +0 -65
  77. package/types-back/router/core/params/paramTypes.d.ts +0 -193
  78. package/types-back/router/core/params/stateParams.d.ts +0 -15
  79. package/types-back/router/core/path/index.d.ts +0 -2
  80. package/types-back/router/core/path/pathNode.d.ts +0 -60
  81. package/types-back/router/core/path/pathUtils.d.ts +0 -105
  82. package/types-back/router/core/resolve/index.d.ts +0 -3
  83. package/types-back/router/core/resolve/interface.d.ts +0 -210
  84. package/types-back/router/core/resolve/resolvable.d.ts +0 -75
  85. package/types-back/router/core/resolve/resolveContext.d.ts +0 -97
  86. package/types-back/router/core/router.d.ts +0 -57
  87. package/types-back/router/core/state/index.d.ts +0 -28
  88. package/types-back/router/core/state/interface.d.ts +0 -732
  89. package/types-back/router/core/state/stateBuilder.d.ts +0 -107
  90. package/types-back/router/core/state/stateMatcher.d.ts +0 -13
  91. package/types-back/router/core/state/stateObject.d.ts +0 -170
  92. package/types-back/router/core/state/stateQueueManager.d.ts +0 -27
  93. package/types-back/router/core/state/stateRegistry.d.ts +0 -138
  94. package/types-back/router/core/state/stateService.d.ts +0 -386
  95. package/types-back/router/core/state/targetState.d.ts +0 -105
  96. package/types-back/router/core/transition/hookBuilder.d.ts +0 -49
  97. package/types-back/router/core/transition/hookRegistry.d.ts +0 -115
  98. package/types-back/router/core/transition/index.d.ts +0 -20
  99. package/types-back/router/core/transition/interface.d.ts +0 -862
  100. package/types-back/router/core/transition/rejectFactory.d.ts +0 -103
  101. package/types-back/router/core/transition/transition.d.ts +0 -575
  102. package/types-back/router/core/transition/transitionEventType.d.ts +0 -26
  103. package/types-back/router/core/transition/transitionHook.d.ts +0 -96
  104. package/types-back/router/core/transition/transitionService.d.ts +0 -253
  105. package/types-back/router/core/url/index.d.ts +0 -8
  106. package/types-back/router/core/url/interface.d.ts +0 -169
  107. package/types-back/router/core/url/urlConfig.d.ts +0 -144
  108. package/types-back/router/core/url/urlMatcher.d.ts +0 -185
  109. package/types-back/router/core/url/urlMatcherFactory.d.ts +0 -56
  110. package/types-back/router/core/url/urlRouter.d.ts +0 -101
  111. package/types-back/router/core/url/urlRule.d.ts +0 -143
  112. package/types-back/router/core/url/urlRules.d.ts +0 -251
  113. package/types-back/router/core/url/urlService.d.ts +0 -205
  114. package/types-back/router/core/view/index.d.ts +0 -2
  115. package/types-back/router/core/view/interface.d.ts +0 -46
  116. package/types-back/router/core/view/view.d.ts +0 -176
  117. package/types-back/router/directives/viewDirective.d.ts +0 -144
  118. package/types-back/router/index.d.ts +0 -17
  119. package/types-back/router/interface.d.ts +0 -500
  120. package/types-back/router/legacy/resolveService.d.ts +0 -47
  121. package/types-back/router/legacy/stateEvents.d.ts +0 -124
  122. package/types-back/router/services.d.ts +0 -15
  123. package/types-back/router/stateFilters.d.ts +0 -10
  124. package/types-back/router/stateProvider.d.ts +0 -258
  125. package/types-back/router/statebuilders/onEnterExitRetain.d.ts +0 -13
  126. package/types-back/router/statebuilders/views.d.ts +0 -53
  127. package/types-back/router/templateFactory.d.ts +0 -104
  128. package/types-back/router/viewScroll.d.ts +0 -9
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@angular-wave/angular.ts",
3
+ "description": "A modern, optimized and typesafe version of AngularJS",
3
4
  "license": "MIT",
4
- "version": "0.0.60",
5
+ "version": "0.0.62",
5
6
  "type": "module",
6
7
  "main": "dist/angular-ts.esm.js",
7
8
  "browser": "dist/angular-ts.umd.js",
@@ -2084,8 +2084,8 @@ describe("angular", () => {
2084
2084
  body,
2085
2085
  element,
2086
2086
  ];
2087
- angular.forEach(tests, (value, idx) => {
2088
- const result = angular.isElement(value);
2087
+ forEach(tests, (value, idx) => {
2088
+ const result = isElement(value);
2089
2089
  expect(typeof result).toEqual("boolean");
2090
2090
  expect(result).toEqual(expected[idx]);
2091
2091
  });
@@ -9,6 +9,7 @@ import { Parser } from "./parser";
9
9
  * @property {boolean} constant - Indicates if the expression is constant.
10
10
  * @property {boolean} isPure
11
11
  * @property {boolean} oneTime
12
+ * @property {function(import('../scope/scope').Scope, import('../scope/scope').WatchListener, boolean, CompiledExpression, string | ((scope: import('../scope/scope').Scope) => any)): any} $$watchDelegate
12
13
  * @property {any[]} inputs
13
14
  * @property {function(any, any): any} assign - Assigns a value to a context. If value is not provided,
14
15
  */
@@ -198,6 +199,11 @@ export function constantWatchDelegate(
198
199
  return unwatch;
199
200
  }
200
201
 
202
+ /**
203
+ *
204
+ * @param {CompiledExpression} parsedExpression
205
+ * @returns {CompiledExpression}
206
+ */
201
207
  function addWatchDelegate(parsedExpression) {
202
208
  if (parsedExpression.constant) {
203
209
  parsedExpression.$$watchDelegate = constantWatchDelegate;
@@ -210,6 +216,14 @@ function addWatchDelegate(parsedExpression) {
210
216
  return parsedExpression;
211
217
  }
212
218
 
219
+ /**
220
+ *
221
+ * @param {import('../scope/scope').Scope} scope
222
+ * @param {import('../scope/scope').WatchListener} listener
223
+ * @param {*} objectEquality
224
+ * @param {CompiledExpression} parsedExpression
225
+ * @returns
226
+ */
213
227
  function inputsWatchDelegate(
214
228
  scope,
215
229
  listener,
@@ -7,7 +7,6 @@ import {
7
7
  csp,
8
8
  valueFn,
9
9
  extend,
10
- identity,
11
10
  } from "../../shared/utils";
12
11
  import { publishExternalAPI } from "../../public";
13
12
  import { createInjector } from "../../injector";
@@ -3673,7 +3672,10 @@ describe("parser", () => {
3673
3672
  });
3674
3673
 
3675
3674
  it("should always be invoked if flagged as $stateful when wrapping one-time with inputs", () => {
3676
- filterProvider.register("identity", valueFn(identity));
3675
+ filterProvider.register(
3676
+ "identity",
3677
+ valueFn((x) => x),
3678
+ );
3677
3679
 
3678
3680
  let interceptorCalls = 0;
3679
3681
  function interceptor() {
@@ -3799,7 +3801,7 @@ describe("parser", () => {
3799
3801
 
3800
3802
  it("should not affect when a one-time binding becomes stable", () => {
3801
3803
  scope.$watch($parse("::x"));
3802
- scope.$watch($parse("::x", identity));
3804
+ scope.$watch($parse("::x", (x) => x));
3803
3805
  scope.$watch($parse("::x", () => 1)); // interceptor that returns non-undefined
3804
3806
 
3805
3807
  scope.$digest();
@@ -3812,7 +3814,7 @@ describe("parser", () => {
3812
3814
 
3813
3815
  it("should not affect when a one-time literal binding becomes stable", () => {
3814
3816
  scope.$watch($parse("::[x]"));
3815
- scope.$watch($parse("::[x]", identity));
3817
+ scope.$watch($parse("::[x]", (x) => x));
3816
3818
  scope.$watch($parse("::[x]", () => 1)); // interceptor that returns non-literal
3817
3819
 
3818
3820
  scope.$digest();
@@ -3846,7 +3848,7 @@ describe("parser", () => {
3846
3848
  scope.$watch(
3847
3849
  $parse(
3848
3850
  $parse("::{x:x, y:y}", (lit) => lit.x),
3849
- identity,
3851
+ (x) => x,
3850
3852
  ),
3851
3853
  (val) => logs.push(val),
3852
3854
  );
@@ -28,7 +28,7 @@ export class Parser {
28
28
  /**
29
29
  *
30
30
  * @param {string} exp - Expression to be parsed
31
- * @returns
31
+ * @returns {import("./parse").CompiledExpression}
32
32
  */
33
33
  parse(exp) {
34
34
  const { ast, oneTime } = this.getAst(exp);
package/src/core/q/q.js CHANGED
@@ -1,221 +1,3 @@
1
- /**
2
- * @ngdoc service
3
- * @name $q
4
- * @requires $rootScope
5
- *
6
- * @description
7
- * A service that helps you run functions asynchronously, and use their return values (or exceptions)
8
- * when they are done processing.
9
- *
10
- * This is a [Promises/A+](https://promisesaplus.com/)-compliant implementation of promises/deferred
11
- * objects inspired by [Kris Kowal's Q](https://github.com/kriskowal/q).
12
- *
13
- * $q can be used in two fashions --- one which is more similar to Kris Kowal's Q or jQuery's Deferred
14
- * implementations, and the other which resembles ES6 (ES2015) promises to some degree.
15
- *
16
- * ## $q constructor
17
- *
18
- * The streamlined ES6 style promise is essentially just using $q as a constructor which takes a `resolver`
19
- * function as the first argument. This is similar to the native Promise implementation from ES6,
20
- * see [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
21
- *
22
- * While the constructor-style use is supported, not all of the supporting methods from ES6 promises are
23
- * available yet.
24
- *
25
- * It can be used like so:
26
- *
27
- * ```js
28
- * // for the purpose of this example let's assume that variables `$q` and `okToGreet`
29
- * // are available in the current lexical scope (they could have been injected or passed in).
30
- *
31
- * function asyncGreet(name) {
32
- * // perform some asynchronous operation, resolve or reject the promise when appropriate.
33
- * return $q(function(resolve, reject) {
34
- * setTimeout(function() {
35
- * if (okToGreet(name)) {
36
- * resolve('Hello, ' + name + '!');
37
- * } else {
38
- * reject('Greeting ' + name + ' is not allowed.');
39
- * }
40
- * }, 1000);
41
- * });
42
- * }
43
- *
44
- * let promise = asyncGreet('Robin Hood');
45
- * promise.then(function(greeting) {
46
- * alert('Success: ' + greeting);
47
- * }, function(reason) {
48
- * alert('Failed: ' + reason);
49
- * });
50
- * ```
51
- *
52
- * Note: progress/notify callbacks are not currently supported via the ES6-style interface.
53
- *
54
- * Note: unlike ES6 behavior, an exception thrown in the constructor function will NOT implicitly reject the promise.
55
- *
56
- * However, the more traditional CommonJS-style usage is still available, and documented below.
57
- *
58
- * [The CommonJS Promise proposal](http://wiki.commonjs.org/wiki/Promises) describes a promise as an
59
- * interface for interacting with an object that represents the result of an action that is
60
- * performed asynchronously, and may or may not be finished at any given point in time.
61
- *
62
- * From the perspective of dealing with error handling, deferred and promise APIs are to
63
- * asynchronous programming what `try`, `catch` and `throw` keywords are to synchronous programming.
64
- *
65
- * ```js
66
- * // for the purpose of this example let's assume that variables `$q` and `okToGreet`
67
- * // are available in the current lexical scope (they could have been injected or passed in).
68
- *
69
- * function asyncGreet(name) {
70
- * let deferred = $q.defer();
71
- *
72
- * setTimeout(function() {
73
- * deferred.notify('About to greet ' + name + '.');
74
- *
75
- * if (okToGreet(name)) {
76
- * deferred.resolve('Hello, ' + name + '!');
77
- * } else {
78
- * deferred.reject('Greeting ' + name + ' is not allowed.');
79
- * }
80
- * }, 1000);
81
- *
82
- * return deferred.promise;
83
- * }
84
- *
85
- * let promise = asyncGreet('Robin Hood');
86
- * promise.then(function(greeting) {
87
- * alert('Success: ' + greeting);
88
- * }, function(reason) {
89
- * alert('Failed: ' + reason);
90
- * }, function(update) {
91
- * alert('Got notification: ' + update);
92
- * });
93
- * ```
94
- *
95
- * At first it might not be obvious why this extra complexity is worth the trouble. The payoff
96
- * comes in the way of guarantees that promise and deferred APIs make, see
97
- * https://github.com/kriskowal/uncommonjs/blob/master/promises/specification.md.
98
- *
99
- * Additionally the promise api allows for composition that is very hard to do with the
100
- * traditional callback ([CPS](http://en.wikipedia.org/wiki/Continuation-passing_style)) approach.
101
- * For more on this please see the [Q documentation](https://github.com/kriskowal/q) especially the
102
- * section on serial or parallel joining of promises.
103
- *
104
- * ## The Deferred API
105
- *
106
- * A new instance of deferred is constructed by calling `$q.defer()`.
107
- *
108
- * The purpose of the deferred object is to expose the associated Promise instance as well as APIs
109
- * that can be used for signaling the successful or unsuccessful completion, as well as the status
110
- * of the task.
111
- *
112
- * **Methods**
113
- *
114
- * - `resolve(value)` – resolves the derived promise with the `value`. If the value is a rejection
115
- * constructed via `$q.reject`, the promise will be rejected instead.
116
- * - `reject(reason)` – rejects the derived promise with the `reason`. This is equivalent to
117
- * resolving it with a rejection constructed via `$q.reject`.
118
- * - `notify(value)` - provides updates on the status of the promise's execution. This may be called
119
- * multiple times before the promise is either resolved or rejected.
120
- *
121
- * **Properties**
122
- *
123
- * - promise – `{Promise}` – promise object associated with this deferred.
124
- *
125
- *
126
- * ## The Promise API
127
- *
128
- * A new promise instance is created when a deferred instance is created and can be retrieved by
129
- * calling `deferred.promise`.
130
- *
131
- * The purpose of the promise object is to allow for interested parties to get access to the result
132
- * of the deferred task when it completes.
133
- *
134
- * **Methods**
135
- *
136
- * - `then(successCallback, [errorCallback], [notifyCallback])` – regardless of when the promise was or
137
- * will be resolved or rejected, `then` calls one of the success or error callbacks asynchronously
138
- * as soon as the result is available. The callbacks are called with a single argument: the result
139
- * or rejection reason. Additionally, the notify callback may be called zero or more times to
140
- * provide a progress indication, before the promise is resolved or rejected.
141
- *
142
- * This method *returns a new promise* which is resolved or rejected via the return value of the
143
- * `successCallback`, `errorCallback` (unless that value is a promise, in which case it is resolved
144
- * with the value which is resolved in that promise using
145
- * [promise chaining](http://www.html5rocks.com/en/tutorials/es6/promises/#toc-promises-queues)).
146
- * It also notifies via the return value of the `notifyCallback` method. The promise cannot be
147
- * resolved or rejected from the notifyCallback method. The errorCallback and notifyCallback
148
- * arguments are optional.
149
- *
150
- * - `catch(errorCallback)` – shorthand for `promise.then(null, errorCallback)`
151
- *
152
- * - `finally(callback, notifyCallback)` – allows you to observe either the fulfillment or rejection of a promise,
153
- * but to do so without modifying the final value. This is useful to release resources or do some
154
- * clean-up that needs to be done whether the promise was rejected or resolved. See the [full
155
- * specification](https://github.com/kriskowal/q/wiki/API-Reference#promisefinallycallback) for
156
- * more information.
157
- *
158
- * ## Chaining promises
159
- *
160
- * Because calling the `then` method of a promise returns a new derived promise, it is easily
161
- * possible to create a chain of promises:
162
- *
163
- * ```js
164
- * promiseB = promiseA.then(function(result) {
165
- * return result + 1;
166
- * });
167
- *
168
- * // promiseB will be resolved immediately after promiseA is resolved and its value
169
- * // will be the result of promiseA incremented by 1
170
- * ```
171
- *
172
- * It is possible to create chains of any length and since a promise can be resolved with another
173
- * promise (which will defer its resolution further), it is possible to pause/defer resolution of
174
- * the promises at any point in the chain. This makes it possible to implement powerful APIs like
175
- * $http's response interceptors.
176
- *
177
- *
178
- * ## Differences between Kris Kowal's Q and $q
179
- *
180
- * There are two main differences:
181
- *
182
- * - $q is integrated with the {@link ng.$rootScope.Scope} Scope model observation
183
- * mechanism in AngularJS, which means faster propagation of resolution or rejection into your
184
- * models and avoiding unnecessary browser repaints, which would result in flickering UI.
185
- * - Q has many more features than $q, but that comes at a cost of bytes. $q is tiny, but contains
186
- * all the important functionality needed for common async tasks.
187
- *
188
- * ## Testing
189
- *
190
- * ```js
191
- * it('should simulate promise', inject(function($q, $rootScope) {
192
- * let deferred = $q.defer();
193
- * let promise = deferred.promise;
194
- * let resolvedValue;
195
- *
196
- * promise.then(function(value) { resolvedValue = value; });
197
- * expect(resolvedValue).toBeUndefined();
198
- *
199
- * // Simulate resolving of promise
200
- * deferred.resolve(123);
201
- * // Note that the 'then' function does not get called synchronously.
202
- * // This is because we want the promise API to always be async, whether or not
203
- * // it got called synchronously or asynchronously.
204
- * expect(resolvedValue).toBeUndefined();
205
- *
206
- * // Propagate promise resolution to 'then' functions using $apply().
207
- * $rootScope.$apply();
208
- * expect(resolvedValue).toEqual(123);
209
- * }));
210
- * ```
211
- *
212
- * @param {function(function, function)} resolver Function which is responsible for resolving or
213
- * rejecting the newly created promise. The first parameter is a function which resolves the
214
- * promise, the second parameter is a function which rejects the promise.
215
- *
216
- * @returns {Promise} The newly created promise.
217
- */
218
-
219
1
  /**
220
2
  * @template T
221
3
  * @typedef {Object} angular.QPromise
@@ -246,7 +28,6 @@
246
28
  import {
247
29
  forEach,
248
30
  minErr,
249
- extend,
250
31
  isUndefined,
251
32
  isFunction,
252
33
  isObject,
@@ -295,7 +76,7 @@ export function $QProvider() {
295
76
  * This feature is enabled by default.
296
77
  *
297
78
  * @param {boolean=} value Whether to generate an error when a rejected promise is not handled.
298
- * @returns {boolean|ng.$qProvider} Current value when called without a new value or self for
79
+ * @returns {boolean|$QProvider} Current value when called without a new value or self for
299
80
  * chaining otherwise.
300
81
  */
301
82
  this.errorOnUnhandledRejections = function (value) {
@@ -306,6 +87,7 @@ export function $QProvider() {
306
87
  return errorOnUnhandledRejections;
307
88
  };
308
89
  }
90
+
309
91
  export function $$QProvider() {
310
92
  let errorOnUnhandledRejections = true;
311
93
  this.$get = [
@@ -334,8 +116,8 @@ export function $$QProvider() {
334
116
  /**
335
117
  * Constructs a promise manager.
336
118
  *
337
- * @param {function(function)} nextTick Function for executing functions in the next turn.
338
- * @param {function(...*)} exceptionHandler Function into which unexpected exceptions are passed for
119
+ * @param {function(function):any} nextTick Function for executing functions in the next turn.
120
+ * @param {function(...any):any} exceptionHandler Function into which unexpected exceptions are passed for
339
121
  * debugging purposes.
340
122
  * @param {boolean=} errorOnUnhandledRejections Whether an error should be generated on unhandled
341
123
  * promises rejections.
@@ -378,41 +160,34 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
378
160
  this.$$state = { status: 0 };
379
161
  }
380
162
 
381
- extend(QPromise.prototype, {
382
- then(onFulfilled, onRejected, progressBack) {
383
- if (
384
- isUndefined(onFulfilled) &&
385
- isUndefined(onRejected) &&
386
- isUndefined(progressBack)
387
- ) {
388
- return this;
389
- }
390
- const result = new QPromise();
391
-
392
- this.$$state.pending = this.$$state.pending || [];
393
- this.$$state.pending.push([
394
- result,
395
- onFulfilled,
396
- onRejected,
397
- progressBack,
398
- ]);
399
- if (this.$$state.status > 0) scheduleProcessQueue(this.$$state);
400
-
401
- return result;
402
- },
163
+ QPromise.prototype.then = function (onFulfilled, onRejected, progressBack) {
164
+ if (
165
+ isUndefined(onFulfilled) &&
166
+ isUndefined(onRejected) &&
167
+ isUndefined(progressBack)
168
+ ) {
169
+ return this;
170
+ }
171
+ const result = new QPromise();
403
172
 
404
- catch(callback) {
405
- return this.then(null, callback);
406
- },
173
+ this.$$state.pending = this.$$state.pending || [];
174
+ this.$$state.pending.push([result, onFulfilled, onRejected, progressBack]);
175
+ if (this.$$state.status > 0) scheduleProcessQueue(this.$$state);
407
176
 
408
- finally(callback, progressBack) {
409
- return this.then(
410
- (value) => handleCallback(value, resolve, callback),
411
- (error) => handleCallback(error, reject, callback),
412
- progressBack,
413
- );
414
- },
415
- });
177
+ return result;
178
+ };
179
+
180
+ QPromise.prototype.catch = function (callback) {
181
+ return this.then(null, callback);
182
+ };
183
+
184
+ QPromise.prototype.finally = function (callback, progressBack) {
185
+ return this.then(
186
+ (value) => handleCallback(value, resolve, callback),
187
+ (error) => handleCallback(error, reject, callback),
188
+ progressBack,
189
+ );
190
+ };
416
191
 
417
192
  function processQueue(state) {
418
193
  let fn;
@@ -569,11 +344,6 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
569
344
  }
570
345
 
571
346
  /**
572
- * @ngdoc method
573
- * @name $q#reject
574
- * @kind function
575
- *
576
- * @description
577
347
  * Creates a promise that is resolved as rejected with the specified `reason`. This api should be
578
348
  * used to forward rejection in a chain of promises. If you are dealing with the last promise in
579
349
  * a promise chain, you don't need to worry about it.
@@ -602,7 +372,7 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
602
372
  * ```
603
373
  *
604
374
  * @param {*} reason Constant, message, exception or an object representing the rejection reason.
605
- * @returns {Promise} Returns a promise that was already resolved as rejected with the `reason`.
375
+ * @returns {QPromise} Returns a promise that was already resolved as rejected with the `reason`.
606
376
  */
607
377
  function reject(reason) {
608
378
  const result = new QPromise();
@@ -624,11 +394,6 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
624
394
  }
625
395
 
626
396
  /**
627
- * @ngdoc method
628
- * @name $q#when
629
- * @kind function
630
- *
631
- * @description
632
397
  * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise.
633
398
  * This is useful when you are dealing with an object that might or might not be a promise, or if
634
399
  * the promise comes from a source that can't be trusted.
@@ -637,22 +402,17 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
637
402
  * @param {Function=} successCallback
638
403
  * @param {Function=} errorCallback
639
404
  * @param {Function=} progressCallback
640
- * @returns {Promise} Returns a promise of the passed value or promise
405
+ * @returns {QPromise} Returns a promise of the passed value or promise
641
406
  */
642
407
 
643
- function when(value, callback, errback, progressBack) {
408
+ function when(value, successCallback, errorCallback, progressCallback) {
644
409
  const result = new QPromise();
645
410
  resolvePromise(result, value);
646
- return result.then(callback, errback, progressBack);
411
+ return result.then(successCallback, errorCallback, progressCallback);
647
412
  }
648
413
 
649
414
  /**
650
- * @ngdoc method
651
- * @name $q#resolve
652
- * @kind function
653
- *
654
- * @description
655
- * Alias of {@link ng.$q#when when} to maintain naming consistency with ES6.
415
+ * Alias of {@link when} to maintain naming consistency with ES6.
656
416
  *
657
417
  * @param {*} value Value or a promise
658
418
  * @param {Function=} successCallback
@@ -663,16 +423,11 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
663
423
  let resolve = when;
664
424
 
665
425
  /**
666
- * @ngdoc method
667
- * @name $q#all
668
- * @kind function
669
- *
670
- * @description
671
426
  * Combines multiple promises into a single promise that is resolved when all of the input
672
427
  * promises are resolved.
673
428
  *
674
- * @param {Array.<Promise>|Object.<Promise>} promises An array or hash of promises.
675
- * @returns {Promise} Returns a single promise that will be resolved with an array/hash of values,
429
+ * @param {Array.<QPromise>} promises An array or hash of promises.
430
+ * @returns {QPromise} Returns a single promise that will be resolved with an array/hash of values,
676
431
  * each value corresponding to the promise at the same index/key in the `promises` array/hash.
677
432
  * If any of the promises is resolved with a rejection, this resulting promise will be rejected
678
433
  * with the same rejection value.
@@ -704,16 +459,11 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
704
459
  }
705
460
 
706
461
  /**
707
- * @ngdoc method
708
- * @name $q#race
709
- * @kind function
710
- *
711
- * @description
712
462
  * Returns a promise that resolves or rejects as soon as one of those promises
713
463
  * resolves or rejects, with the value or reason from that promise.
714
464
  *
715
- * @param {Array.<Promise>|Object.<Promise>} promises An array or hash of promises.
716
- * @returns {Promise} a promise that resolves or rejects as soon as one of the `promises`
465
+ * @param {Array.<QPromise>} promises An array or hash of promises.
466
+ * @returns {QPromise} a promise that resolves or rejects as soon as one of the `promises`
717
467
  * resolves or rejects, with the value or reason from that promise.
718
468
  */
719
469
 
@@ -727,6 +477,13 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
727
477
  return deferred.promise;
728
478
  }
729
479
 
480
+ /**
481
+ * @param {function(function, function):any} resolver Function which is responsible for resolving or
482
+ * rejecting the newly created promise. The first parameter is a function which resolves the
483
+ * promise, the second parameter is a function which rejects the promise.
484
+ *
485
+ * @returns {QPromise} The newly created promise.
486
+ */
730
487
  function $Q(resolver) {
731
488
  if (!isFunction(resolver)) {
732
489
  throw $qMinErr("norslvr", "Expected resolverFn, got '{0}'", resolver);