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 - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2-canary.1.2e19dab85c23a5c1bec2a151d78733e22aac0f52.0

6

index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.timeout = exports.benchmark = void 0;
const console_1 = require("console");
const perf_hooks_1 = require("perf_hooks");

@@ -17,3 +18,3 @@ const util_1 = require("util");

*/
function benchmark(metric = 'ms', precision) {
function benchmark(metric = 'ms', precision, stream = process.stdout) {
return function (target, keyName, descriptor) {

@@ -23,2 +24,3 @@ if (!(descriptor.value instanceof Function)) {

}
const logger = new console_1.Console({ stdout: stream });
const fn = descriptor.value;

@@ -35,3 +37,3 @@ descriptor.value = async function (...args) {

}
console.log(`Function ${keyName} from class ${target.constructor.name} was executed in ${diff.toFixed(precision)} ${metric}`);
logger.info(`Function ${keyName} from class ${target.constructor.name} was executed in ${diff.toFixed(precision)} ${metric}`);
return result;

@@ -38,0 +40,0 @@ };

@@ -0,1 +1,2 @@

import { Console } from 'console';
import { performance } from 'perf_hooks';

@@ -19,2 +20,3 @@ import { promisify } from 'util';

precision?: number,
stream: NodeJS.WritableStream = process.stdout,
): Function {

@@ -32,2 +34,4 @@ return function(

const logger = new Console({ stdout: stream });
const fn: Function = descriptor.value;

@@ -49,3 +53,3 @@

console.log(
logger.info(
`Function ${keyName} from class ${target.constructor.name} was executed in ${diff.toFixed(precision)} ${metric}`,

@@ -52,0 +56,0 @@ );

{
"name": "@namchee/decora",
"version": "1.0.1",
"version": "1.0.2-canary.1.2e19dab85c23a5c1bec2a151d78733e22aac0f52.0",
"description": "Useful ECMAScript-compliant decorators to enhance JS (specifically, TypeScript) development experience",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,2 +0,2 @@

# Decorator Ku
# Decora

@@ -15,2 +15,4 @@ Useful ECMAScript decorator for personal purposes.

> Will transform the decorated function into an asynchronous function.
```ts

@@ -31,2 +33,3 @@ class Example {

`precision` | `false` | `number, n > 1` | `undefined` | Number of digits after comma. Passing `undefined` will print an abruptly long string.
`stream` | `true` | `NodeJS.WritableStream` | `process.stdout` | Destination for the log to be written to. [Detailed Explanation](https://nodejs.org/api/stream.html#stream_writable_streams)

@@ -39,2 +42,4 @@ ## `@timeout`

> Will transform the decorated function into an asynchronous function.
```ts

@@ -41,0 +46,0 @@ class Example {

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