# deborator

> a TypeScript decorator, to add console.log() to all methods and properties of a class.

Latest version **1.0.20** (published 2017-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install deborator
pnpm add deborator
yarn add deborator
bun add deborator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.20 |
| Published | 2017-08-25 |
| First published | 2017-08-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sean Ryan |
| Maintainers | seanius |
| Keywords | TypeScript, decorator, debug, console |

## Links

- npm: https://www.npmjs.com/package/deborator
- Repository: https://bitbucket.org/str/deborator
- Homepage: https://bitbucket.org/str/deborator#readme
- npm.io page: https://npm.io/package/deborator

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.20 (latest) — 2017-08-25
- 1.0.19 — 2017-08-25
- 1.0.18 — 2017-08-25
- 1.0.16 — 2017-08-25
- 1.0.15 — 2017-08-25
- 1.0.14 — 2017-08-25
- 1.0.13 — 2017-08-25
- 1.0.12 — 2017-08-25
- 1.0.11 — 2017-08-25
- 1.0.10 — 2017-08-25
- 1.0.9 — 2017-08-25
- 1.0.8 — 2017-08-25
- 1.0.7 — 2017-08-25
- 1.0.6 — 2017-08-25
- 1.0.5 — 2017-08-25
- … 5 more at https://npm.io/package/deborator/versions

## README

# deborator readme

deborator (DEBug decORATOR) is a TypeScript decorator, to add console.log() to all methods and properties of a TypeScript class.

If you find yourself writing a lot of console.log() entries during debugging, then deborator may save you time!
 
This can be especially useful when regular debugging via breakpoints is not really practical

examples:
- developing drag'n'drop features in a browser
    since browsers like Chrome tend not to exit the 'dragging' state, if they hit a breakpoint

- developing real-time sites, when debugging via breakpoints is not practical

note: deborator should NOT be deployed to Production (as there may be performance/security impact because of the logging)

## usage

Install deborator via yarn:

```
yarn add deborator
```

Import deborator into the TypeScript file, and apply the decorator to the class you want to debug:

```
import { deborator } from "deborator";

@deborator({})
class MyCalculator {
    constructor(private value: number) {}

    add(value: number) {
        this.value += value;
    }
}

// using your class:
const calc = new MyCalculator(1);
calc.add(5);
```

Now if you hit F12, you will see console log entries for your class, as it is being used:

```
>DB> new MyCalculator( 1 )
>DB> MyCalculator.add( 5 )
>DB>   MyCalculator.add( 5 ) => ( {"value":6} )
```

### advanced usage

deborator options: (all are optional)

| 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 }) ``` |
|showProperties| Set this to true, to also log get/set properties. This can be noisy!. | ```@deborator({showProperties: true }) ``` |
|decoratePrototype| Set this to true, to also log inherited methods (does not work with React components).| ```@deborator({decoratePrototype: true }) ``` |

### known issues

- import into react project - right now need to do this (import source rather than compiled js):
    ```import { deborator } from "deborator/src/deborator";```
- dist folder (npm package): the index.js does not work from one unit test project
    workaround: copy the source file 'deborator.ts' into the project

## running the demo app

To see deborator in action, you can get the source code and run the demo app.

- get the source code:

```
git clone https://bitbucket.org/str/deborator
```

### dependencies

- node [v6.10.3 is OK]
- yarn [0.27.5 is OK]

### setup

On a Windows box (Unix should be similar ...)

```
CD demo-app
install
```

### run the app

```
run
```

## relevant links

sourcecode in git:
https://bitbucket.org/str/deborator

npm package:
https://www.npmjs.com/package/deborator

TypeScript decorators:
https://www.typescriptlang.org/docs/handbook/decorators.html

https://gist.github.com/remojansen/16c661a7afd68e22ac6e

### 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

---
_Source: https://npm.io/package/deborator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
