applyStateChanges.ts 216 B

1234567
  1. export type MutateStateFunc<S> = (state: S) => S;
  2. export const applyStateChanges = <S>(state: S, ...args: Array<MutateStateFunc<S>>): S => {
  3. return args.reduce((all, cur) => {
  4. return cur(all);
  5. }, state);
  6. };