Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

deborator

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deborator - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

@@ -1,5 +0,3 @@

/////////////////////////////////////////////////////////////////////
// BEGIN deborator
class DeboratorOptions {
log?: (text: string) => void;
showReturnValues? = false;

@@ -14,2 +12,5 @@ }

export function deborator(options: DeboratorOptions) {
// tslint:disable-next-line:no-console
console.warn("deborator is active - NOT suitable for use in Production! (since console logging may impact performance and security)");
return (target: any) => {

@@ -22,4 +23,10 @@ // save a reference to the original constructor

const log = (text: string) => {
// tslint:disable-next-line:no-console
console.log(">DB> " + text);
const message = ">DB> " + text;
if(options.log) {
options.log(message);
} else {
// tslint:disable-next-line:no-console
console.log(message);
}
};

@@ -140,3 +147,1 @@

}
// END deborator
/////////////////////////////////////////////////////////////////////
{
"name": "deborator",
"version": "1.0.5",
"version": "1.0.6",
"description": "a TypeScript decorator, to add console.log() to all methods and properties of a class.",

@@ -5,0 +5,0 @@ "main": "deborator.ts",

@@ -30,3 +30,3 @@ # deborator readme

@deborator
@deborator({})
class MyCalculator {

@@ -47,2 +47,11 @@ add(value: number) {

### advanced usage
deborator options:
| option | description | example |
|---|---|---|
|log| A function that accepts a string (a message generated by deborator). This overrides the default behaviour (logging to console).| ```@deborator({log: (text: string) => {console.info(text);} }) ``` |
|showReturnValues| Set this to true, if you also want to see return values in the log.| ```@deborator({showReturnValues: true }) ``` |
## running the demo app

@@ -91,4 +100,12 @@

### demo app
The demo app was based on a really nice react-typescript starter kit by Jack Franklin
https://github.com/javascript-playground/react-typescript-jest-demo
https://javascriptplayground.com/blog/2017/04/react-typescript/
## license
MIT