@ngxs/store 3.7.3-dev.master-5175b98 → 3.7.3

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 (267) hide show
  1. package/README.md +16 -16
  2. package/bundles/ngxs-store-internals-testing.umd.js +215 -235
  3. package/bundles/ngxs-store-internals-testing.umd.js.map +1 -1
  4. package/bundles/ngxs-store-internals-testing.umd.min.js +2 -2
  5. package/bundles/ngxs-store-internals-testing.umd.min.js.map +1 -1
  6. package/bundles/ngxs-store-internals.umd.js +211 -422
  7. package/bundles/ngxs-store-internals.umd.js.map +1 -1
  8. package/bundles/ngxs-store-internals.umd.min.js +1 -1
  9. package/bundles/ngxs-store-internals.umd.min.js.map +1 -1
  10. package/bundles/ngxs-store-operators.umd.js +310 -311
  11. package/bundles/ngxs-store-operators.umd.js.map +1 -1
  12. package/bundles/ngxs-store-operators.umd.min.js +1 -1
  13. package/bundles/ngxs-store-operators.umd.min.js.map +1 -1
  14. package/bundles/ngxs-store.umd.js +4518 -4423
  15. package/bundles/ngxs-store.umd.js.map +1 -1
  16. package/bundles/ngxs-store.umd.min.js +1 -1
  17. package/bundles/ngxs-store.umd.min.js.map +1 -1
  18. package/esm2015/index.js +13 -13
  19. package/esm2015/internals/angular.js +40 -46
  20. package/esm2015/internals/index.js +10 -11
  21. package/esm2015/internals/initial-state.js +34 -34
  22. package/esm2015/internals/internal-tokens.js +16 -16
  23. package/esm2015/internals/memoize.js +70 -70
  24. package/esm2015/internals/ngxs-bootstrapper.js +41 -41
  25. package/esm2015/internals/ngxs-store-internals.js +9 -9
  26. package/esm2015/internals/src/symbols.js +14 -14
  27. package/esm2015/internals/symbols.js +14 -14
  28. package/esm2015/internals/testing/fresh-platform.js +71 -90
  29. package/esm2015/internals/testing/helpers/ngxs-test.component.js +22 -22
  30. package/esm2015/internals/testing/helpers/ngxs-test.module.js +24 -24
  31. package/esm2015/internals/testing/index.js +7 -7
  32. package/esm2015/internals/testing/ngxs-store-internals-testing.js +8 -8
  33. package/esm2015/internals/testing/ngxs.setup.js +76 -76
  34. package/esm2015/internals/testing/symbol.js +29 -29
  35. package/esm2015/ngxs-store.js +27 -24
  36. package/esm2015/operators/append.js +31 -31
  37. package/esm2015/operators/compose.js +24 -24
  38. package/esm2015/operators/iif.js +56 -56
  39. package/esm2015/operators/index.js +18 -18
  40. package/esm2015/operators/insert-item.js +41 -41
  41. package/esm2015/operators/internals.js +5 -5
  42. package/esm2015/operators/ngxs-store-operators.js +8 -8
  43. package/esm2015/operators/patch.js +39 -38
  44. package/esm2015/operators/remove-item.js +34 -34
  45. package/esm2015/operators/update-item.js +52 -54
  46. package/esm2015/operators/utils.js +50 -50
  47. package/esm2015/src/actions/actions.js +39 -39
  48. package/esm2015/src/actions/symbols.js +39 -39
  49. package/esm2015/src/actions-stream.js +140 -138
  50. package/esm2015/src/configs/messages.config.js +87 -79
  51. package/esm2015/src/decorators/action.js +44 -48
  52. package/esm2015/src/decorators/select/select-factory.js +46 -49
  53. package/esm2015/src/decorators/select/select.js +45 -81
  54. package/esm2015/src/decorators/select/symbols.js +50 -94
  55. package/esm2015/src/decorators/selector/selector.js +55 -59
  56. package/esm2015/src/decorators/selector/symbols.js +5 -5
  57. package/esm2015/src/decorators/selector-options.js +34 -34
  58. package/esm2015/src/decorators/state.js +75 -83
  59. package/esm2015/src/execution/dispatch-outside-zone-ngxs-execution-strategy.js +96 -101
  60. package/esm2015/src/execution/internal-ngxs-execution-strategy.js +45 -45
  61. package/esm2015/src/execution/noop-ngxs-execution-strategy.js +27 -27
  62. package/esm2015/src/execution/symbols.js +29 -29
  63. package/esm2015/src/host-environment/host-environment.js +31 -0
  64. package/esm2015/src/internal/config-validator.js +67 -0
  65. package/esm2015/src/internal/dispatcher.js +217 -217
  66. package/esm2015/src/internal/internals.js +489 -493
  67. package/esm2015/src/internal/lifecycle-state-manager.js +129 -129
  68. package/esm2015/src/internal/state-context-factory.js +138 -138
  69. package/esm2015/src/internal/state-factory.js +429 -449
  70. package/esm2015/src/internal/state-operations.js +125 -120
  71. package/esm2015/src/internal/state-operators.js +33 -33
  72. package/esm2015/src/internal/state-stream.js +21 -21
  73. package/esm2015/src/ivy/ensure-state-class-is-injectable.js +34 -0
  74. package/esm2015/src/ivy/ivy-enabled-in-dev-mode.js +40 -28
  75. package/esm2015/src/module.js +172 -158
  76. package/esm2015/src/modules/ngxs-feature.module.js +63 -63
  77. package/esm2015/src/modules/ngxs-root.module.js +52 -52
  78. package/esm2015/src/operators/leave-ngxs.js +58 -58
  79. package/esm2015/src/operators/of-action.js +191 -191
  80. package/esm2015/src/plugin-manager.js +70 -70
  81. package/esm2015/src/plugin_api.js +10 -10
  82. package/esm2015/src/public_api.js +29 -29
  83. package/esm2015/src/public_to_deprecate.js +64 -64
  84. package/esm2015/src/state-token/state-token.js +45 -45
  85. package/esm2015/src/state-token/symbols.js +5 -5
  86. package/esm2015/src/store.js +174 -174
  87. package/esm2015/src/symbols.js +221 -217
  88. package/esm2015/src/utils/compose.js +44 -44
  89. package/esm2015/src/utils/freeze.js +35 -35
  90. package/esm2015/src/utils/selector-utils.js +221 -221
  91. package/esm2015/src/utils/store-validators.js +65 -60
  92. package/esm2015/src/utils/utils.js +143 -143
  93. package/esm5/index.js +13 -13
  94. package/esm5/internals/angular.js +40 -46
  95. package/esm5/internals/index.js +10 -11
  96. package/esm5/internals/initial-state.js +45 -45
  97. package/esm5/internals/internal-tokens.js +16 -16
  98. package/esm5/internals/memoize.js +71 -71
  99. package/esm5/internals/ngxs-bootstrapper.js +56 -56
  100. package/esm5/internals/ngxs-store-internals.js +9 -9
  101. package/esm5/internals/src/symbols.js +14 -14
  102. package/esm5/internals/symbols.js +14 -14
  103. package/esm5/internals/testing/fresh-platform.js +81 -101
  104. package/esm5/internals/testing/helpers/ngxs-test.component.js +32 -32
  105. package/esm5/internals/testing/helpers/ngxs-test.module.js +32 -32
  106. package/esm5/internals/testing/index.js +7 -7
  107. package/esm5/internals/testing/ngxs-store-internals-testing.js +8 -8
  108. package/esm5/internals/testing/ngxs.setup.js +98 -98
  109. package/esm5/internals/testing/symbol.js +29 -29
  110. package/esm5/ngxs-store.js +27 -24
  111. package/esm5/operators/append.js +31 -31
  112. package/esm5/operators/compose.js +28 -28
  113. package/esm5/operators/iif.js +56 -56
  114. package/esm5/operators/index.js +18 -18
  115. package/esm5/operators/insert-item.js +41 -41
  116. package/esm5/operators/internals.js +5 -5
  117. package/esm5/operators/ngxs-store-operators.js +8 -8
  118. package/esm5/operators/patch.js +40 -39
  119. package/esm5/operators/remove-item.js +34 -34
  120. package/esm5/operators/update-item.js +52 -54
  121. package/esm5/operators/utils.js +50 -50
  122. package/esm5/src/actions/actions.js +62 -62
  123. package/esm5/src/actions/symbols.js +39 -39
  124. package/esm5/src/actions-stream.js +186 -184
  125. package/esm5/src/configs/messages.config.js +104 -79
  126. package/esm5/src/decorators/action.js +56 -60
  127. package/esm5/src/decorators/select/select-factory.js +47 -50
  128. package/esm5/src/decorators/select/select.js +50 -87
  129. package/esm5/src/decorators/select/symbols.js +51 -95
  130. package/esm5/src/decorators/selector/selector.js +55 -59
  131. package/esm5/src/decorators/selector/symbols.js +5 -5
  132. package/esm5/src/decorators/selector-options.js +34 -34
  133. package/esm5/src/decorators/state.js +76 -84
  134. package/esm5/src/execution/dispatch-outside-zone-ngxs-execution-strategy.js +121 -121
  135. package/esm5/src/execution/internal-ngxs-execution-strategy.js +54 -54
  136. package/esm5/src/execution/noop-ngxs-execution-strategy.js +41 -41
  137. package/esm5/src/execution/symbols.js +29 -29
  138. package/esm5/src/host-environment/host-environment.js +29 -0
  139. package/esm5/src/internal/config-validator.js +76 -0
  140. package/esm5/src/internal/dispatcher.js +253 -253
  141. package/esm5/src/internal/internals.js +491 -495
  142. package/esm5/src/internal/lifecycle-state-manager.js +177 -177
  143. package/esm5/src/internal/state-context-factory.js +146 -146
  144. package/esm5/src/internal/state-factory.js +563 -575
  145. package/esm5/src/internal/state-operations.js +139 -130
  146. package/esm5/src/internal/state-operators.js +34 -34
  147. package/esm5/src/internal/state-stream.js +25 -25
  148. package/esm5/src/ivy/ensure-state-class-is-injectable.js +34 -0
  149. package/esm5/src/ivy/ivy-enabled-in-dev-mode.js +40 -28
  150. package/esm5/src/module.js +215 -201
  151. package/esm5/src/modules/ngxs-feature.module.js +65 -65
  152. package/esm5/src/modules/ngxs-root.module.js +47 -47
  153. package/esm5/src/operators/leave-ngxs.js +58 -58
  154. package/esm5/src/operators/of-action.js +217 -217
  155. package/esm5/src/plugin-manager.js +82 -82
  156. package/esm5/src/plugin_api.js +10 -10
  157. package/esm5/src/public_api.js +29 -29
  158. package/esm5/src/public_to_deprecate.js +64 -64
  159. package/esm5/src/state-token/state-token.js +57 -57
  160. package/esm5/src/state-token/symbols.js +5 -5
  161. package/esm5/src/store.js +225 -225
  162. package/esm5/src/symbols.js +230 -226
  163. package/esm5/src/utils/compose.js +55 -55
  164. package/esm5/src/utils/freeze.js +35 -35
  165. package/esm5/src/utils/selector-utils.js +230 -230
  166. package/esm5/src/utils/store-validators.js +86 -78
  167. package/esm5/src/utils/utils.js +151 -151
  168. package/fesm2015/ngxs-store-internals-testing.js +175 -194
  169. package/fesm2015/ngxs-store-internals-testing.js.map +1 -1
  170. package/fesm2015/ngxs-store-internals.js +194 -402
  171. package/fesm2015/ngxs-store-internals.js.map +1 -1
  172. package/fesm2015/ngxs-store-operators.js +312 -313
  173. package/fesm2015/ngxs-store-operators.js.map +1 -1
  174. package/fesm2015/ngxs-store.js +3976 -3927
  175. package/fesm2015/ngxs-store.js.map +1 -1
  176. package/fesm5/ngxs-store-internals-testing.js +221 -241
  177. package/fesm5/ngxs-store-internals-testing.js.map +1 -1
  178. package/fesm5/ngxs-store-internals.js +219 -427
  179. package/fesm5/ngxs-store-internals.js.map +1 -1
  180. package/fesm5/ngxs-store-operators.js +316 -317
  181. package/fesm5/ngxs-store-operators.js.map +1 -1
  182. package/fesm5/ngxs-store.js +4510 -4420
  183. package/fesm5/ngxs-store.js.map +1 -1
  184. package/index.d.ts +8 -8
  185. package/internals/angular.d.ts +3 -3
  186. package/internals/index.d.ts +6 -7
  187. package/internals/initial-state.d.ts +8 -8
  188. package/internals/internal-tokens.d.ts +9 -9
  189. package/internals/memoize.d.ts +9 -9
  190. package/internals/ngxs-bootstrapper.d.ts +13 -13
  191. package/internals/ngxs-store-internals.d.ts +4 -4
  192. package/internals/ngxs-store-internals.metadata.json +1 -1
  193. package/internals/src/symbols.d.ts +7 -7
  194. package/internals/symbols.d.ts +7 -7
  195. package/internals/testing/fresh-platform.d.ts +1 -1
  196. package/internals/testing/helpers/ngxs-test.component.d.ts +5 -5
  197. package/internals/testing/helpers/ngxs-test.module.d.ts +4 -4
  198. package/internals/testing/index.d.ts +3 -3
  199. package/internals/testing/ngxs-store-internals-testing.d.ts +4 -4
  200. package/internals/testing/ngxs-store-internals-testing.metadata.json +1 -1
  201. package/internals/testing/ngxs.setup.d.ts +7 -7
  202. package/internals/testing/symbol.d.ts +14 -14
  203. package/ngxs-store.d.ts +23 -20
  204. package/ngxs-store.metadata.json +1 -1
  205. package/operators/append.d.ts +6 -6
  206. package/operators/compose.d.ts +2 -3
  207. package/operators/iif.d.ts +11 -11
  208. package/operators/index.d.ts +13 -13
  209. package/operators/insert-item.d.ts +7 -7
  210. package/operators/internals.d.ts +2 -2
  211. package/operators/ngxs-store-operators.d.ts +4 -4
  212. package/operators/ngxs-store-operators.metadata.json +1 -1
  213. package/operators/patch.d.ts +10 -6
  214. package/operators/remove-item.d.ts +7 -7
  215. package/operators/update-item.d.ts +10 -10
  216. package/operators/utils.d.ts +9 -10
  217. package/package.json +2 -2
  218. package/src/actions/actions.d.ts +15 -15
  219. package/src/actions/symbols.d.ts +21 -21
  220. package/src/actions-stream.d.ts +49 -49
  221. package/src/configs/messages.config.d.ts +30 -11
  222. package/src/decorators/action.d.ts +5 -5
  223. package/src/decorators/select/select-factory.d.ts +14 -13
  224. package/src/decorators/select/select.d.ts +4 -4
  225. package/src/decorators/select/symbols.d.ts +10 -14
  226. package/src/decorators/selector/selector.d.ts +5 -5
  227. package/src/decorators/selector/symbols.d.ts +4 -4
  228. package/src/decorators/selector-options.d.ts +5 -5
  229. package/src/decorators/state.d.ts +6 -6
  230. package/src/execution/dispatch-outside-zone-ngxs-execution-strategy.d.ts +12 -11
  231. package/src/execution/internal-ngxs-execution-strategy.d.ts +7 -7
  232. package/src/execution/noop-ngxs-execution-strategy.d.ts +5 -5
  233. package/src/execution/symbols.d.ts +6 -6
  234. package/src/host-environment/host-environment.d.ts +6 -0
  235. package/src/internal/config-validator.d.ts +10 -0
  236. package/src/internal/dispatcher.d.ts +32 -32
  237. package/src/internal/internals.d.ts +167 -166
  238. package/src/internal/lifecycle-state-manager.d.ts +20 -20
  239. package/src/internal/state-context-factory.d.ts +15 -15
  240. package/src/internal/state-factory.d.ts +58 -57
  241. package/src/internal/state-operations.d.ts +21 -19
  242. package/src/internal/state-operators.d.ts +2 -2
  243. package/src/internal/state-stream.d.ts +9 -9
  244. package/src/ivy/ensure-state-class-is-injectable.d.ts +6 -0
  245. package/src/ivy/ivy-enabled-in-dev-mode.d.ts +14 -6
  246. package/src/module.d.ts +23 -23
  247. package/src/modules/ngxs-feature.module.d.ts +13 -13
  248. package/src/modules/ngxs-root.module.d.ts +13 -13
  249. package/src/operators/leave-ngxs.d.ts +7 -7
  250. package/src/operators/of-action.d.ts +43 -43
  251. package/src/plugin-manager.d.ts +10 -10
  252. package/src/plugin_api.d.ts +5 -5
  253. package/src/public_api.d.ts +17 -17
  254. package/src/public_to_deprecate.d.ts +21 -21
  255. package/src/state-token/state-token.d.ts +7 -7
  256. package/src/state-token/symbols.d.ts +5 -5
  257. package/src/store.d.ts +53 -53
  258. package/src/symbols.d.ts +137 -135
  259. package/src/utils/compose.d.ts +23 -23
  260. package/src/utils/freeze.d.ts +5 -5
  261. package/src/utils/selector-utils.d.ts +23 -23
  262. package/src/utils/store-validators.d.ts +8 -7
  263. package/src/utils/utils.d.ts +46 -46
  264. package/types/index.d.ts +2 -2
  265. package/esm2015/internals/decorator-injector-adapter.js +0 -204
  266. package/esm5/internals/decorator-injector-adapter.js +0 -204
  267. package/internals/decorator-injector-adapter.d.ts +0 -15
