takes snapshots for an object across event loop ticks
npm install ticks-tracer

> Takes snapshots for an object across event loop ticks.
Good for testing flow control packages like flowa, async, q, etc.
* Installation
* Usage
* API
* License
```
npm install --save ticks-tracer
Take snapshot on every check phase of the event loop (using setImmediate internally).
`js
var TicksTracer = require('ticks-tracer');
// A flow control package
var Flowa = require('flowa');
// The object to trace
var context = {};
// A dummy flow
var flow = new Flowa({
type: 'serial',
task1: generateDummyTask(1),
task2: generateDummyTask(2),
group1: {
type: 'parallel',
task3: generateDummyTask(3),
task4: generateDummyTask(4)
},
task5: generateDummyTask(5)
});
// Start tracing
var ticksTracer = new TicksTracer(context);
// Execute the tasks
flow.run(context).then(function(result) {
// Get the taken snapshots
console.log(ticksTracer.getSnapshots());
console.log(ticksTracer.getSnapshotsDiffs());
// Stop the tracing
ticksTracer.stop();
});
// Don't worry about this
function generateDummyTask(id) {
return function(context, callback) {
context['task' + id] = true;
setImmediate(callback);
};
}
`
The output is:
```
[
{},
{ task1: true },
{ task1: true, task2: true },
{ task1: true, task2: true, task3: true, task4: true },
{ task1: true, task2: true, task3: true, task4: true, task5: true }
]
To create a TicksTracer object and start tracing
Stop tracing
NumberGet the current tick number
ObjectGet a taken snapshot by a tick number
ArrayGet all taken snapshots indexed by ticks numbers
ArrayGet a list of snapshots that represent only the diffs
To create a TicksTracer object and start tracing.
| Param | Type | Description |
|--------------|---------------------|---------------------------------|
| tracedObject | Object | The object to take snapshots of |
Stop tracing.
NumberGet the current tick number.
Returns: Number
ObjectGet a taken snapshot by a tick number.
| Param | Type | Description |
|-------|---------------------|---------------------------------|
| tick | Number | The tick number |
Returns: Object
ArrayGet all taken snapshots indexed by ticks numbers.
Returns: Array
ArrayGet a list of snapshots that represent only the diffs
Returns: Array
This project is under the MIT license.