@ngxs/store 3.7.6-dev.master-fb318b1 → 3.7.6-dev.master-dcdd391

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 (230) hide show
  1. package/bundles/ngxs-store-internals-testing.umd.js +409 -420
  2. package/bundles/ngxs-store-internals-testing.umd.js.map +1 -1
  3. package/bundles/ngxs-store-internals.umd.js +48 -117
  4. package/bundles/ngxs-store-internals.umd.js.map +1 -1
  5. package/bundles/ngxs-store-operators.umd.js +60 -402
  6. package/bundles/ngxs-store-operators.umd.js.map +1 -1
  7. package/bundles/ngxs-store.umd.js +1041 -3269
  8. package/bundles/ngxs-store.umd.js.map +1 -1
  9. package/esm2015/index.js +7 -7
  10. package/esm2015/internals/angular.js +1 -8
  11. package/esm2015/internals/index.js +2 -6
  12. package/esm2015/internals/initial-state.js +1 -21
  13. package/esm2015/internals/internal-tokens.js +4 -15
  14. package/esm2015/internals/memoize.js +8 -33
  15. package/esm2015/internals/ngxs-bootstrapper.js +7 -20
  16. package/esm2015/internals/ngxs-store-internals.js +2 -6
  17. package/esm2015/internals/src/symbols.js +2 -14
  18. package/esm2015/internals/symbols.js +2 -14
  19. package/esm2015/internals/testing/fresh-platform.js +13 -53
  20. package/esm2015/internals/testing/helpers/ngxs-test.component.js +11 -17
  21. package/esm2015/internals/testing/helpers/ngxs-test.module.js +13 -16
  22. package/esm2015/internals/testing/index.js +1 -5
  23. package/esm2015/internals/testing/ngxs-store-internals-testing.js +2 -6
  24. package/esm2015/internals/testing/ngxs.setup.js +1 -31
  25. package/esm2015/internals/testing/skip-console-logging.js +7 -42
  26. package/esm2015/internals/testing/symbol.js +2 -29
  27. package/esm2015/ngxs-store.js +2 -23
  28. package/esm2015/operators/append.js +7 -18
  29. package/esm2015/operators/compose.js +4 -22
  30. package/esm2015/operators/iif.js +12 -30
  31. package/esm2015/operators/index.js +1 -5
  32. package/esm2015/operators/insert-item.js +10 -22
  33. package/esm2015/operators/ngxs-store-operators.js +2 -6
  34. package/esm2015/operators/patch.js +5 -22
  35. package/esm2015/operators/remove-item.js +5 -17
  36. package/esm2015/operators/types.js +2 -5
  37. package/esm2015/operators/update-item.js +12 -26
  38. package/esm2015/operators/utils.js +1 -32
  39. package/esm2015/src/actions/actions.js +1 -18
  40. package/esm2015/src/actions/symbols.js +2 -39
  41. package/esm2015/src/actions-stream.js +24 -90
  42. package/esm2015/src/configs/messages.config.js +1 -44
  43. package/esm2015/src/decorators/action.js +3 -18
  44. package/esm2015/src/decorators/select/select-factory.js +10 -27
  45. package/esm2015/src/decorators/select/select.js +3 -22
  46. package/esm2015/src/decorators/select/symbols.js +4 -25
  47. package/esm2015/src/decorators/selector/selector.js +5 -29
  48. package/esm2015/src/decorators/selector/symbols.js +2 -5
  49. package/esm2015/src/decorators/selector-options.js +4 -18
  50. package/esm2015/src/decorators/state.js +5 -44
  51. package/esm2015/src/dev-features/ngxs-development.module.js +8 -12
  52. package/esm2015/src/dev-features/ngxs-unhandled-actions-logger.js +12 -37
  53. package/esm2015/src/dev-features/symbols.js +2 -18
  54. package/esm2015/src/execution/dispatch-outside-zone-ngxs-execution-strategy.js +10 -56
  55. package/esm2015/src/execution/internal-ngxs-execution-strategy.js +10 -32
  56. package/esm2015/src/execution/noop-ngxs-execution-strategy.js +7 -19
  57. package/esm2015/src/execution/symbols.js +3 -32
  58. package/esm2015/src/internal/dispatcher.js +26 -121
  59. package/esm2015/src/internal/error-handler.js +18 -72
  60. package/esm2015/src/internal/internals.js +24 -244
  61. package/esm2015/src/internal/lifecycle-state-manager.js +19 -117
  62. package/esm2015/src/internal/state-context-factory.js +9 -67
  63. package/esm2015/src/internal/state-factory.js +42 -225
  64. package/esm2015/src/internal/state-operations.js +19 -80
  65. package/esm2015/src/internal/state-operators.js +6 -20
  66. package/esm2015/src/internal/state-stream.js +7 -13
  67. package/esm2015/src/ivy/ivy-enabled-in-dev-mode.js +7 -17
  68. package/esm2015/src/module.js +12 -47
  69. package/esm2015/src/modules/ngxs-feature.module.js +18 -36
  70. package/esm2015/src/modules/ngxs-root.module.js +18 -26
  71. package/esm2015/src/operators/leave-ngxs.js +8 -43
  72. package/esm2015/src/operators/of-action.js +16 -111
  73. package/esm2015/src/plugin-manager.js +17 -50
  74. package/esm2015/src/plugin_api.js +1 -5
  75. package/esm2015/src/private_api.js +3 -0
  76. package/esm2015/src/public_api.js +1 -5
  77. package/esm2015/src/public_to_deprecate.js +1 -51
  78. package/esm2015/src/state-token/state-token.js +4 -32
  79. package/esm2015/src/state-token/symbols.js +2 -5
  80. package/esm2015/src/store.js +20 -104
  81. package/esm2015/src/symbols.js +7 -177
  82. package/esm2015/src/utils/compose.js +5 -23
  83. package/esm2015/src/utils/freeze.js +5 -20
  84. package/esm2015/src/utils/selector-utils.js +23 -136
  85. package/esm2015/src/utils/store-validators.js +3 -36
  86. package/esm2015/src/utils/utils.js +13 -64
  87. package/fesm2015/ngxs-store-internals-testing.js +38 -159
  88. package/fesm2015/ngxs-store-internals-testing.js.map +1 -1
  89. package/fesm2015/ngxs-store-internals.js +18 -100
  90. package/fesm2015/ngxs-store-internals.js.map +1 -1
  91. package/fesm2015/ngxs-store-operators.js +52 -185
  92. package/fesm2015/ngxs-store-operators.js.map +1 -1
  93. package/fesm2015/ngxs-store.js +400 -2473
  94. package/fesm2015/ngxs-store.js.map +1 -1
  95. package/index.d.ts +4 -0
  96. package/internals/index.d.ts +1 -1
  97. package/internals/internal-tokens.d.ts +2 -8
  98. package/internals/ngxs-bootstrapper.d.ts +4 -1
  99. package/internals/ngxs-store-internals.d.ts +1 -0
  100. package/internals/package.json +2 -5
  101. package/internals/testing/helpers/ngxs-test.component.d.ts +3 -0
  102. package/internals/testing/helpers/ngxs-test.module.d.ts +6 -0
  103. package/internals/testing/ngxs-store-internals-testing.d.ts +1 -0
  104. package/internals/testing/package.json +2 -5
  105. package/ngxs-store.d.ts +1 -18
  106. package/operators/ngxs-store-operators.d.ts +1 -0
  107. package/operators/package.json +2 -5
  108. package/package.json +3 -6
  109. package/src/actions/actions.d.ts +2 -2
  110. package/src/actions-stream.d.ts +5 -0
  111. package/src/decorators/select/select-factory.d.ts +3 -0
  112. package/src/decorators/state.d.ts +1 -1
  113. package/src/dev-features/ngxs-development.module.d.ts +4 -0
  114. package/src/dev-features/ngxs-unhandled-actions-logger.d.ts +3 -0
  115. package/src/execution/dispatch-outside-zone-ngxs-execution-strategy.d.ts +3 -0
  116. package/src/execution/internal-ngxs-execution-strategy.d.ts +3 -0
  117. package/src/execution/noop-ngxs-execution-strategy.d.ts +3 -0
  118. package/src/internal/dispatcher.d.ts +5 -0
  119. package/src/internal/error-handler.d.ts +4 -1
  120. package/src/internal/lifecycle-state-manager.d.ts +3 -0
  121. package/src/internal/state-context-factory.d.ts +3 -0
  122. package/src/internal/state-factory.d.ts +7 -4
  123. package/src/internal/state-operations.d.ts +3 -0
  124. package/src/internal/state-stream.d.ts +3 -0
  125. package/src/module.d.ts +4 -0
  126. package/src/modules/ngxs-feature.module.d.ts +4 -0
  127. package/src/modules/ngxs-root.module.d.ts +4 -0
  128. package/src/plugin-manager.d.ts +4 -1
  129. package/src/private_api.d.ts +2 -0
  130. package/src/store.d.ts +3 -0
  131. package/src/symbols.d.ts +4 -1
  132. package/src/utils/utils.d.ts +1 -1
  133. package/bundles/ngxs-store-internals-testing.umd.min.js +0 -16
  134. package/bundles/ngxs-store-internals-testing.umd.min.js.map +0 -1
  135. package/bundles/ngxs-store-internals.umd.min.js +0 -2
  136. package/bundles/ngxs-store-internals.umd.min.js.map +0 -1
  137. package/bundles/ngxs-store-operators.umd.min.js +0 -16
  138. package/bundles/ngxs-store-operators.umd.min.js.map +0 -1
  139. package/bundles/ngxs-store.umd.min.js +0 -16
  140. package/bundles/ngxs-store.umd.min.js.map +0 -1
  141. package/esm5/index.js +0 -13
  142. package/esm5/internals/angular.js +0 -20
  143. package/esm5/internals/index.js +0 -10
  144. package/esm5/internals/initial-state.js +0 -45
  145. package/esm5/internals/internal-tokens.js +0 -16
  146. package/esm5/internals/memoize.js +0 -71
  147. package/esm5/internals/ngxs-bootstrapper.js +0 -56
  148. package/esm5/internals/ngxs-store-internals.js +0 -9
  149. package/esm5/internals/src/symbols.js +0 -14
  150. package/esm5/internals/symbols.js +0 -14
  151. package/esm5/internals/testing/fresh-platform.js +0 -121
  152. package/esm5/internals/testing/helpers/ngxs-test.component.js +0 -32
  153. package/esm5/internals/testing/helpers/ngxs-test.module.js +0 -32
  154. package/esm5/internals/testing/index.js +0 -8
  155. package/esm5/internals/testing/ngxs-store-internals-testing.js +0 -9
  156. package/esm5/internals/testing/ngxs.setup.js +0 -98
  157. package/esm5/internals/testing/skip-console-logging.js +0 -62
  158. package/esm5/internals/testing/symbol.js +0 -29
  159. package/esm5/ngxs-store.js +0 -26
  160. package/esm5/operators/append.js +0 -31
  161. package/esm5/operators/compose.js +0 -28
  162. package/esm5/operators/iif.js +0 -56
  163. package/esm5/operators/index.js +0 -18
  164. package/esm5/operators/insert-item.js +0 -41
  165. package/esm5/operators/ngxs-store-operators.js +0 -9
  166. package/esm5/operators/patch.js +0 -39
  167. package/esm5/operators/remove-item.js +0 -34
  168. package/esm5/operators/types.js +0 -5
  169. package/esm5/operators/update-item.js +0 -54
  170. package/esm5/operators/utils.js +0 -50
  171. package/esm5/src/actions/actions.js +0 -62
  172. package/esm5/src/actions/symbols.js +0 -39
  173. package/esm5/src/actions-stream.js +0 -201
  174. package/esm5/src/configs/messages.config.js +0 -79
  175. package/esm5/src/decorators/action.js +0 -60
  176. package/esm5/src/decorators/select/select-factory.js +0 -46
  177. package/esm5/src/decorators/select/select.js +0 -50
  178. package/esm5/src/decorators/select/symbols.js +0 -51
  179. package/esm5/src/decorators/selector/selector.js +0 -59
  180. package/esm5/src/decorators/selector/symbols.js +0 -5
  181. package/esm5/src/decorators/selector-options.js +0 -34
  182. package/esm5/src/decorators/state.js +0 -78
  183. package/esm5/src/dev-features/ngxs-development.module.js +0 -34
  184. package/esm5/src/dev-features/ngxs-unhandled-actions-logger.js +0 -100
  185. package/esm5/src/dev-features/symbols.js +0 -22
  186. package/esm5/src/execution/dispatch-outside-zone-ngxs-execution-strategy.js +0 -123
  187. package/esm5/src/execution/internal-ngxs-execution-strategy.js +0 -54
  188. package/esm5/src/execution/noop-ngxs-execution-strategy.js +0 -43
  189. package/esm5/src/execution/symbols.js +0 -52
  190. package/esm5/src/internal/dispatcher.js +0 -231
  191. package/esm5/src/internal/error-handler.js +0 -125
  192. package/esm5/src/internal/internals.js +0 -470
  193. package/esm5/src/internal/lifecycle-state-manager.js +0 -224
  194. package/esm5/src/internal/state-context-factory.js +0 -135
  195. package/esm5/src/internal/state-factory.js +0 -599
  196. package/esm5/src/internal/state-operations.js +0 -134
  197. package/esm5/src/internal/state-operators.js +0 -34
  198. package/esm5/src/internal/state-stream.js +0 -37
  199. package/esm5/src/ivy/ivy-enabled-in-dev-mode.js +0 -28
  200. package/esm5/src/module.js +0 -202
  201. package/esm5/src/modules/ngxs-feature.module.js +0 -65
  202. package/esm5/src/modules/ngxs-root.module.js +0 -44
  203. package/esm5/src/operators/leave-ngxs.js +0 -58
  204. package/esm5/src/operators/of-action.js +0 -223
  205. package/esm5/src/plugin-manager.js +0 -82
  206. package/esm5/src/plugin_api.js +0 -10
  207. package/esm5/src/public_api.js +0 -31
  208. package/esm5/src/public_to_deprecate.js +0 -64
  209. package/esm5/src/state-token/state-token.js +0 -57
  210. package/esm5/src/state-token/symbols.js +0 -5
  211. package/esm5/src/store.js +0 -241
  212. package/esm5/src/symbols.js +0 -230
  213. package/esm5/src/utils/compose.js +0 -55
  214. package/esm5/src/utils/freeze.js +0 -35
  215. package/esm5/src/utils/selector-utils.js +0 -230
  216. package/esm5/src/utils/store-validators.js +0 -78
  217. package/esm5/src/utils/utils.js +0 -151
  218. package/fesm5/ngxs-store-internals-testing.js +0 -345
  219. package/fesm5/ngxs-store-internals-testing.js.map +0 -1
  220. package/fesm5/ngxs-store-internals.js +0 -217
  221. package/fesm5/ngxs-store-internals.js.map +0 -1
  222. package/fesm5/ngxs-store-operators.js +0 -341
  223. package/fesm5/ngxs-store-operators.js.map +0 -1
  224. package/fesm5/ngxs-store.js +0 -4783
  225. package/fesm5/ngxs-store.js.map +0 -1
  226. package/internals/ngxs-store-internals.metadata.json +0 -1
  227. package/internals/testing/ngxs-store-internals-testing.metadata.json +0 -1
  228. package/ngxs-store.metadata.json +0 -1
  229. package/operators/ngxs-store-operators.metadata.json +0 -1
  230. package/types/index.d.ts +0 -2
