@ngxs/store 3.7.6 → 3.8.0-dev.master-c341c15

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/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 +62 -402
  6. package/bundles/ngxs-store-operators.umd.js.map +1 -1
  7. package/bundles/ngxs-store.umd.js +1296 -3219
  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 -22
  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 +2 -6
  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 -23
  35. package/esm2015/operators/remove-item.js +5 -17
  36. package/esm2015/operators/types.js +2 -0
  37. package/esm2015/operators/update-item.js +13 -25
  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 +20 -122
  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 +11 -38
  48. package/esm2015/src/decorators/selector/symbols.js +2 -5
  49. package/esm2015/src/decorators/selector-options.js +6 -19
  50. package/esm2015/src/decorators/state.js +5 -44
  51. package/esm2015/src/dev-features/ngxs-development.module.js +22 -0
  52. package/esm2015/src/dev-features/ngxs-unhandled-actions-logger.js +46 -0
  53. package/esm2015/src/dev-features/symbols.js +6 -0
  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/custom-rxjs-subjects.js +81 -0
  59. package/esm2015/src/internal/dispatcher.js +26 -121
  60. package/esm2015/src/internal/error-handler.js +18 -72
  61. package/esm2015/src/internal/internals.js +24 -244
  62. package/esm2015/src/internal/lifecycle-state-manager.js +19 -117
  63. package/esm2015/src/internal/state-context-factory.js +8 -66
  64. package/esm2015/src/internal/state-factory.js +60 -227
  65. package/esm2015/src/internal/state-operations.js +19 -80
  66. package/esm2015/src/internal/state-operators.js +15 -28
  67. package/esm2015/src/internal/state-stream.js +9 -15
  68. package/esm2015/src/ivy/ivy-enabled-in-dev-mode.js +7 -17
  69. package/esm2015/src/module.js +12 -47
  70. package/esm2015/src/modules/ngxs-feature.module.js +18 -36
  71. package/esm2015/src/modules/ngxs-root.module.js +18 -26
  72. package/esm2015/src/operators/leave-ngxs.js +8 -43
  73. package/esm2015/src/operators/of-action.js +16 -105
  74. package/esm2015/src/plugin-manager.js +17 -50
  75. package/esm2015/src/plugin_api.js +1 -5
  76. package/esm2015/src/private_api.js +3 -0
  77. package/esm2015/src/public_api.js +7 -9
  78. package/esm2015/src/public_to_deprecate.js +1 -51
  79. package/esm2015/src/selectors/create-model-selector.js +28 -0
  80. package/esm2015/src/selectors/create-pick-selector.js +14 -0
  81. package/esm2015/src/selectors/create-property-selectors.js +18 -0
  82. package/esm2015/src/selectors/create-selector.js +9 -0
  83. package/esm2015/src/selectors/index.js +6 -0
  84. package/esm2015/src/selectors/selector-checks.util.js +18 -0
  85. package/esm2015/src/selectors/selector-metadata.js +30 -0
  86. package/esm2015/src/selectors/selector-models.js +2 -0
  87. package/esm2015/src/selectors/selector-types.util.js +2 -0
  88. package/esm2015/src/selectors/selector-utils.js +74 -0
  89. package/esm2015/src/state-token/state-token.js +4 -32
  90. package/esm2015/src/state-token/symbols.js +2 -5
  91. package/esm2015/src/store.js +24 -108
  92. package/esm2015/src/symbols.js +7 -177
  93. package/esm2015/src/utils/compose.js +5 -23
  94. package/esm2015/src/utils/freeze.js +5 -20
  95. package/esm2015/src/utils/store-validators.js +3 -36
  96. package/esm2015/src/utils/utils.js +13 -64
  97. package/fesm2015/ngxs-store-internals-testing.js +38 -159
  98. package/fesm2015/ngxs-store-internals-testing.js.map +1 -1
  99. package/fesm2015/ngxs-store-internals.js +18 -100
  100. package/fesm2015/ngxs-store-internals.js.map +1 -1
  101. package/fesm2015/ngxs-store-operators.js +54 -186
  102. package/fesm2015/ngxs-store-operators.js.map +1 -1
  103. package/fesm2015/ngxs-store.js +662 -2488
  104. package/fesm2015/ngxs-store.js.map +1 -1
  105. package/index.d.ts +4 -0
  106. package/internals/index.d.ts +1 -1
  107. package/internals/internal-tokens.d.ts +2 -8
  108. package/internals/ngxs-bootstrapper.d.ts +4 -1
  109. package/internals/ngxs-store-internals.d.ts +1 -0
  110. package/internals/package.json +2 -5
  111. package/internals/testing/helpers/ngxs-test.component.d.ts +3 -0
  112. package/internals/testing/helpers/ngxs-test.module.d.ts +6 -0
  113. package/internals/testing/ngxs-store-internals-testing.d.ts +1 -0
  114. package/internals/testing/package.json +2 -5
  115. package/ngxs-store.d.ts +1 -17
  116. package/operators/append.d.ts +2 -3
  117. package/operators/compose.d.ts +2 -2
  118. package/operators/iif.d.ts +3 -4
  119. package/operators/index.d.ts +3 -2
  120. package/operators/insert-item.d.ts +2 -3
  121. package/operators/ngxs-store-operators.d.ts +1 -0
  122. package/operators/package.json +2 -5
  123. package/operators/patch.d.ts +5 -8
  124. package/operators/remove-item.d.ts +3 -4
  125. package/operators/types.d.ts +56 -0
  126. package/operators/update-item.d.ts +3 -4
  127. package/operators/utils.d.ts +2 -3
  128. package/package.json +4 -7
  129. package/src/actions/actions.d.ts +2 -2
  130. package/src/actions-stream.d.ts +8 -22
  131. package/src/decorators/select/select-factory.d.ts +3 -0
  132. package/src/decorators/selector/selector.d.ts +7 -2
  133. package/src/decorators/state.d.ts +1 -1
  134. package/src/dev-features/ngxs-development.module.d.ts +9 -0
  135. package/src/dev-features/ngxs-unhandled-actions-logger.d.ts +17 -0
  136. package/src/dev-features/symbols.d.ts +8 -0
  137. package/src/execution/dispatch-outside-zone-ngxs-execution-strategy.d.ts +3 -0
  138. package/src/execution/internal-ngxs-execution-strategy.d.ts +3 -0
  139. package/src/execution/noop-ngxs-execution-strategy.d.ts +3 -0
  140. package/src/internal/custom-rxjs-subjects.d.ts +37 -0
  141. package/src/internal/dispatcher.d.ts +5 -0
  142. package/src/internal/error-handler.d.ts +4 -1
  143. package/src/internal/lifecycle-state-manager.d.ts +3 -0
  144. package/src/internal/state-context-factory.d.ts +3 -0
  145. package/src/internal/state-factory.d.ts +7 -4
  146. package/src/internal/state-operations.d.ts +3 -0
  147. package/src/internal/state-operators.d.ts +2 -2
  148. package/src/internal/state-stream.d.ts +5 -2
  149. package/src/module.d.ts +4 -0
  150. package/src/modules/ngxs-feature.module.d.ts +4 -0
  151. package/src/modules/ngxs-root.module.d.ts +4 -0
  152. package/src/operators/of-action.d.ts +20 -7
  153. package/src/plugin-manager.d.ts +4 -1
  154. package/src/private_api.d.ts +2 -0
  155. package/src/public_api.d.ts +8 -5
  156. package/src/selectors/create-model-selector.d.ts +10 -0
  157. package/src/selectors/create-pick-selector.d.ts +6 -0
  158. package/src/selectors/create-property-selectors.d.ts +5 -0
  159. package/src/selectors/create-selector.d.ts +19 -0
  160. package/src/selectors/index.d.ts +5 -0
  161. package/src/selectors/selector-checks.util.d.ts +9 -0
  162. package/src/selectors/selector-metadata.d.ts +7 -0
  163. package/src/selectors/selector-models.d.ts +10 -0
  164. package/src/selectors/selector-types.util.d.ts +7 -0
  165. package/src/selectors/selector-utils.d.ts +9 -0
  166. package/src/store.d.ts +3 -0
  167. package/src/symbols.d.ts +7 -3
  168. package/src/utils/utils.d.ts +1 -1
  169. package/bundles/ngxs-store-internals-testing.umd.min.js +0 -16
  170. package/bundles/ngxs-store-internals-testing.umd.min.js.map +0 -1
  171. package/bundles/ngxs-store-internals.umd.min.js +0 -2
  172. package/bundles/ngxs-store-internals.umd.min.js.map +0 -1
  173. package/bundles/ngxs-store-operators.umd.min.js +0 -16
  174. package/bundles/ngxs-store-operators.umd.min.js.map +0 -1
  175. package/bundles/ngxs-store.umd.min.js +0 -16
  176. package/bundles/ngxs-store.umd.min.js.map +0 -1
  177. package/esm2015/operators/internals.js +0 -5
  178. package/esm2015/src/utils/selector-utils.js +0 -221
  179. package/esm5/index.js +0 -13
  180. package/esm5/internals/angular.js +0 -20
  181. package/esm5/internals/index.js +0 -10
  182. package/esm5/internals/initial-state.js +0 -45
  183. package/esm5/internals/internal-tokens.js +0 -16
  184. package/esm5/internals/memoize.js +0 -71
  185. package/esm5/internals/ngxs-bootstrapper.js +0 -56
  186. package/esm5/internals/ngxs-store-internals.js +0 -9
  187. package/esm5/internals/src/symbols.js +0 -14
  188. package/esm5/internals/symbols.js +0 -14
  189. package/esm5/internals/testing/fresh-platform.js +0 -121
  190. package/esm5/internals/testing/helpers/ngxs-test.component.js +0 -32
  191. package/esm5/internals/testing/helpers/ngxs-test.module.js +0 -32
  192. package/esm5/internals/testing/index.js +0 -8
  193. package/esm5/internals/testing/ngxs-store-internals-testing.js +0 -9
  194. package/esm5/internals/testing/ngxs.setup.js +0 -98
  195. package/esm5/internals/testing/skip-console-logging.js +0 -62
  196. package/esm5/internals/testing/symbol.js +0 -29
  197. package/esm5/ngxs-store.js +0 -25
  198. package/esm5/operators/append.js +0 -31
  199. package/esm5/operators/compose.js +0 -28
  200. package/esm5/operators/iif.js +0 -56
  201. package/esm5/operators/index.js +0 -18
  202. package/esm5/operators/insert-item.js +0 -41
  203. package/esm5/operators/internals.js +0 -5
  204. package/esm5/operators/ngxs-store-operators.js +0 -9
  205. package/esm5/operators/patch.js +0 -40
  206. package/esm5/operators/remove-item.js +0 -34
  207. package/esm5/operators/update-item.js +0 -52
  208. package/esm5/operators/utils.js +0 -50
  209. package/esm5/src/actions/actions.js +0 -62
  210. package/esm5/src/actions/symbols.js +0 -39
  211. package/esm5/src/actions-stream.js +0 -203
  212. package/esm5/src/configs/messages.config.js +0 -79
  213. package/esm5/src/decorators/action.js +0 -60
  214. package/esm5/src/decorators/select/select-factory.js +0 -46
  215. package/esm5/src/decorators/select/select.js +0 -50
  216. package/esm5/src/decorators/select/symbols.js +0 -51
  217. package/esm5/src/decorators/selector/selector.js +0 -59
  218. package/esm5/src/decorators/selector/symbols.js +0 -5
  219. package/esm5/src/decorators/selector-options.js +0 -34
  220. package/esm5/src/decorators/state.js +0 -78
  221. package/esm5/src/execution/dispatch-outside-zone-ngxs-execution-strategy.js +0 -123
  222. package/esm5/src/execution/internal-ngxs-execution-strategy.js +0 -54
  223. package/esm5/src/execution/noop-ngxs-execution-strategy.js +0 -43
  224. package/esm5/src/execution/symbols.js +0 -52
  225. package/esm5/src/internal/dispatcher.js +0 -231
  226. package/esm5/src/internal/error-handler.js +0 -125
  227. package/esm5/src/internal/internals.js +0 -470
  228. package/esm5/src/internal/lifecycle-state-manager.js +0 -224
  229. package/esm5/src/internal/state-context-factory.js +0 -135
  230. package/esm5/src/internal/state-factory.js +0 -583
  231. package/esm5/src/internal/state-operations.js +0 -134
  232. package/esm5/src/internal/state-operators.js +0 -34
  233. package/esm5/src/internal/state-stream.js +0 -37
  234. package/esm5/src/ivy/ivy-enabled-in-dev-mode.js +0 -28
  235. package/esm5/src/module.js +0 -202
  236. package/esm5/src/modules/ngxs-feature.module.js +0 -65
  237. package/esm5/src/modules/ngxs-root.module.js +0 -44
  238. package/esm5/src/operators/leave-ngxs.js +0 -58
  239. package/esm5/src/operators/of-action.js +0 -217
  240. package/esm5/src/plugin-manager.js +0 -82
  241. package/esm5/src/plugin_api.js +0 -10
  242. package/esm5/src/public_api.js +0 -29
  243. package/esm5/src/public_to_deprecate.js +0 -64
  244. package/esm5/src/state-token/state-token.js +0 -57
  245. package/esm5/src/state-token/symbols.js +0 -5
  246. package/esm5/src/store.js +0 -241
  247. package/esm5/src/symbols.js +0 -230
  248. package/esm5/src/utils/compose.js +0 -55
  249. package/esm5/src/utils/freeze.js +0 -35
  250. package/esm5/src/utils/selector-utils.js +0 -230
  251. package/esm5/src/utils/store-validators.js +0 -78
  252. package/esm5/src/utils/utils.js +0 -151
  253. package/fesm5/ngxs-store-internals-testing.js +0 -345
  254. package/fesm5/ngxs-store-internals-testing.js.map +0 -1
  255. package/fesm5/ngxs-store-internals.js +0 -217
  256. package/fesm5/ngxs-store-internals.js.map +0 -1
  257. package/fesm5/ngxs-store-operators.js +0 -340
  258. package/fesm5/ngxs-store-operators.js.map +0 -1
  259. package/fesm5/ngxs-store.js +0 -4619
  260. package/fesm5/ngxs-store.js.map +0 -1
  261. package/internals/ngxs-store-internals.metadata.json +0 -1
  262. package/internals/testing/ngxs-store-internals-testing.metadata.json +0 -1
  263. package/ngxs-store.metadata.json +0 -1
  264. package/operators/internals.d.ts +0 -2
  265. package/operators/ngxs-store-operators.metadata.json +0 -1
  266. package/src/utils/selector-utils.d.ts +0 -23
  267. package/types/index.d.ts +0 -2
@@ -1,340 +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 {?} */ (existing));
24
- }
25
- if (Array.isArray(existing)) {
26
- return existing.concat((/** @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 {?} */ (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(accumulator); }), 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((/** @type {?} */ ((/** @type {?} */ (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 {?} */ ((/** @type {?} */ (((/** @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(existing);
159
- }
160
- if (result) {
161
- return retrieveValue(trueOperatorOrValue, (/** @type {?} */ (existing)));
162
- }
163
- return retrieveValue((/** @type {?} */ (elseOperatorOrValue)), (/** @type {?} */ (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 {?} */ (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 {?} */ (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
- * @template U
219
- * @param {?} existing
220
- * @return {?}
221
- */
222
- function patchStateOperator(existing) {
223
- /** @type {?} */
224
- var clone = null;
225
- for (var k in patchObject) {
226
- /** @type {?} */
227
- var newValue = patchObject[k];
228
- /** @type {?} */
229
- var existingPropValue = existing[k];
230
- /** @type {?} */
231
- var newPropValue = isStateOperator(newValue)
232
- ? newValue((/** @type {?} */ (existingPropValue)))
233
- : newValue;
234
- if (newPropValue !== existingPropValue) {
235
- if (!clone) {
236
- clone = __assign({}, ((/** @type {?} */ (existing))));
237
- }
238
- clone[k] = newPropValue;
239
- }
240
- }
241
- return clone || existing;
242
- });
243
- }
244
-
245
- /**
246
- * @fileoverview added by tsickle
247
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
248
- */
249
- /**
250
- * @template T
251
- * @param {?} selector - Index of item in the array or a predicate function
252
- * that can be provided in `Array.prototype.findIndex`
253
- * @param {?} operatorOrValue - New value under the `selector` index or a
254
- * function that can be applied to an existing value
255
- * @return {?}
256
- */
257
- function updateItem(selector, operatorOrValue) {
258
- return (/**
259
- * @param {?} existing
260
- * @return {?}
261
- */
262
- function updateItemOperator(existing) {
263
- /** @type {?} */
264
- var index = -1;
265
- if (isPredicate(selector)) {
266
- index = existing.findIndex(selector);
267
- }
268
- else if (isNumber(selector)) {
269
- index = selector;
270
- }
271
- if (invalidIndex(index)) {
272
- return (/** @type {?} */ (existing));
273
- }
274
- /** @type {?} */
275
- var value = (/** @type {?} */ (null));
276
- // Need to check if the new item value will change the existing item value
277
- // then, only if it will change it then clone the array and set the item
278
- if (isStateOperator(operatorOrValue)) {
279
- value = operatorOrValue((/** @type {?} */ (existing[index])));
280
- }
281
- else {
282
- value = operatorOrValue;
283
- }
284
- // If the value hasn't been mutated
285
- // then we just return `existing` array
286
- if (value === existing[index]) {
287
- return (/** @type {?} */ (existing));
288
- }
289
- /** @type {?} */
290
- var clone = existing.slice();
291
- clone[index] = (/** @type {?} */ (value));
292
- return clone;
293
- });
294
- }
295
-
296
- /**
297
- * @fileoverview added by tsickle
298
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
299
- */
300
- /**
301
- * @template T
302
- * @param {?} selector - index or predicate to remove an item from an array by
303
- * @return {?}
304
- */
305
- function removeItem(selector) {
306
- return (/**
307
- * @param {?} existing
308
- * @return {?}
309
- */
310
- function removeItemOperator(existing) {
311
- /** @type {?} */
312
- var index = -1;
313
- if (isPredicate(selector)) {
314
- index = existing.findIndex(selector);
315
- }
316
- else if (isNumber(selector)) {
317
- index = selector;
318
- }
319
- if (invalidIndex(index)) {
320
- return (/** @type {?} */ (existing));
321
- }
322
- /** @type {?} */
323
- var clone = existing.slice();
324
- clone.splice(index, 1);
325
- return clone;
326
- });
327
- }
328
-
329
- /**
330
- * @fileoverview added by tsickle
331
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
332
- */
333
-
334
- /**
335
- * @fileoverview added by tsickle
336
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
337
- */
338
-
339
- export { append, compose, iif, insertItem, isStateOperator, patch, removeItem, updateItem };
340
- //# 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 { StateOperator } from '@ngxs/store';\nimport { RepairType } from './utils';\n\n/**\n * @param items - Specific items to append to the end of an array\n */\nexport function append<T>(items: T[]): StateOperator<RepairType<T>[]> {\n return function appendOperator(existing: Readonly<RepairType<T>[]>): RepairType<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 RepairType<T>[];\n }\n\n if (Array.isArray(existing)) {\n return existing.concat(items as RepairType<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 RepairType<T>[];\n };\n}\n","import { StateOperator } from '@ngxs/store';\n\nexport function compose<T>(...operators: StateOperator<T>[]): StateOperator<T> {\n return function composeOperator(existing: Readonly<T>): T {\n return operators.reduce((accumulator, operator) => operator(accumulator), existing);\n };\n}\n","import { StateOperator } from '@ngxs/store';\n\nimport { Predicate } from './internals';\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\nexport type RepairType<T> = T extends true ? boolean : (T extends false ? boolean : T);\n","import { StateOperator } from '@ngxs/store';\n\nimport { isStateOperator, isUndefined, isPredicate, RepairType } from './utils';\nimport { Predicate } from './internals';\n\nfunction retrieveValue<T>(\n operatorOrValue: StateOperator<T> | T,\n existing?: Readonly<RepairType<T>>\n): RepairType<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! as Readonly<T>);\n return value as RepairType<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 (<any>existing)! as RepairType<T>;\n }\n\n return operatorOrValue as RepairType<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: Predicate<T> | boolean,\n trueOperatorOrValue: StateOperator<T> | T,\n elseOperatorOrValue?: StateOperator<T> | T\n): StateOperator<RepairType<T>> {\n return function iifOperator(existing: Readonly<RepairType<T>>): RepairType<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);\n }\n\n if (result) {\n return retrieveValue<T>(trueOperatorOrValue, existing as RepairType<T>);\n }\n\n return retrieveValue<T>(elseOperatorOrValue!, existing as RepairType<T>);\n };\n}\n","import { StateOperator } from '@ngxs/store';\nimport { isNil, RepairType } 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>(\n value: T,\n beforePosition?: number\n): StateOperator<RepairType<T>[]> {\n return function insertItemOperator(existing: Readonly<RepairType<T>[]>): RepairType<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 RepairType<T>[];\n }\n\n // Property may be dynamic and might not existed before\n if (!Array.isArray(existing)) {\n return [value as RepairType<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 RepairType<T>);\n return clone;\n };\n}\n","import { StateOperator } from '@ngxs/store';\nimport { isStateOperator } from './utils';\n\nexport type PatchSpec<T> = { [P in keyof T]?: T[P] | StateOperator<NonNullable<T[P]>> };\n\ntype PatchValues<T> = {\n readonly [P in keyof T]?: T[P] extends (...args: any[]) => infer R ? R : T[P];\n};\n\ntype PatchOperator<T> = <U extends PatchValues<T>>(existing: Readonly<U>) => U;\n\nexport function patch<T>(patchObject: PatchSpec<T>): PatchOperator<T> {\n return function patchStateOperator<U extends PatchValues<T>>(existing: Readonly<U>): U {\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 { StateOperator } from '@ngxs/store';\n\nimport { isStateOperator, isPredicate, isNumber, invalidIndex, RepairType } from './utils';\nimport { Predicate } from './internals';\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 | Predicate<T>,\n operatorOrValue: T | StateOperator<T>\n): StateOperator<RepairType<T>[]> {\n return function updateItemOperator(existing: Readonly<RepairType<T>[]>): RepairType<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 RepairType<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 if (isStateOperator(operatorOrValue)) {\n value = operatorOrValue(existing[index] as Readonly<T>);\n } else {\n value = operatorOrValue;\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 RepairType<T>[];\n }\n\n const clone = existing.slice();\n clone[index] = value as RepairType<T>;\n return clone;\n };\n}\n","import { StateOperator } from '@ngxs/store';\nimport { Predicate } from './internals';\nimport { isPredicate, isNumber, invalidIndex, RepairType } from './utils';\n\n/**\n * @param selector - index or predicate to remove an item from an array by\n */\nexport function removeItem<T>(\n selector: number | Predicate<T>\n): StateOperator<RepairType<T>[]> {\n return function removeItemOperator(existing: Readonly<RepairType<T>[]>): RepairType<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 RepairType<T>[];\n }\n\n const clone = existing.slice();\n clone.splice(index, 1);\n return clone;\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAMA,SAAgB,MAAM,CAAI,KAAU;IAClC;;;;IAAO,SAAS,cAAc,CAAC,QAAmC;;;;YAG1D,6BAA6B,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ;QAC3E,IAAI,6BAA6B,EAAE;YACjC,0BAAO,QAAQ,GAAoB;SACpC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC3B,OAAO,QAAQ,CAAC,MAAM,oBAAC,KAAK,GAAoB,CAAC;SAClD;;;QAID,0BAAO,KAAK,GAAoB;KACjC,EAAC;CACH;;;;;;;;;;;ACrBD,SAAgB,OAAO;IAAI,mBAAgC;SAAhC,UAAgC,EAAhC,qBAAgC,EAAhC,IAAgC;QAAhC,8BAAgC;;IACzD;;;;IAAO,SAAS,eAAe,CAAC,QAAqB;QACnD,OAAO,SAAS,CAAC,MAAM;;;;;QAAC,UAAC,WAAW,EAAE,QAAQ,IAAK,OAAA,QAAQ,CAAC,WAAW,CAAC,GAAA,GAAE,QAAQ,CAAC,CAAC;KACrF,EAAC;CACH;;;;;;;;;;;ACFD,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;;;;;;AAED,SAAgB,WAAW,CAAI,KAAsC;IACnE,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;CACpC;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