Socket
Socket
Sign inDemoInstall

@codspeed/core

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 2.0.0

89

dist/index.cjs.js
'use strict';
var fs = require('fs');
var path = require('path');
const getV8Flags = (nodeVersionMajor) => {
const flags = [
"--hash-seed=1",
"--random-seed=1",
"--no-opt",
"--predictable",
"--predictable-gc-schedule",
"--interpreted-frames-native-stack"
];
if (nodeVersionMajor < 18) {
flags.push("--no-randomize-hashes");
}
if (nodeVersionMajor < 20) {
flags.push("--no-scavenge-task");
}
return flags;
};
const tryIntrospect = () => {
if (process.env.__CODSPEED_NODE_CORE_INTROSPECTION_PATH__ !== void 0) {
const nodeVersionMajor = parseInt(process.version.slice(1).split(".")[0]);
const introspectionMetadata = {
flags: getV8Flags(nodeVersionMajor)
};
fs.writeFileSync(
process.env.__CODSPEED_NODE_CORE_INTROSPECTION_PATH__,
JSON.stringify(introspectionMetadata)
);
process.exit(0);
}
};
var __defProp = Object.defineProperty;

@@ -24,14 +56,28 @@ var __defProps = Object.defineProperties;

var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
let m;
let native_core;
try {
m = __spreadProps(__spreadValues({}, require("node-gyp-build")(path.dirname(__dirname))), {
const nativeCore = require("node-gyp-build")(
path.dirname(__dirname)
);
native_core = __spreadProps(__spreadValues({}, nativeCore), {
isBound: true
});
} catch (e) {
m = {
isInstrumented: () => false,
startInstrumentation: () => {
native_core = {
Measurement: {
isInstrumented: () => false,
// eslint-disable-next-line @typescript-eslint/no-empty-function
startInstrumentation: () => {
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
stopInstrumentation: (at) => {
}
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
stopInstrumentation: (at) => {
LinuxPerf: class LinuxPerf {
start() {
return false;
}
stop() {
return false;
}
},

@@ -41,12 +87,13 @@ isBound: false

}
var native_core$1 = native_core;
const skipOptimization = process.env.CODSPEED_FORCE_OPTIMIZATION !== "true";
const measurement = m;
const initCore = () => {
const initOptimization = () => {
if (!skipOptimization) {
require("v8").setFlagsFromString("--allow-natives-syntax");
}
measurement.stopInstrumentation(`Metadata: codspeed-node ${"1.0.2"}`);
};
const optimizeFunction = async (fn) => {
if (skipOptimization) {
await fn();
return;

@@ -61,2 +108,3 @@ }

if (skipOptimization) {
fn();
return;

@@ -70,6 +118,23 @@ }

exports.initCore = initCore;
exports.measurement = measurement;
tryIntrospect();
const linuxPerf = new native_core$1.LinuxPerf();
const isBound = native_core$1.isBound;
const setupCore = () => {
initOptimization();
native_core$1.Measurement.stopInstrumentation(
`Metadata: codspeed-node ${"2.0.0"}`
);
linuxPerf.start();
};
const teardownCore = () => {
linuxPerf.stop();
};
const Measurement = native_core$1.Measurement;
exports.Measurement = Measurement;
exports.isBound = isBound;
exports.optimizeFunction = optimizeFunction;
exports.optimizeFunctionSync = optimizeFunctionSync;
exports.setupCore = setupCore;
exports.teardownCore = teardownCore;
//# sourceMappingURL=index.cjs.js.map

20

dist/index.d.ts

@@ -1,13 +0,17 @@

interface Measurement {
isInstrumented(): boolean;
startInstrumentation(): void;
stopInstrumentation(at: string): void;
isBound: boolean;
interface Measurement$1 {
isInstrumented: () => boolean;
startInstrumentation: () => void;
stopInstrumentation: (pos: string) => void;
}
declare const measurement: Measurement;
declare const initCore: () => void;
declare const optimizeFunction: (fn: CallableFunction) => Promise<void>;
declare const optimizeFunctionSync: (fn: CallableFunction) => void;
export { Measurement, initCore, measurement, optimizeFunction, optimizeFunctionSync };
declare const isBound: boolean;
declare const setupCore: () => void;
declare const teardownCore: () => void;
declare const Measurement: Measurement$1;
export { Measurement, isBound, optimizeFunction, optimizeFunctionSync, setupCore, teardownCore };
//# sourceMappingURL=index.d.ts.map

@@ -0,3 +1,35 @@

import { writeFileSync } from 'fs';
import path from 'path';
const getV8Flags = (nodeVersionMajor) => {
const flags = [
"--hash-seed=1",
"--random-seed=1",
"--no-opt",
"--predictable",
"--predictable-gc-schedule",
"--interpreted-frames-native-stack"
];
if (nodeVersionMajor < 18) {
flags.push("--no-randomize-hashes");
}
if (nodeVersionMajor < 20) {
flags.push("--no-scavenge-task");
}
return flags;
};
const tryIntrospect = () => {
if (process.env.__CODSPEED_NODE_CORE_INTROSPECTION_PATH__ !== void 0) {
const nodeVersionMajor = parseInt(process.version.slice(1).split(".")[0]);
const introspectionMetadata = {
flags: getV8Flags(nodeVersionMajor)
};
writeFileSync(
process.env.__CODSPEED_NODE_CORE_INTROSPECTION_PATH__,
JSON.stringify(introspectionMetadata)
);
process.exit(0);
}
};
var __defProp = Object.defineProperty;

@@ -22,14 +54,28 @@ var __defProps = Object.defineProperties;

var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
let m;
let native_core;
try {
m = __spreadProps(__spreadValues({}, require("node-gyp-build")(path.dirname(__dirname))), {
const nativeCore = require("node-gyp-build")(
path.dirname(__dirname)
);
native_core = __spreadProps(__spreadValues({}, nativeCore), {
isBound: true
});
} catch (e) {
m = {
isInstrumented: () => false,
startInstrumentation: () => {
native_core = {
Measurement: {
isInstrumented: () => false,
// eslint-disable-next-line @typescript-eslint/no-empty-function
startInstrumentation: () => {
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
stopInstrumentation: (at) => {
}
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
stopInstrumentation: (at) => {
LinuxPerf: class LinuxPerf {
start() {
return false;
}
stop() {
return false;
}
},

@@ -39,12 +85,13 @@ isBound: false

}
var native_core$1 = native_core;
const skipOptimization = process.env.CODSPEED_FORCE_OPTIMIZATION !== "true";
const measurement = m;
const initCore = () => {
const initOptimization = () => {
if (!skipOptimization) {
require("v8").setFlagsFromString("--allow-natives-syntax");
}
measurement.stopInstrumentation(`Metadata: codspeed-node ${"1.0.2"}`);
};
const optimizeFunction = async (fn) => {
if (skipOptimization) {
await fn();
return;

@@ -59,2 +106,3 @@ }

if (skipOptimization) {
fn();
return;

@@ -68,3 +116,18 @@ }

export { initCore, measurement, optimizeFunction, optimizeFunctionSync };
tryIntrospect();
const linuxPerf = new native_core$1.LinuxPerf();
const isBound = native_core$1.isBound;
const setupCore = () => {
initOptimization();
native_core$1.Measurement.stopInstrumentation(
`Metadata: codspeed-node ${"2.0.0"}`
);
linuxPerf.start();
};
const teardownCore = () => {
linuxPerf.stop();
};
const Measurement = native_core$1.Measurement;
export { Measurement, isBound, optimizeFunction, optimizeFunctionSync, setupCore, teardownCore };
//# sourceMappingURL=index.es5.js.map
{
"name": "@codspeed/core",
"version": "1.1.0",
"version": "2.0.0",
"description": "The core Node library used to integrate with Codspeed runners",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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