New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@namchee/decora

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@namchee/decora

Useful ECMAScript-compliant decorators to enhance JS (specifically, TypeScript) development experience

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-81.82%
Maintainers
1
Weekly downloads
 
Created
Source

Decora

NPM Badge

Useful ECMAScript decorator for personal purposes. Compatible with both browser and NodeJS environment.

Although it's written in TypeScript, these decorators should be compatible with normal JS files as long as it supports ES7.

Will be updated indefinitely.

Installation

npm install @namchee/decora

TypeScript

Remember to toggle the experimentalDecorators option to true in your tsconfig.json

JavaScript

Install @babel/plugin-proposal-decorators and add it to your Babel configuration

@benchmark

Decorator Type: Method decorator

Add benchmarking functionality to a method from a class. Benchmark result will be written to console.

Will transform the decorated function into an asynchronous function.

class Example {
  @benchmark()
  logMe() {
    console.log('test');
  }
}

Parameters

NameRequired?ValuesDefault ValueDescription
metricfalse['s', 'ms', 'ns']'ms'Metric to be used when logging function runtime
precisionfalsenumber, n > 1undefinedNumber of digits after comma. Passing undefined will print an abruptly long string.
streamtrueNodeJS.WritableStreamprocess.stdoutDestination for the log to be written to. Detailed Explanation. This option is ONLY available on NodeJS environment.

@timeout

Decorator Type: Method decorator

Limits a function execution time to a certain time limit. Will throw an error if timeout value exceeded.

Will transform the decorated function into an asynchronous function.

class Example {
  @benchmark(1000)
  timeoutMe() {
    setTimeoutPromise(5000); // will throw an error
  }
}

Parameters

NameRequired?ValuesDefault ValueDescription
timetruenumber-Time limit for the function
metricfalse['s', 'ms', 'ns']'ms'Metric to be used when logging function runtime

Keywords

FAQs

Package last updated on 07 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc