Socket
Socket
Sign inDemoInstall

cronometro

Package Overview
Dependencies
49
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.2 to 3.0.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

### 2024-02-07 / 3.0.0
- feat!: Replaced ts-node with @swc-node/register.
### 2024-01-27 / 2.0.2

@@ -2,0 +6,0 @@

5

dist/models.d.ts

@@ -9,3 +9,4 @@ /// <reference types="node" resolution-mode="require"/>

}
export type SetupFunction = (cb: (err?: Error | null) => void) => Promise<any> | void;
export type SetupFunctionCallback = (err?: Error | null) => void;
export type SetupFunction = (cb: SetupFunctionCallback) => Promise<any> | void;
export interface Options {

@@ -30,3 +31,2 @@ iterations: number;

}
export type Callback = (err: Error | null, results: Results) => any;
export type Percentiles = Record<string, number>;

@@ -44,2 +44,3 @@ export interface Result {

}
export type Callback = (err: Error | null, results: Results) => any;
export type Tests = Record<string, TestFunction | Test>;

@@ -46,0 +47,0 @@ export type Results = Record<string, Result>;

@@ -25,2 +25,2 @@ import { resolve } from 'node:path';

];
export const runnerPath = resolve(import.meta.url.replace('file://', '').replace(/models.(js|ts)/, ''), './runner.js');
export const runnerPath = resolve(import.meta.url.replace('file://', '').replace('/src/', '/dist/').replace(/models.(js|ts)/, ''), './runner.js');

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

import { isMainThread, parentPort, workerData } from 'node:worker_threads';
/* c8 ignore start */ import { isMainThread, parentPort, workerData } from 'node:worker_threads';
import { runWorker } from './worker.js';

@@ -6,24 +6,13 @@ if (isMainThread) {

}
// Register ts-node for TypeScript inclusion
let chain = Promise.resolve();
/* c8 ignore start */ if (workerData.path.endsWith('.ts')) {
const instance = Symbol.for('ts-node.register.instance');
if (!(instance in process)) {
chain = import('ts-node').then(({ register })=>{
register({
project: process.env.TS_NODE_PROJECT
});
});
}
if (workerData.path.endsWith('.ts')) {
await import('@swc-node/register/esm-register');
}
// Require the script to set tests
chain.then(()=>{
return import(workerData.path);
}).then((module)=>{
try {
const module = await import(workerData.path);
if (typeof module === 'function') {
return module();
await module();
} else if (typeof module.default === 'function') {
return module.default();
await module.default();
}
}).then(()=>{
// Run the worker

@@ -36,6 +25,6 @@ runWorker(workerData, (value)=>{

}, (code)=>process.exit(code));
}).catch((error)=>{
} catch (error) {
process.nextTick(()=>{
throw error;
});
}) /* c8 ignore stop */ ;
} /* c8 ignore stop */

@@ -83,3 +83,3 @@ import { build as buildHistogram } from 'hdr-histogram-js';

} catch (error) {
// If a error was thrown, only handle if the original function length is 0, which means it's a sync error, otherwise propagate
/* c8 ignore start */ // If a error was thrown, only handle if the original function length is 0, which means it's a sync error, otherwise propagate
if (context.test.length === 0) {

@@ -89,3 +89,3 @@ context.handler(error);

}
throw error;
/* c8 ignore end */ throw error;
}

@@ -92,0 +92,0 @@ }

{
"name": "cronometro",
"version": "2.0.2",
"version": "3.0.0",
"description": "Simple benchmarking suite powered by HDR histograms.",

@@ -36,4 +36,4 @@ "homepage": "https://sw.cowtech.it/cronometro",

"typecheck": "tsc -p . --emitDeclarationOnly",
"test": "c8 -c test/config/c8-local.json tap test/*.test.ts",
"test:ci": "c8 -c test/config/c8-ci.json tap --no-color test/*.test.ts",
"test": "TS_NODE_PROJECT=tsconfig.test.json c8 -c test/config/c8-local.json node --import @swc-node/register/esm-register --test test/*.test.ts",
"test:ci": "TS_NODE_PROJECT=tsconfig.test.json c8 -c test/config/c8-ci.json node --import @swc-node/register/esm-register --test-reporter=tap --test test/*.test.ts",
"ci": "npm run build && npm run test:ci",

@@ -44,2 +44,3 @@ "prepublishOnly": "npm run ci",

"dependencies": {
"@swc-node/register": "^1.8.0",
"acquerello": "^2.0.6",

@@ -60,4 +61,2 @@ "hdr-histogram-js": "^3.0.0",

"proxyquire": "^2.1.3",
"tap": "^18.7.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"

@@ -67,6 +66,3 @@ },

"node": ">= 18.18.0"
},
"tap": {
"extends": "./test/config/tap.yml"
}
}

@@ -32,8 +32,6 @@ # cronometro

cronometro uses [ts-node](https://www.npmjs.com/package/ts-node) to compile TypeScript files on the fly.
cronometro can run on TypeScript files. Type deletion happens on the fly with no additional configuration required.
ts-node and TypeScript are not installed automatically by cronometro (as they are listed in `peerDependencies`) so you need to do it manually.
Use the `TS_NODE_PROJECT` environment variable to provide a TypeScript configuration.
To pass the `tsconfig.json` project file to use, use the `TS_NODE_PROJECT` environment variable.
### API use

@@ -106,6 +104,6 @@

const results = cronometro({
test1: function () {
await test1: function () {
// Do something
},
test2: function () {
await test2: function () {
// Do something else

@@ -112,0 +110,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc