Skip to content

Combinations

dumpkit places no limits on your creativity. All functions are independent and pure – you can use them in any order, inside conditionals, loops, or combined with native Node.js code.

The combinations listed below are just examples to illustrate the composable spirit of the library. In practice, you can create countless others.


Examples of combinations

Dump with stack trace

js
dump(value);
trace();

Dump with timing

js
const { result } = measure('operation', () => fn());
dump(result);

Dump with tree view

js
dump(structure, { view: 'tree' });

Dump with table view

js
dump(users, { view: 'table' });

Dump and pause

js
await dp(value);

Dump, stack and pause

js
trace();
await dp(value);

Dump and die with stack

js
trace();
dd(value);

Measure and die

js
const { result } = measure('operation', () => fn());
dd(result);

Inspect without colors and save

js
const str = inspect(object, { colors: false });
fs.writeFileSync('debug.json', str);

Save tree to file

js
const treeStr = inspect(structure, { view: 'tree', colors: false });
fs.writeFileSync('tree.txt', treeStr);

Programmatic analysis

js
const analysis = analyze(data);
console.log(analysis.type);
console.log(analysis.properties.length);

Detect circular references

js
const analysis = analyze(obj);
const isCircular = analysis.properties.some(p => p.value.type === 'circular');

Multiple values in dump

Currently, to display multiple values, group them in an object:

js
dump({ v1, v2, v3 });

Combine with native code

js
// Conditional dump
if (process.env.DEBUG) dump(data);

// Accumulate measurements
const m1 = measure('A', fnA).measurement;
const m2 = measure('B', fnB).measurement;
dump({ m1, m2 });

// Redirect to file
const stream = createWriteStream('./debug.log');
trace('checkpoint', { stream });
await measure('query', () => db.query(sql), { stream });

Combinations table

NameDescriptionCode
dddDump with stack tracedump(value); trace()
ddtDump with timingdump(measure('op', () => fn()).result)
ddtvDump with timing and tree viewdump(measure('op', () => fn()).result, { view: 'tree' })
dpDump and pauseawait dp(value)
dppDump, stack and pausetrace(); await dp(value)
dddsDump, stack and dietrace(); dd(value)
ddtsTiming and diedd(measure('op', () => fn()).result)
ddsSilent dump (no colors)dump(obj, { colors: false })
ddpDump with limited depthdump(obj, { depth: 2 })
ddaDump with array limitdump(arr, { maxArrayLength: 20 })
tddTrace with full stacktrace('point', { showStack: true })
idInspect and savefs.writeFileSync('log', inspect(obj, { colors: false }))
cdConditional dumpif (debug) dump(data)
cmCompare measurementsconst a = measure('A', fnA).measurement; const b = measure('B', fnB).measurement; dump({ a, b })
treeTree viewdump(obj, { view: 'tree' })
tableTable viewdump(arr, { view: 'table' })
analyzeProgrammatic analysisconst analysis = analyze(obj)

Conclusion

The 7 base functionsdump, dd, dp, inspect, trace, measure, analyze – form a small vocabulary. With them, you can combine infinitely to solve any debugging need.

This documentation only suggests some useful patterns, not an exhaustive list. Feel free to create your own combinations and share them with the community.

MIT License