@jonit-dev/decorators-utils
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

Decorator Utils

This lib is a collection of useful decorators for debugging, logging and other utilities.

Installation

yarn add @jonit-dev/decorators-utils -D

Usage

Loggers

@ClassLogger

This decorator will log the class name and the method name before the method execution.

import { ClassLogger } from '@jonit-dev/decorators-utils';

@ClassLogger()
export class SomeClassHere {
  public someMethodHere() {
    ...
  }
}

Would output something like:

 Running SomeClassHere.someMethodHere with arguments: [
  ...
  ]

Performance Trackers

Performance trackers

@TrackExecutionTime

This one is a method specific performance tracker. It will track the performance of the decorated method by using a console.time and console.timeEnd.

import { TrackExecutionTime } from '@jonit-dev/decorators-utils';

export class SomeClassHere {
  @TrackExecutionTime()
  public someMethodHere() {
    ...
  }
}

@TrackClassExecutionTime

This decorator will track the performance of all public and private methods of a class, by using a console.time and console.timeEnd.

import { TrackClassExecutionTime } from '@jonit-dev/decorators-utils';

@TrackClassExecutionTime()
export class SomeClassHere {
  ...
}

@DecorateAllWith(decorator)

As the name suggests, this decorator will decorate all methods of a class with the given decorator.

import { DecorateAllWith } from '@jonit-dev/decorators-utils';

@DecorateAllWith(TrackExecutionTime())
export class SomeClassHere {
  ...
}

Readme

Keywords

none

Package Sidebar

Install

npm i @jonit-dev/decorators-utils

Weekly Downloads

6

Version

0.1.5

License

MIT

Unpacked Size

52.4 kB

Total Files

23

Last publish

Collaborators

  • jonit-dev