Ticks Tracer
Takes snapshots for an object across event loop ticks.
Hint
Good for testing flow control packages like flowa
, async
, q
, etc.
Table of Contents
Installation
npm install --save ticks-tracer
Usage
Take snapshot on every check
phase of the event loop (using setImmediate
internally).
var TicksTracer = ; // A flow control packagevar Flowa = ; // The object to tracevar context = {}; // A dummy flowvar flow = type: 'serial' task1: task2: group1: type: 'parallel' task3: task4: task5: ; // Start tracingvar ticksTracer = context; // Execute the tasksflow; // Don't worry about this { return { context'task' + id = true; ; }; }
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 }
]
API
- TicksTracer(tracedObject)
To create a TicksTracer object and start tracing
- stop()
Stop tracing
- getTicksCount() ⇒
Number
Get the current tick number
- getSnapshotAt(tick) ⇒
Object
Get a taken snapshot by a tick number
- getSnapshots() ⇒
Array
Get all taken snapshots indexed by ticks numbers
- getSnapshotsDiffs() ⇒
Array
Get a list of snapshots that represent only the diffs
TicksTracer(tracedObject)
To create a TicksTracer object and start tracing.
Param | Type | Description |
---|---|---|
tracedObject | Object |
The object to take snapshots of |
stop()
Stop tracing.
Number
getTicksCount() ⇒ Get the current tick number.
Returns: Number
Object
getSnapshotAt(tick) ⇒ Get a taken snapshot by a tick number.
Param | Type | Description |
---|---|---|
tick | Number |
The tick number |
Returns: Object
Array
getSnapshots() ⇒ Get all taken snapshots indexed by ticks numbers.
Returns: Array
Array
getSnapshotsDiffs() ⇒ Get a list of snapshots that represent only the diffs
Returns: Array
License
This project is under the MIT license.