@ngxs/store 3.7.4-dev.master-af4a196 → 3.7.5

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 (51) hide show
  1. package/bundles/ngxs-store-operators.umd.js +12 -13
  2. package/bundles/ngxs-store-operators.umd.js.map +1 -1
  3. package/bundles/ngxs-store-operators.umd.min.js +1 -1
  4. package/bundles/ngxs-store-operators.umd.min.js.map +1 -1
  5. package/bundles/ngxs-store.umd.js +2 -6
  6. package/bundles/ngxs-store.umd.js.map +1 -1
  7. package/bundles/ngxs-store.umd.min.js.map +1 -1
  8. package/esm2015/operators/append.js +3 -3
  9. package/esm2015/operators/compose.js +1 -1
  10. package/esm2015/operators/iif.js +1 -1
  11. package/esm2015/operators/index.js +1 -1
  12. package/esm2015/operators/insert-item.js +3 -3
  13. package/esm2015/operators/patch.js +5 -4
  14. package/esm2015/operators/update-item.js +5 -7
  15. package/esm2015/operators/utils.js +1 -1
  16. package/esm2015/src/actions-stream.js +3 -1
  17. package/esm2015/src/operators/of-action.js +1 -7
  18. package/esm2015/src/public_api.js +1 -1
  19. package/esm5/operators/append.js +3 -3
  20. package/esm5/operators/compose.js +1 -1
  21. package/esm5/operators/iif.js +1 -1
  22. package/esm5/operators/index.js +1 -1
  23. package/esm5/operators/insert-item.js +3 -3
  24. package/esm5/operators/patch.js +5 -4
  25. package/esm5/operators/update-item.js +5 -7
  26. package/esm5/operators/utils.js +1 -1
  27. package/esm5/src/actions-stream.js +3 -1
  28. package/esm5/src/operators/of-action.js +1 -7
  29. package/esm5/src/public_api.js +1 -1
  30. package/fesm2015/ngxs-store-operators.js +12 -13
  31. package/fesm2015/ngxs-store-operators.js.map +1 -1
  32. package/fesm2015/ngxs-store.js +2 -6
  33. package/fesm2015/ngxs-store.js.map +1 -1
  34. package/fesm5/ngxs-store-operators.js +12 -13
  35. package/fesm5/ngxs-store-operators.js.map +1 -1
  36. package/fesm5/ngxs-store.js +2 -6
  37. package/fesm5/ngxs-store.js.map +1 -1
  38. package/ngxs-store.metadata.json +1 -1
  39. package/operators/append.d.ts +2 -2
  40. package/operators/compose.d.ts +1 -2
  41. package/operators/iif.d.ts +2 -2
  42. package/operators/index.d.ts +1 -1
  43. package/operators/insert-item.d.ts +2 -2
  44. package/operators/ngxs-store-operators.metadata.json +1 -1
  45. package/operators/patch.d.ts +6 -2
  46. package/operators/update-item.d.ts +2 -2
  47. package/operators/utils.d.ts +1 -2
  48. package/package.json +2 -2
  49. package/src/actions-stream.d.ts +1 -1
  50. package/src/operators/of-action.d.ts +7 -20
  51. package/src/public_api.d.ts +1 -1
@@ -23,11 +23,11 @@ function append(items) {
23
23
  return (/** @type {?} */ (existing));
24
24
  }
25
25
  if (Array.isArray(existing)) {
26
- return existing.concat((/** @type {?} */ (((/** @type {?} */ (items))))));
26
+ return existing.concat((/** @type {?} */ (items)));
27
27
  }
28
28
  // For example if some property is added dynamically
29
29
  // and didn't exist before thus it's not `ArrayLike`
30
- return (/** @type {?} */ (((/** @type {?} */ (items)))));
30
+ return (/** @type {?} */ (items));
31
31
  });
32
32
  }
33
33
 
@@ -187,7 +187,7 @@ function insertItem(value, beforePosition) {
187
187
  }
188
188
  // Property may be dynamic and might not existed before
189
189
  if (!Array.isArray(existing)) {
190
- return [(/** @type {?} */ (((/** @type {?} */ (value)))))];
190
+ return [(/** @type {?} */ (value))];
191
191
  }
192
192
  /** @type {?} */
193
193
  var clone = existing.slice();
