debug-it
Debug-it is a simple library for logging input and output parameters of a decorated class.
It depends on debug.
This library is very similar to decorate-it but doesn't perform any validation and it can be used in the browser.
Installation
npm i --save debug-it
Sample usage
file services/CalcService.js
; { return a + b;} // create your serviceconst CalcService = add; // decorate it, it will mutate CalcService; ;
use service
; CalcService; // returns 4
See example under example/example1.js
. Run it using npm run example1
.
Async sample usage
file services/UserService.js
; { return await { ; };} getUserparams = 'id'; // create your serviceconst UserService = getUser; // decorate it, it will mutate UserService; ;
use service
; await UserService; // returns { id: 1, username: 'john' }await UserService; // returns { id: 222, username: 'john' }
See example under example/example2.js
. Run it using npm run example2
.
NOTE parameter names cannot be automatically retrieved from async
methods.
You must define them explicitly in params
property like this getUser.params = ['id'];
MIT License
Copyright (c) 2017 Łukasz Sentkiewicz