Escaping the dreaded
console
error:
Because isn't this way much better?
- No dependecies!
- Your javascript won't fail if you are looking for something that doesn't exist.
- You will be able to look at the stack trace and find the location of your error.
In your project directory
# Install fron NPM
$ npm install -save get-n-log
In your code
import {get} from 'get-n-log';
...
// Use it like this:
getSafe(() => obj.a.lot.of.properties);
// or add an optional default value:
getSafe(() => obj.a.lot.of.properties, 'nothing');
To get started...
-
Option 1
- 🍴 Fork this repo!
-
Option 2
- 👯 Clone this repo to your local machine using
https://github.com/rabbishuki/get-n-log.git
- 👯 Clone this repo to your local machine using
- HACK AWAY! 🔨🔨🔨
- 🔃 Create a new pull request using
https://github.com/rabbishuki/get-n-log/compare/
.