Compares objects and runs appropriate code for each change found (node.js).
Makes it easy to compare objects and based on the differences decide what code to run.
var changeProcessor = require'./../lib/changeProcessor'var personChangeProcessor = changeProcessorthisonChange"name"// NOTE - Here we might do something like send a message, trigger an authorisation process...console.log"changed - name";done;;thisonChange"name.first"console.log"changed - name.first";done;;var original =name :first: "Bob"second: "Marshall"var updated =name :first: "Robert" // NOTE - Different valuesecond: "Marshall"varconsole.log"all done.";personChangeProcessororiginal updated allDone;
The output from this will be
changed - namechanged - name.firstall done
Note even though we only changed
name.first the event for
name was raised too.
The project comes with examples in the examples directory:
node examples/simple node examples/allinOneFile
First install mocha:
npm install mocha -g
Run the tests using
npm test or:
mocha -R spec spec/testFixture spec/ -w -G --recursive
- A change to a property could trigger further changes and we should probably then call their appropriate handlers (avoiding cycles).
- Suitable reporting of errors that occur inside
- Optional built-in logging using winston.