0.0.2 • Published 7 years ago
action-processor v0.0.2
action-processor
Simple utility to run a series of functions over an initial state and return the end state.
Supports async functions which will be waited upon before the next action, to ensure actions are completed sequentially.
Supports ignoring failed actions .
Installation
npm i -S action-processorUsage
action-processor exposes a simple API:
const {run} = require('action-processor');
const result = run(initialState, actions, opts);Where:
initialStateis any value. It will be passed as the only argument to the first item inactions.actionsis an array of functions or async functions (or a mixture). Each function should take one argument:previousStateand return the next state to pass to the next action function (or be returned in the case of the last action).optsis an object with the following settings:continueOnFailure(default:false): If set to true, any action invocation which throws an error will be skipped, and the chain will continue as if that action were not included.