@@ -1,341 +0,0 @@
1
- import { __assign } from 'tslib';
2
-
3
- /**
4
- * @fileoverview added by tsickle
5
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6
- */
7
- /**
8
- * @template T
9
- * @param {?} items - Specific items to append to the end of an array
10
- * @return {?}
11
- */
12
- function append(items) {
13
- return (/**
14
- * @param {?} existing
15
- * @return {?}
16
- */
17
- function appendOperator(existing) {
18
- // If `items` is `undefined` or `null` or `[]` but `existing` is provided
19
- // just return `existing`
20
- /** @type {?} */
21
- var itemsNotProvidedButExistingIs = (!items || !items.length) && existing;
22
- if (itemsNotProvidedButExistingIs) {
23
- return (/** @type {?} */ (((/** @type {?} */ (existing)))));
24
- }
25
- if (Array.isArray(existing)) {
26
- return existing.concat((/** @type {?} */ (((/** @type {?} */ (items))))));
27
- }
28
- // For example if some property is added dynamically
29
- // and didn't exist before thus it's not `ArrayLike`
30
- return (/** @type {?} */ (((/** @type {?} */ (items)))));
31
- });
32
- }
33
-
34
- /**
35
- * @fileoverview added by tsickle
36
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
37
- */
38
- /**
39
- * @template T
40
- * @param {...?} operators
41
- * @return {?}
42
- */
43
- function compose() {
44
- var operators = [];
45
- for (var _i = 0; _i < arguments.length; _i++) {
46
- operators[_i] = arguments[_i];
47
- }
48
- return (/**
49
- * @param {?} existing
50
- * @return {?}
51
- */
52
- function composeOperator(existing) {
53
- return operators.reduce((/**
54
- * @param {?} accumulator
55
- * @param {?} operator
56
- * @return {?}
57
- */
58
- function (accumulator, operator) { return operator((/** @type {?} */ (accumulator))); }), (/** @type {?} */ (existing)));
59
- });
60
- }
61
-
62
- /**
63
- * @fileoverview added by tsickle
64
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
65
- */
66
- /**
67
- * @template T
68
- * @param {?} value
69
- * @return {?}
70
- */
71
- function isStateOperator(value) {
72
- return typeof value === 'function';
73
- }
74
- /**
75
- * @param {?} value
76
- * @return {?}
77
- */
78
- function isUndefined(value) {
79
- return typeof value === 'undefined';
80
- }
81
- /**
82
- * @template T
83
- * @param {?} value
84
- * @return {?}
85
- */
86
- function isPredicate(value) {
87
- return typeof value === 'function';
88
- }
89
- /**
90
- * @param {?} value
91
- * @return {?}
92
- */
93
- function isNumber(value) {
94
- return typeof value === 'number';
95
- }
96
- /**
97
- * @param {?} index
98
- * @return {?}
99
- */
100
- function invalidIndex(index) {
101
- return Number.isNaN(index) || index === -1;
102
- }
103
- /**
104
- * @template T
105
- * @param {?} value
106
- * @return {?}
107
- */
108
- function isNil(value) {
109
- return value === null || isUndefined(value);
110
- }
111
-
112
- /**
113
- * @fileoverview added by tsickle
114
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
115
- */
116
- /**
117
- * @template T
118
- * @param {?} operatorOrValue
119
- * @param {?} existing
120
- * @return {?}
121
- */
122
- function retrieveValue(operatorOrValue, existing) {
123
- // If state operator is a function
124
- // then call it with an original value
125
- if (isStateOperator(operatorOrValue)) {
126
- /** @type {?} */
127
- var value = operatorOrValue(existing);
128
- return (/** @type {?} */ (value));
129
- }
130
- // If operator or value was not provided
131
- // e.g. `elseOperatorOrValue` is `undefined`
132
- // then we just return an original value
133
- if (isUndefined(operatorOrValue)) {
134
- return (/** @type {?} */ (existing));
135
- }
136
- return (/** @type {?} */ (operatorOrValue));
137
- }
138
- /**
139
- * @template T
140
- * @param {?} condition - Condition can be a plain boolean value or a function,
141
- * that returns boolean, also this function can take a value as an argument
142
- * to which this state operator applies
143
- * @param {?} trueOperatorOrValue - Any value or a state operator
144
- * @param {?=} elseOperatorOrValue - Any value or a state operator
145
- * @return {?}
146
- */
147
- function iif(condition, trueOperatorOrValue, elseOperatorOrValue) {
148
- return (/**
149
- * @param {?} existing
150
- * @return {?}
151
- */
152
- function iifOperator(existing) {
153
- // Convert the value to a boolean
154
- /** @type {?} */
155
- var result = !!condition;
156
- // but if it is a function then run it to get the result
157
- if (isPredicate(condition)) {
158
- result = condition((/** @type {?} */ (existing)));
159
- }
160
- if (result) {
161
- return retrieveValue((/** @type {?} */ (trueOperatorOrValue)), existing);
162
- }
163
- return retrieveValue((/** @type {?} */ ((/** @type {?} */ (elseOperatorOrValue)))), existing);
164
- });
165
- }
166
-
167
- /**
168
- * @fileoverview added by tsickle
169
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
170
- */
171
- /**
172
- * @template T
173
- * @param {?} value - Value to insert
174
- * @param {?=} beforePosition
175
- * @return {?}
176
- */
177
- function insertItem(value, beforePosition) {
178
- return (/**
179
- * @param {?} existing
180
- * @return {?}
181
- */
182
- function insertItemOperator(existing) {
183
- // Have to check explicitly for `null` and `undefined`
184
- // because `value` can be `0`, thus `!value` will return `true`
185
- if (isNil(value) && existing) {
186
- return (/** @type {?} */ (existing));
187
- }
188
- // Property may be dynamic and might not existed before
189
- if (!Array.isArray(existing)) {
190
- return [(/** @type {?} */ (((/** @type {?} */ (value)))))];
191
- }
192
- /** @type {?} */
193
- var clone = existing.slice();
194
- /** @type {?} */
195
- var index = 0;
196
- // No need to call `isNumber`
197
- // as we are checking `> 0` not `>= 0`
198
- // everything except number will return false here
199
- if ((/** @type {?} */ (beforePosition)) > 0) {
200
- index = (/** @type {?} */ (beforePosition));
201
- }
202
- clone.splice(index, 0, (/** @type {?} */ (((/** @type {?} */ (value))))));
203
- return clone;
204
- });
205
- }
206
-
207
- /**
208
- * @fileoverview added by tsickle
209
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
210
- */
211
- /**
212
- * @template T
213
- * @param {?} patchObject
214
- * @return {?}
215
- */
216
- function patch(patchObject) {
217
- return (/**
218
- * @param {?} existing
219
- * @return {?}
220
- */
221
- function patchStateOperator(existing) {
222
- /** @type {?} */
223
- var clone = null;
224
- for (var k in patchObject) {
225
- /** @type {?} */
226
- var newValue = patchObject[k];
227
- /** @type {?} */
228
- var existingPropValue = existing[k];
229
- /** @type {?} */
230
- var newPropValue = isStateOperator(newValue)
231
- ? newValue((/** @type {?} */ (existingPropValue)))
232
- : newValue;
233
- if (newPropValue !== existingPropValue) {
234
- if (!clone) {
235
- clone = __assign({}, ((/** @type {?} */ (existing))));
236
- }
237
- clone[k] = newPropValue;
238
- }
239
- }
240
- return clone || existing;
241
- });
242
- }
243
-
244
- /**
245
- * @fileoverview added by tsickle
246
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
247
- */
248
- /**
249
- * @template T
250
- * @param {?} selector - Index of item in the array or a predicate function
251
- * that can be provided in `Array.prototype.findIndex`
252
- * @param {?} operatorOrValue - New value under the `selector` index or a
253
- * function that can be applied to an existing value
254
- * @return {?}
255
- */
256
- function updateItem(selector, operatorOrValue) {
257
- return (/**
258
- * @param {?} existing
259
- * @return {?}
260
- */
261
- function updateItemOperator(existing) {
262
- /** @type {?} */
263
- var index = -1;
264
- if (isPredicate(selector)) {
265
- index = existing.findIndex((/** @type {?} */ (selector)));
266
- }
267
- else if (isNumber(selector)) {
268
- index = selector;
269
- }
270
- if (invalidIndex(index)) {
271
- return (/** @type {?} */ (existing));
272
- }
273
- /** @type {?} */
274
- var value = (/** @type {?} */ (null));
275
- // Need to check if the new item value will change the existing item value
276
- // then, only if it will change it then clone the array and set the item
277
- /** @type {?} */
278
- var theOperatorOrValue = (/** @type {?} */ (operatorOrValue));
279
- if (isStateOperator(theOperatorOrValue)) {
280
- value = theOperatorOrValue((/** @type {?} */ (existing[index])));
281
- }
282
- else {
283
- value = theOperatorOrValue;
284
- }
285
- // If the value hasn't been mutated
286
- // then we just return `existing` array
287
- if (value === existing[index]) {
288
- return (/** @type {?} */ (existing));
289
- }
290
- /** @type {?} */
291
- var clone = existing.slice();
292
- clone[index] = (/** @type {?} */ (value));
293
- return clone;
294
- });
295
- }
296
-
297
- /**
298
- * @fileoverview added by tsickle
299
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
300
- */
301
- /**
302
- * @template T
303
- * @param {?} selector - index or predicate to remove an item from an array by
304
- * @return {?}
305
- */
306
- function removeItem(selector) {
307
- return (/**
308
- * @param {?} existing
309
- * @return {?}
310
- */
311
- function removeItemOperator(existing) {
312
- /** @type {?} */
313
- var index = -1;
314
- if (isPredicate(selector)) {
315
- index = existing.findIndex(selector);
316
- }
317
- else if (isNumber(selector)) {
318
- index = selector;
319
- }
320
- if (invalidIndex(index)) {
321
- return (/** @type {?} */ (existing));
322
- }
323
- /** @type {?} */
324
- var clone = existing.slice();
325
- clone.splice(index, 1);
326
- return clone;
327
- });
328
- }
329
-
330
- /**
331
- * @fileoverview added by tsickle
332
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
333
- */
334
-
335
- /**
336
- * @fileoverview added by tsickle
337
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
338
- */
339
-
340
- export { append, compose, iif, insertItem, isStateOperator, patch, removeItem, updateItem };
341
- //# sourceMappingURL=ngxs-store-operators.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ngxs-store-operators.js","sources":["ng://@ngxs/store/operators/append.ts","ng://@ngxs/store/operators/compose.ts","ng://@ngxs/store/operators/utils.ts","ng://@ngxs/store/operators/iif.ts","ng://@ngxs/store/operators/insert-item.ts","ng://@ngxs/store/operators/patch.ts","ng://@ngxs/store/operators/update-item.ts","ng://@ngxs/store/operators/remove-item.ts"],"sourcesContent":["import { ExistingState, NoInfer, StateOperator } from './types';\n\n/**\n * @param items - Specific items to append to the end of an array\n */\nexport function append<T>(items: NoInfer<T[]>): StateOperator<T[]> {\n return function appendOperator(existing: ExistingState<T[]>): T[] {\n // If `items` is `undefined` or `null` or `[]` but `existing` is provided\n // just return `existing`\n const itemsNotProvidedButExistingIs = (!items || !items.length) && existing;\n if (itemsNotProvidedButExistingIs) {\n return (existing as unknown) as T[];\n }\n\n if (Array.isArray(existing)) {\n return existing.concat((items as unknown) as ExistingState<T[]>);\n }\n\n // For example if some property is added dynamically\n // and didn't exist before thus it's not `ArrayLike`\n return (items as unknown) as T[];\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\n\nexport function compose<T>(...operators: NoInfer<StateOperator<T>[]>): StateOperator<T> {\n return function composeOperator(existing: ExistingState<T>): T {\n return operators.reduce(\n (accumulator, operator) => operator(accumulator as ExistingState<T>),\n existing as T\n );\n };\n}\n","import { StateOperator } from './types';\n\nexport type Predicate<T = any> = (value: T | Readonly<T>) => boolean;\n\nexport function isStateOperator<T>(value: T | StateOperator<T>): value is StateOperator<T> {\n return typeof value === 'function';\n}\n\nexport function isUndefined(value: any): value is undefined {\n return typeof value === 'undefined';\n}\n\nexport function isPredicate<T>(value: Predicate<T> | boolean | number): value is Predicate<T> {\n return typeof value === 'function';\n}\n\nexport function isNumber(value: any): value is number {\n return typeof value === 'number';\n}\n\nexport function invalidIndex(index: number): boolean {\n return Number.isNaN(index) || index === -1;\n}\n\nexport function isNil<T>(value: T | null | undefined): value is null | undefined {\n return value === null || isUndefined(value);\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\n\nimport { isStateOperator, isUndefined, isPredicate, Predicate } from './utils';\n\nfunction retrieveValue<T>(\n operatorOrValue: StateOperator<T> | T,\n existing: ExistingState<T>\n): T {\n // If state operator is a function\n // then call it with an original value\n if (isStateOperator(operatorOrValue)) {\n const value = operatorOrValue(existing);\n return value as T;\n }\n\n // If operator or value was not provided\n // e.g. `elseOperatorOrValue` is `undefined`\n // then we just return an original value\n if (isUndefined(operatorOrValue)) {\n return existing as T;\n }\n\n return operatorOrValue as T;\n}\n\n/**\n * @param condition - Condition can be a plain boolean value or a function,\n * that returns boolean, also this function can take a value as an argument\n * to which this state operator applies\n * @param trueOperatorOrValue - Any value or a state operator\n * @param elseOperatorOrValue - Any value or a state operator\n */\nexport function iif<T>(\n condition: NoInfer<Predicate<T>> | boolean,\n trueOperatorOrValue: NoInfer<StateOperator<T> | T>,\n elseOperatorOrValue?: NoInfer<StateOperator<T> | T>\n): StateOperator<T> {\n return function iifOperator(existing: ExistingState<T>): T {\n // Convert the value to a boolean\n let result = !!condition;\n // but if it is a function then run it to get the result\n if (isPredicate(condition)) {\n result = condition(existing as T);\n }\n\n if (result) {\n return retrieveValue<T>(trueOperatorOrValue as StateOperator<T> | T, existing);\n }\n\n return retrieveValue<T>(elseOperatorOrValue! as StateOperator<T> | T, existing);\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\nimport { isNil } from './utils';\n\n/**\n * @param value - Value to insert\n * @param [beforePosition] - Specified index to insert value before, optional\n */\nexport function insertItem<T>(value: NoInfer<T>, beforePosition?: number): StateOperator<T[]> {\n return function insertItemOperator(existing: ExistingState<T[]>): T[] {\n // Have to check explicitly for `null` and `undefined`\n // because `value` can be `0`, thus `!value` will return `true`\n if (isNil(value) && existing) {\n return existing as T[];\n }\n\n // Property may be dynamic and might not existed before\n if (!Array.isArray(existing)) {\n return [(value as unknown) as T];\n }\n\n const clone = existing.slice();\n\n let index = 0;\n\n // No need to call `isNumber`\n // as we are checking `> 0` not `>= 0`\n // everything except number will return false here\n if (beforePosition! > 0) {\n index = beforePosition!;\n }\n\n clone.splice(index, 0, (value as unknown) as T);\n return clone;\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\nimport { isStateOperator } from './utils';\n\ntype NotUndefined<T> = T extends undefined ? never : T;\n\nexport type PatchSpec<T> = { [P in keyof T]?: T[P] | StateOperator<NotUndefined<T[P]>> };\n\nexport function patch<T extends Record<string, any>>(\n patchObject: NoInfer<PatchSpec<T>>\n): StateOperator<T> {\n return function patchStateOperator(existing: ExistingState<T>): T {\n let clone = null;\n for (const k in patchObject) {\n const newValue = patchObject[k];\n const existingPropValue = existing[k];\n const newPropValue = isStateOperator(newValue)\n ? newValue(<any>existingPropValue)\n : newValue;\n if (newPropValue !== existingPropValue) {\n if (!clone) {\n clone = { ...(<any>existing) };\n }\n clone[k] = newPropValue;\n }\n }\n return clone || existing;\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\n\nimport { isStateOperator, isPredicate, isNumber, invalidIndex, Predicate } from './utils';\n\n/**\n * @param selector - Index of item in the array or a predicate function\n * that can be provided in `Array.prototype.findIndex`\n * @param operatorOrValue - New value under the `selector` index or a\n * function that can be applied to an existing value\n */\nexport function updateItem<T>(\n selector: number | NoInfer<Predicate<T>>,\n operatorOrValue: NoInfer<T> | NoInfer<StateOperator<T>>\n): StateOperator<T[]> {\n return function updateItemOperator(existing: ExistingState<T[]>): T[] {\n let index = -1;\n\n if (isPredicate(selector)) {\n index = existing.findIndex(selector as Predicate<T>);\n } else if (isNumber(selector)) {\n index = selector;\n }\n\n if (invalidIndex(index)) {\n return existing as T[];\n }\n\n let value: T = null!;\n // Need to check if the new item value will change the existing item value\n // then, only if it will change it then clone the array and set the item\n const theOperatorOrValue = operatorOrValue as T | StateOperator<T>;\n if (isStateOperator(theOperatorOrValue)) {\n value = theOperatorOrValue(existing[index] as ExistingState<T>);\n } else {\n value = theOperatorOrValue;\n }\n\n // If the value hasn't been mutated\n // then we just return `existing` array\n if (value === existing[index]) {\n return existing as T[];\n }\n\n const clone = existing.slice();\n clone[index] = value as T;\n return clone;\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\nimport { isPredicate, isNumber, invalidIndex, Predicate } from './utils';\n\n/**\n * @param selector - index or predicate to remove an item from an array by\n */\nexport function removeItem<T>(selector: number | NoInfer<Predicate<T>>): StateOperator<T[]> {\n return function removeItemOperator(existing: ExistingState<T[]>): T[] {\n let index = -1;\n\n if (isPredicate(selector)) {\n index = existing.findIndex(selector);\n } else if (isNumber(selector)) {\n index = selector;\n }\n\n if (invalidIndex(index)) {\n return existing as T[];\n }\n\n const clone = existing.slice();\n clone.splice(index, 1);\n return clone;\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAKA,SAAgB,MAAM,CAAI,KAAmB;IAC3C;;;;IAAO,SAAS,cAAc,CAAC,QAA4B;;;;YAGnD,6BAA6B,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ;QAC3E,IAAI,6BAA6B,EAAE;YACjC,8CAAQ,QAAQ,MAAoB;SACrC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC3B,OAAO,QAAQ,CAAC,MAAM,wCAAE,KAAK,MAAmC,CAAC;SAClE;;;QAID,8CAAQ,KAAK,MAAoB;KAClC,EAAC;CACH;;;;;;;;;;;ACpBD,SAAgB,OAAO;IAAI,mBAAyC;SAAzC,UAAyC,EAAzC,qBAAyC,EAAzC,IAAyC;QAAzC,8BAAyC;;IAClE;;;;IAAO,SAAS,eAAe,CAAC,QAA0B;QACxD,OAAO,SAAS,CAAC,MAAM;;;;;QACrB,UAAC,WAAW,EAAE,QAAQ,IAAK,OAAA,QAAQ,oBAAC,WAAW,GAAqB,GAAA,sBACpE,QAAQ,GACT,CAAC;KACH,EAAC;CACH;;;;;;;;;;;ACLD,SAAgB,eAAe,CAAI,KAA2B;IAC5D,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;CACpC;;;;;AAED,SAAgB,WAAW,CAAC,KAAU;IACpC,OAAO,OAAO,KAAK,KAAK,WAAW,CAAC;CACrC;;;;;;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