@@ -199,7 +199,7 @@ function insertItem(value, beforePosition) {
199
199
  if ((/** @type {?} */ (beforePosition)) > 0) {
200
200
  index = (/** @type {?} */ (beforePosition));
201
201
  }
202
- clone.splice(index, 0, (/** @type {?} */ (((/** @type {?} */ (value))))));
202
+ clone.splice(index, 0, (/** @type {?} */ (value)));
203
203
  return clone;
204
204
  });
205
205
  }
@@ -214,7 +214,8 @@ function insertItem(value, beforePosition) {
214
214
  * @return {?}
215
215
  */
216
216
  function patch(patchObject) {
217
- return (/** @type {?} */ (((/** @type {?} */ ((/**
217
+ return (/**
218
+ * @template U
218
219
  * @param {?} existing
219
220
  * @return {?}
220
221
  */
@@ -225,7 +226,7 @@ function patch(patchObject) {
225
226
  /** @type {?} */
226
227
  var newValue = patchObject[k];
227
228
  /** @type {?} */
228
- var existingPropValue = existing[(/** @type {?} */ (k))];
229
+ var existingPropValue = existing[k];
229
230
  /** @type {?} */
230
231
  var newPropValue = isStateOperator(newValue)
231
232
  ? newValue((/** @type {?} */ (existingPropValue)))
@@ -238,7 +239,7 @@ function patch(patchObject) {
238
239
  }
239
240
  }
240
241
  return clone || existing;
241
- }))))));
242
+ });
242
243
  }
243
244
 
244
245
  /**
@@ -262,7 +263,7 @@ function updateItem(selector, operatorOrValue) {
262
263
  /** @type {?} */
263
264
  var index = -1;
264
265
  if (isPredicate(selector)) {
265
- index = existing.findIndex((/** @type {?} */ (selector)));
266
+ index = existing.findIndex(selector);
266
267
  }
267
268
  else if (isNumber(selector)) {
268
269
  index = selector;
@@ -274,13 +275,11 @@ function updateItem(selector, operatorOrValue) {
274
275
  var value = (/** @type {?} */ (null));
275
276
  // Need to check if the new item value will change the existing item value
276
277
  // 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])));
278
+ if (isStateOperator(operatorOrValue)) {
279
+ value = operatorOrValue((/** @type {?} */ (existing[index])));
281
280
  }
282
281
  else {
283
- value = theOperatorOrValue;
282
+ value = operatorOrValue;
284
283
  }
285
284
  // If the value hasn't been mutated
286
285
  // then we just return `existing` array
@@ -1 +1 @@
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, NoInfer } from './utils';\n\n/**\n * @param items - Specific items to append to the end of an array\n */\nexport function append<T>(items: NoInfer<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 unknown) 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 unknown) as RepairType<T>[];\n };\n}\n","import { StateOperator } from '@ngxs/store';\nimport { NoInfer } from './utils';\n\nexport function compose<T>(...operators: NoInfer<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\nexport type NoInfer<T> = T extends infer S ? S : never;\n","import { StateOperator } from '@ngxs/store';\n\nimport { isStateOperator, isUndefined, isPredicate, RepairType, NoInfer } 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: NoInfer<Predicate<T>> | boolean,\n trueOperatorOrValue: NoInfer<StateOperator<T>> | T,\n elseOperatorOrValue?: NoInfer<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, NoInfer } 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: NoInfer<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 unknown) 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 unknown) as RepairType<T>);\n return clone;\n };\n}\n","import { StateOperator } from '@ngxs/store';\nimport { isStateOperator, NoInfer } 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\nexport function patch<T>(patchObject: NoInfer<PatchSpec<T>>): StateOperator<NonNullable<T>> {\n return (function patchStateOperator(existing: Readonly<PatchValues<T>>): NonNullable<T> {\n let clone = null;\n for (const k in patchObject) {\n const newValue = patchObject[k];\n const existingPropValue = existing[k as Extract<keyof T, string>];\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 } as unknown) as StateOperator<NonNullable<T>>;\n}\n","import { StateOperator } from '@ngxs/store';\n\nimport {\n isStateOperator,\n isPredicate,\n isNumber,\n invalidIndex,\n RepairType,\n NoInfer\n} 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 | NoInfer<Predicate<T>>,\n operatorOrValue: NoInfer<T> | NoInfer<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 as Predicate<T>);\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 const theOperatorOrValue = operatorOrValue as T | StateOperator<T>;\n if (isStateOperator(theOperatorOrValue)) {\n value = theOperatorOrValue(existing[index] as Readonly<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 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,KAAmB;IAC3C;;;;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,wCAAE,KAAK,MAAgC,CAAC;SAC/D;;;QAID,8CAAQ,KAAK,MAAgC;KAC9C,EAAC;CACH;;;;;;;;;;;ACpBD,SAAgB,OAAO;IAAI,mBAAyC;SAAzC,UAAyC,EAAzC,qBAAyC,EAAzC,IAAyC;QAAzC,8BAAyC;;IAClE;;;;IAAO,SAAS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Q,CAAC,EAAE;YACzB,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;SACtC;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC7B,KAAK,GAAG,QAAQ,CAAC;SAClB;QAED,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;YACvB,0BAAO,QAAQ,GAAoB;SACpC;;YAEK,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE;QAC9B,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;KACd,EAAC;CACH;;;;;;;;;;;;;;"}
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;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,CAAC,KAAK,EAAE;QAC9B,KAAK,CAAC,KAAK,CAAC,sBAAG,KAAK,EAAiB,CAAC;QACtC,OAAO,KAAK,CAAC;KACd,EAAC;CACH;;;;;;AC7CD;;;;;AAKA,SAAgB,UAAU,CACxB,QAA+B;IAE/B;;;;IAAO,SAAS,kBAAkB,CAAC,QAAmC;;YAChE,KAAK,GAAG,CAAC,CAAC;QAEd,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE;YACzB,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;SACtC;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC7B,KAAK,GAAG,QAAQ,CAAC;SAClB;QAED,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;YACvB,0BAAO,QAAQ,GAAoB;SACpC;;YAEK,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE;QAC9B,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;KACd,EAAC;CACH;;;;;;;;;;;;;;"}
@@ -1174,7 +1174,6 @@ if (false) {
1174
1174
  * RxJS operator for selecting out specific actions.
1175
1175
  *
1176
1176
  * This will grab actions that have just been dispatched as well as actions that have completed
1177
- * @template T
1178
1177
  * @param {...?} allowedTypes
1179
1178
  * @return {?}
1180
1179
  */
@@ -1189,7 +1188,6 @@ function ofAction() {
1189
1188
  * RxJS operator for selecting out specific actions.
1190
1189
  *
1191
1190
  * This will ONLY grab actions that have just been dispatched
1192
- * @template T
1193
1191
  * @param {...?} allowedTypes
1194
1192
  * @return {?}
1195
1193
  */
@@ -1204,7 +1202,6 @@ function ofActionDispatched() {
1204
1202
  * RxJS operator for selecting out specific actions.
1205
1203
  *
1206
1204
  * This will ONLY grab actions that have just been successfully completed
1207
- * @template T
1208
1205
  * @param {...?} allowedTypes
1209
1206
  * @return {?}
1210
1207
  */
@@ -1219,7 +1216,6 @@ function ofActionSuccessful() {
1219
1216
  * RxJS operator for selecting out specific actions.
1220
1217
  *
1221
1218
  * This will ONLY grab actions that have just been canceled
1222
- * @template T
1223
1219
  * @param {...?} allowedTypes
1224
1220
  * @return {?}
1225
1221
  */
@@ -1234,7 +1230,6 @@ function ofActionCanceled() {
1234
1230
  * RxJS operator for selecting out specific actions.
1235
1231
  *
1236
1232
  * This will ONLY grab actions that have just been completed
1237
- * @template T
1238
1233
  * @param {...?} allowedTypes
1239
1234
  * @return {?}
1240
1235
  */
@@ -1255,7 +1250,6 @@ function ofActionCompleted() {
1255
1250
  * RxJS operator for selecting out specific actions.
1256
1251
  *
1257
1252
  * This will ONLY grab actions that have just thrown an error
1258
- * @template T
1259
1253
  * @param {...?} allowedTypes
1260
1254
  * @return {?}
1261
1255
  */
@@ -1604,6 +1598,8 @@ var InternalActions = /** @class */ (function (_super) {
1604
1598
  */
1605
1599
  var Actions = /** @class */ (function (_super) {
1606
1600
  __extends(Actions, _super);
1601
+ // This has to be `Observable<ActionContext>` in the v4. Because `InternalActions`
1602
+ // is a `Subject<ActionContext>`. Leave it as `any` to avoid breaking changes
1607
1603
  function Actions(internalActions$, internalExecutionStrategy) {
1608
1604
  return _super.call(this, (/**
1609
1605
  * @param {?} observer