Dump an object and kill the process in node.js for quick debugging. Based on Laravel's dd()
function.
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
You're free to use this package (it's MIT-licensed), but if it makes it to your production environment you are required to send us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.
The best postcards will get published on the open source page on our website.
npm install dump-die
Calling dd
will print the object in your terminal and kill the process.
const dd = require('dump-die')
let myObject = {
foo: 'bar',
baz: function() {
return 'Hi'
}
}
Outputs:
{ foo: 'bar',
baz:
{ [Function]
[length]: 0,
[name]: '',
[prototype]: { [constructor]: [Circular] } } }
You can dump any amount of objects.
let foo = 'bar', hodor = { hodor: 'hodor' }
dd(foo, baz, hodor)
Outputs:
'bar'
{ hodor: 'hodor' }
If you don't want to kill the process, you can require the inspect function (which is a simple wrapper around node.js' util.inspect
)
const inspect = require('dump-die/lib/inspect')
inspect({ foo: 'bar' }) // => '{ foo: \u001b[32m\'bar\'\u001b[39m }'
You can run the tests (ESLint & Mocha) with:
npm run test
Please see CONTRIBUTING for details.
If you discover any security related issues, please email security@spatie.be instead of using the issue tracker.
Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
The MIT License (MIT). Please see License File for more information.