@@ -1,334 +1,333 @@
1
- /**
2
- * @fileoverview added by tsickle
3
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4
- */
5
- /**
6
- * @template T
7
- * @param {?} items - Specific items to append to the end of an array
8
- * @return {?}
9
- */
10
- function append(items) {
11
- return (/**
12
- * @param {?} existing
13
- * @return {?}
14
- */
15
- function appendOperator(existing) {
16
- // If `items` is `undefined` or `null` or `[]` but `existing` is provided
17
- // just return `existing`
18
- /** @type {?} */
19
- const itemsNotProvidedButExistingIs = (!items || !items.length) && existing;
20
- if (itemsNotProvidedButExistingIs) {
21
- return (/** @type {?} */ (existing));
22
- }
23
- if (Array.isArray(existing)) {
24
- return existing.concat((/** @type {?} */ (((/** @type {?} */ (items))))));
25
- }
26
- // For example if some property is added dynamically
27
- // and didn't exist before thus it's not `ArrayLike`
28
- return (/** @type {?} */ (((/** @type {?} */ (items)))));
29
- });
1
+ /**
2
+ * @fileoverview added by tsickle
3
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4
+ */
5
+ /**
6
+ * @template T
7
+ * @param {?} items - Specific items to append to the end of an array
8
+ * @return {?}
9
+ */
10
+ function append(items) {
11
+ return (/**
12
+ * @param {?} existing
13
+ * @return {?}
14
+ */
15
+ function appendOperator(existing) {
16
+ // If `items` is `undefined` or `null` or `[]` but `existing` is provided
17
+ // just return `existing`
18
+ /** @type {?} */
19
+ const itemsNotProvidedButExistingIs = (!items || !items.length) && existing;
20
+ if (itemsNotProvidedButExistingIs) {
21
+ return (/** @type {?} */ (existing));
22
+ }
23
+ if (Array.isArray(existing)) {
24
+ return existing.concat((/** @type {?} */ (items)));
25
+ }
26
+ // For example if some property is added dynamically
27
+ // and didn't exist before thus it's not `ArrayLike`
28
+ return (/** @type {?} */ (items));
29
+ });
30
30
  }
31
31
 
32
- /**
33
- * @fileoverview added by tsickle
34
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
35
- */
36
- /**
37
- * @template T
38
- * @param {...?} operators
39
- * @return {?}
40
- */
41
- function compose(...operators) {
42
- return (/**
43
- * @param {?} existing
44
- * @return {?}
45
- */
46
- function composeOperator(existing) {
47
- return operators.reduce((/**
48
- * @param {?} accumulator
49
- * @param {?} operator
50
- * @return {?}
51
- */
52
- (accumulator, operator) => operator(accumulator)), existing);
53
- });
32
+ /**
33
+ * @fileoverview added by tsickle
34
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
35
+ */
36
+ /**
37
+ * @template T
38
+ * @param {...?} operators
39
+ * @return {?}
40
+ */
41
+ function compose(...operators) {
42
+ return (/**
43
+ * @param {?} existing
44
+ * @return {?}
45
+ */
46
+ function composeOperator(existing) {
47
+ return operators.reduce((/**
48
+ * @param {?} accumulator
49
+ * @param {?} operator
50
+ * @return {?}
51
+ */
52
+ (accumulator, operator) => operator(accumulator)), existing);
53
+ });
54
54
  }
55
55
 
56
- /**
57
- * @fileoverview added by tsickle
58
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
59
- */
60
- /**
61
- * @template T
62
- * @param {?} value
63
- * @return {?}
64
- */
65
- function isStateOperator(value) {
66
- return typeof value === 'function';
67
- }
68
- /**
69
- * @param {?} value
70
- * @return {?}
71
- */
72
- function isUndefined(value) {
73
- return typeof value === 'undefined';
74
- }
75
- /**
76
- * @template T
77
- * @param {?} value
78
- * @return {?}
79
- */
80
- function isPredicate(value) {
81
- return typeof value === 'function';
82
- }
83
- /**
84
- * @param {?} value
85
- * @return {?}
86
- */
87
- function isNumber(value) {
88
- return typeof value === 'number';
89
- }
90
- /**
91
- * @param {?} index
92
- * @return {?}
93
- */
94
- function invalidIndex(index) {
95
- return Number.isNaN(index) || index === -1;
96
- }
97
- /**
98
- * @template T
99
- * @param {?} value
100
- * @return {?}
101
- */
102
- function isNil(value) {
103
- return value === null || isUndefined(value);
56
+ /**
57
+ * @fileoverview added by tsickle
58
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
59
+ */
60
+ /**
61
+ * @template T
62
+ * @param {?} value
63
+ * @return {?}
64
+ */
65
+ function isStateOperator(value) {
66
+ return typeof value === 'function';
67
+ }
68
+ /**
69
+ * @param {?} value
70
+ * @return {?}
71
+ */
72
+ function isUndefined(value) {
73
+ return typeof value === 'undefined';
74
+ }
75
+ /**
76
+ * @template T
77
+ * @param {?} value
78
+ * @return {?}
79
+ */
80
+ function isPredicate(value) {
81
+ return typeof value === 'function';
82
+ }
83
+ /**
84
+ * @param {?} value
85
+ * @return {?}
86
+ */
87
+ function isNumber(value) {
88
+ return typeof value === 'number';
89
+ }
90
+ /**
91
+ * @param {?} index
92
+ * @return {?}
93
+ */
94
+ function invalidIndex(index) {
95
+ return Number.isNaN(index) || index === -1;
96
+ }
97
+ /**
98
+ * @template T
99
+ * @param {?} value
100
+ * @return {?}
101
+ */
102
+ function isNil(value) {
103
+ return value === null || isUndefined(value);
104
104
  }
105
105
 
106
- /**
107
- * @fileoverview added by tsickle
108
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
109
- */
110
- /**
111
- * @template T
112
- * @param {?} operatorOrValue
113
- * @param {?=} existing
114
- * @return {?}
115
- */
116
- function retrieveValue(operatorOrValue, existing) {
117
- // If state operator is a function
118
- // then call it with an original value
119
- if (isStateOperator(operatorOrValue)) {
120
- /** @type {?} */
121
- const value = operatorOrValue((/** @type {?} */ ((/** @type {?} */ (existing)))));
122
- return (/** @type {?} */ (value));
123
- }
124
- // If operator or value was not provided
125
- // e.g. `elseOperatorOrValue` is `undefined`
126
- // then we just return an original value
127
- if (isUndefined(operatorOrValue)) {
128
- return (/** @type {?} */ ((/** @type {?} */ (((/** @type {?} */ (existing)))))));
129
- }
130
- return (/** @type {?} */ (operatorOrValue));
131
- }
132
- /**
133
- * @template T
134
- * @param {?} condition - Condition can be a plain boolean value or a function,
135
- * that returns boolean, also this function can take a value as an argument
136
- * to which this state operator applies
137
- * @param {?} trueOperatorOrValue - Any value or a state operator
138
- * @param {?=} elseOperatorOrValue - Any value or a state operator
139
- * @return {?}
140
- */
141
- function iif(condition, trueOperatorOrValue, elseOperatorOrValue) {
142
- return (/**
143
- * @param {?} existing
144
- * @return {?}
145
- */
146
- function iifOperator(existing) {
147
- // Convert the value to a boolean
148
- /** @type {?} */
149
- let result = !!condition;
150
- // but if it is a function then run it to get the result
151
- if (isPredicate(condition)) {
152
- result = condition(existing);
153
- }
154
- if (result) {
155
- return retrieveValue(trueOperatorOrValue, (/** @type {?} */ (existing)));
156
- }
157
- return retrieveValue((/** @type {?} */ (elseOperatorOrValue)), (/** @type {?} */ (existing)));
158
- });
106
+ /**
107
+ * @fileoverview added by tsickle
108
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
109
+ */
110
+ /**
111
+ * @template T
112
+ * @param {?} operatorOrValue
113
+ * @param {?=} existing
114
+ * @return {?}
115
+ */
116
+ function retrieveValue(operatorOrValue, existing) {
117
+ // If state operator is a function
118
+ // then call it with an original value
119
+ if (isStateOperator(operatorOrValue)) {
120
+ /** @type {?} */
121
+ const value = operatorOrValue((/** @type {?} */ ((/** @type {?} */ (existing)))));
122
+ return (/** @type {?} */ (value));
123
+ }
124
+ // If operator or value was not provided
125
+ // e.g. `elseOperatorOrValue` is `undefined`
126
+ // then we just return an original value
127
+ if (isUndefined(operatorOrValue)) {
128
+ return (/** @type {?} */ ((/** @type {?} */ (((/** @type {?} */ (existing)))))));
129
+ }
130
+ return (/** @type {?} */ (operatorOrValue));
131
+ }
132
+ /**
133
+ * @template T
134
+ * @param {?} condition - Condition can be a plain boolean value or a function,
135
+ * that returns boolean, also this function can take a value as an argument
136
+ * to which this state operator applies
137
+ * @param {?} trueOperatorOrValue - Any value or a state operator
138
+ * @param {?=} elseOperatorOrValue - Any value or a state operator
139
+ * @return {?}
140
+ */
141
+ function iif(condition, trueOperatorOrValue, elseOperatorOrValue) {
142
+ return (/**
143
+ * @param {?} existing
144
+ * @return {?}
145
+ */
146
+ function iifOperator(existing) {
147
+ // Convert the value to a boolean
148
+ /** @type {?} */
149
+ let result = !!condition;
150
+ // but if it is a function then run it to get the result
151
+ if (isPredicate(condition)) {
152
+ result = condition(existing);
153
+ }
154
+ if (result) {
155
+ return retrieveValue(trueOperatorOrValue, (/** @type {?} */ (existing)));
156
+ }
157
+ return retrieveValue((/** @type {?} */ (elseOperatorOrValue)), (/** @type {?} */ (existing)));
158
+ });
159
159
  }
160
160
 
161
- /**
162
- * @fileoverview added by tsickle
163
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
164
- */
165
- /**
166
- * @template T
167
- * @param {?} value - Value to insert
168
- * @param {?=} beforePosition
169
- * @return {?}
170
- */
171
- function insertItem(value, beforePosition) {
172
- return (/**
173
- * @param {?} existing
174
- * @return {?}
175
- */
176
- function insertItemOperator(existing) {
177
- // Have to check explicitly for `null` and `undefined`
178
- // because `value` can be `0`, thus `!value` will return `true`
179
- if (isNil(value) && existing) {
180
- return (/** @type {?} */ (existing));
181
- }
182
- // Property may be dynamic and might not existed before
183
- if (!Array.isArray(existing)) {
184
- return [(/** @type {?} */ (((/** @type {?} */ (value)))))];
185
- }
186
- /** @type {?} */
187
- const clone = existing.slice();
188
- /** @type {?} */
189
- let index = 0;
190
- // No need to call `isNumber`
191
- // as we are checking `> 0` not `>= 0`
192
- // everything except number will return false here
193
- if ((/** @type {?} */ (beforePosition)) > 0) {
194
- index = (/** @type {?} */ (beforePosition));
195
- }
196
- clone.splice(index, 0, (/** @type {?} */ (((/** @type {?} */ (value))))));
197
- return clone;
198
- });
161
+ /**
162
+ * @fileoverview added by tsickle
163
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
164
+ */
165
+ /**
166
+ * @template T
167
+ * @param {?} value - Value to insert
168
+ * @param {?=} beforePosition
169
+ * @return {?}
170
+ */
171
+ function insertItem(value, beforePosition) {
172
+ return (/**
173
+ * @param {?} existing
174
+ * @return {?}
175
+ */
176
+ function insertItemOperator(existing) {
177
+ // Have to check explicitly for `null` and `undefined`
178
+ // because `value` can be `0`, thus `!value` will return `true`
179
+ if (isNil(value) && existing) {
180
+ return (/** @type {?} */ (existing));
181
+ }
182
+ // Property may be dynamic and might not existed before
183
+ if (!Array.isArray(existing)) {
184
+ return [(/** @type {?} */ (value))];
185
+ }
186
+ /** @type {?} */
187
+ const clone = existing.slice();
188
+ /** @type {?} */
189
+ let index = 0;
190
+ // No need to call `isNumber`
191
+ // as we are checking `> 0` not `>= 0`
192
+ // everything except number will return false here
193
+ if ((/** @type {?} */ (beforePosition)) > 0) {
194
+ index = (/** @type {?} */ (beforePosition));
195
+ }
196
+ clone.splice(index, 0, (/** @type {?} */ (value)));
197
+ return clone;
198
+ });
199
199
  }
200
200
 
201
- /**
202
- * @fileoverview added by tsickle
203
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
204
- */
205
- /**
206
- * @template T
207
- * @param {?} patchObject
208
- * @return {?}
209
- */
210
- function patch(patchObject) {
211
- return (/** @type {?} */ (((/** @type {?} */ ((/**
212
- * @param {?} existing
213
- * @return {?}
214
- */
215
- function patchStateOperator(existing) {
216
- /** @type {?} */
217
- let clone = null;
218
- for (const k in patchObject) {
219
- /** @type {?} */
220
- const newValue = patchObject[k];
221
- /** @type {?} */
222
- const existingPropValue = existing[(/** @type {?} */ (k))];
223
- /** @type {?} */
224
- const newPropValue = isStateOperator(newValue)
225
- ? newValue((/** @type {?} */ (existingPropValue)))
226
- : newValue;
227
- if (newPropValue !== existingPropValue) {
228
- if (!clone) {
229
- clone = Object.assign({}, ((/** @type {?} */ (existing))));
230
- }
231
- clone[k] = newPropValue;
232
- }
233
- }
234
- return clone || existing;
235
- }))))));
201
+ /**
202
+ * @fileoverview added by tsickle
203
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
204
+ */
205
+ /**
206
+ * @template T
207
+ * @param {?} patchObject
208
+ * @return {?}
209
+ */
210
+ function patch(patchObject) {
211
+ return (/**
212
+ * @template U
213
+ * @param {?} existing
214
+ * @return {?}
215
+ */
216
+ function patchStateOperator(existing) {
217
+ /** @type {?} */
218
+ let clone = null;
219
+ for (const k in patchObject) {
220
+ /** @type {?} */
221
+ const newValue = patchObject[k];
222
+ /** @type {?} */
223
+ const existingPropValue = existing[k];
224
+ /** @type {?} */
225
+ const newPropValue = isStateOperator(newValue)
226
+ ? newValue((/** @type {?} */ (existingPropValue)))
227
+ : newValue;
228
+ if (newPropValue !== existingPropValue) {
229
+ if (!clone) {
230
+ clone = Object.assign({}, ((/** @type {?} */ (existing))));
231
+ }
232
+ clone[k] = newPropValue;
233
+ }
234
+ }
235
+ return clone || existing;
236
+ });
236
237
  }
237
238
 
238
- /**
239
- * @fileoverview added by tsickle
240
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
241
- */
242
- /**
243
- * @template T
244
- * @param {?} selector - Index of item in the array or a predicate function
245
- * that can be provided in `Array.prototype.findIndex`
246
- * @param {?} operatorOrValue - New value under the `selector` index or a
247
- * function that can be applied to an existing value
248
- * @return {?}
249
- */
250
- function updateItem(selector, operatorOrValue) {
251
- return (/**
252
- * @param {?} existing
253
- * @return {?}
254
- */
255
- function updateItemOperator(existing) {
256
- /** @type {?} */
257
- let index = -1;
258
- if (isPredicate(selector)) {
259
- index = existing.findIndex((/** @type {?} */ (selector)));
260
- }
261
- else if (isNumber(selector)) {
262
- index = selector;
263
- }
264
- if (invalidIndex(index)) {
265
- return (/** @type {?} */ (existing));
266
- }
267
- /** @type {?} */
268
- let value = (/** @type {?} */ (null));
269
- // Need to check if the new item value will change the existing item value
270
- // then, only if it will change it then clone the array and set the item
271
- /** @type {?} */
272
- const theOperatorOrValue = (/** @type {?} */ (operatorOrValue));
273
- if (isStateOperator(theOperatorOrValue)) {
274
- value = theOperatorOrValue((/** @type {?} */ (existing[index])));
275
- }
276
- else {
277
- value = theOperatorOrValue;
278
- }
279
- // If the value hasn't been mutated
280
- // then we just return `existing` array
281
- if (value === existing[index]) {
282
- return (/** @type {?} */ (existing));
283
- }
284
- /** @type {?} */
285
- const clone = existing.slice();
286
- clone[index] = (/** @type {?} */ (value));
287
- return clone;
288
- });
239
+ /**
240
+ * @fileoverview added by tsickle
241
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
242
+ */
243
+ /**
244
+ * @template T
245
+ * @param {?} selector - Index of item in the array or a predicate function
246
+ * that can be provided in `Array.prototype.findIndex`
247
+ * @param {?} operatorOrValue - New value under the `selector` index or a
248
+ * function that can be applied to an existing value
249
+ * @return {?}
250
+ */
251
+ function updateItem(selector, operatorOrValue) {
252
+ return (/**
253
+ * @param {?} existing
254
+ * @return {?}
255
+ */
256
+ function updateItemOperator(existing) {
257
+ /** @type {?} */
258
+ let index = -1;
259
+ if (isPredicate(selector)) {
260
+ index = existing.findIndex(selector);
261
+ }
262
+ else if (isNumber(selector)) {
263
+ index = selector;
264
+ }
265
+ if (invalidIndex(index)) {
266
+ return (/** @type {?} */ (existing));
267
+ }
268
+ /** @type {?} */
269
+ let value = (/** @type {?} */ (null));
270
+ // Need to check if the new item value will change the existing item value
271
+ // then, only if it will change it then clone the array and set the item
272
+ if (isStateOperator(operatorOrValue)) {
273
+ value = operatorOrValue((/** @type {?} */ (existing[index])));
274
+ }
275
+ else {
276
+ value = operatorOrValue;
277
+ }
278
+ // If the value hasn't been mutated
279
+ // then we just return `existing` array
280
+ if (value === existing[index]) {
281
+ return (/** @type {?} */ (existing));
282
+ }
283
+ /** @type {?} */
284
+ const clone = existing.slice();
285
+ clone[index] = (/** @type {?} */ (value));
286
+ return clone;
287
+ });
289
288
  }
290
289
 
291
- /**
292
- * @fileoverview added by tsickle
293
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
294
- */
295
- /**
296
- * @template T
297
- * @param {?} selector - index or predicate to remove an item from an array by
298
- * @return {?}
299
- */
300
- function removeItem(selector) {
301
- return (/**
302
- * @param {?} existing
303
- * @return {?}
304
- */
305
- function removeItemOperator(existing) {
306
- /** @type {?} */
307
- let index = -1;
308
- if (isPredicate(selector)) {
309
- index = existing.findIndex(selector);
310
- }
311
- else if (isNumber(selector)) {
312
- index = selector;
313
- }
314
- if (invalidIndex(index)) {
315
- return (/** @type {?} */ (existing));
316
- }
317
- /** @type {?} */
318
- const clone = existing.slice();
319
- clone.splice(index, 1);
320
- return clone;
321
- });
290
+ /**
291
+ * @fileoverview added by tsickle
292
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
293
+ */
294
+ /**
295
+ * @template T
296
+ * @param {?} selector - index or predicate to remove an item from an array by
297
+ * @return {?}
298
+ */
299
+ function removeItem(selector) {
300
+ return (/**
301
+ * @param {?} existing
302
+ * @return {?}
303
+ */
304
+ function removeItemOperator(existing) {
305
+ /** @type {?} */
306
+ let index = -1;
307
+ if (isPredicate(selector)) {
308
+ index = existing.findIndex(selector);
309
+ }
310
+ else if (isNumber(selector)) {
311
+ index = selector;
312
+ }
313
+ if (invalidIndex(index)) {
314
+ return (/** @type {?} */ (existing));
315
+ }
316
+ /** @type {?} */
317
+ const clone = existing.slice();
318
+ clone.splice(index, 1);
319
+ return clone;
320
+ });
322
321
  }
323
322
 
324
- /**
325
- * @fileoverview added by tsickle
326
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
323
+ /**
324
+ * @fileoverview added by tsickle
325
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
327
326
  */
328
327
 
329
- /**
330
- * @fileoverview added by tsickle
331
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
328
+ /**
329
+ * @fileoverview added by tsickle
330
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
332
331
  */
333
332
 
334
333
  export { append, compose, iif, insertItem, isStateOperator, patch, removeItem, updateItem };