Skip to content

Simple ES7 decorator for debugging classes and methods

License

Notifications You must be signed in to change notification settings

blakeembrey/decorator-debug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Decorator Debug

NPM version NPM downloads Build status Test coverage

Simple ES7 decorator for debugging classes and methods.

Installation

npm install decorator-debug --save

Usage

Every time the class or method is called, a console log will be emitted with the property name, result, args, context and time taken.

import debug = require('decorator-debug')

@debug
class Demo {
  @debug
  method (string) {
    return true
  }
}

new Demo(1, 2, 3).method('test')

//=> new Demo { name: 'Demo', result: {}, context: {}, args: [ 1, 2, 3 ], time: 0.2647359999999992 }
//=> Demo#method { name: 'method', result: true, context: {}, args: [ 'test' ], time: 0.029204000000000008 }

P.S. You can debug conditionally.

@debug(process.env.NODE_ENV !== 'production')
class Demo {}

License

MIT

About

Simple ES7 decorator for debugging classes and methods

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •