Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contrast/require-hook

Package Overview
Dependencies
Maintainers
10
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrast/require-hook - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

2

lib/export-handler-registry.js
// @ts-check
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const Module = require('module');
const Module = require('node:module');
const semver = require('semver');

@@ -6,0 +6,0 @@ const { getShortname } = require('./helpers');

@@ -41,3 +41,3 @@ export = ExportHookDescriptor;

*/
static create<T_1 extends Object>(descriptor: string | HookDescriptorOptions<T_1>): ExportHookDescriptor<T_1>;
static create<T_1 extends Object>(descriptor: string | HookDescriptorOptions<T_1>): import("./export-hook-descriptor")<T_1>;
/**

@@ -44,0 +44,0 @@ * @param {HookDescriptorOptions<T>} options

// @ts-check
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const path = require('node:path');
const Semver = require('semver');
const path = require('path');
const { isBuiltin } = require('./helpers');
const DEFAULT_VERSION = '*';

@@ -36,3 +37,3 @@ /** @typedef {import('./package-finder').Metadata} Metadata */

/** @type {string} */
this.name = name;
this.name = isBuiltin(name) ? name.replace(/^(node:)?/, 'node:') : name;
/** @type {string=} */

@@ -39,0 +40,0 @@ this.file = file?.replace(/\/?(index)?(\.js)?$/, '');

@@ -11,2 +11,9 @@ /**

export function getShortname({ name, packageDir, file, main }: import('./package-finder').Metadata): string;
/**
* ponyfill for `module.isBuiltin` prior to Node v16.17.0
* see: https://nodejs.org/docs/latest-v16.x/api/module.html#moduleisbuiltinmodulename
* @param {string} name
* @returns {boolean}
*/
export function isBuiltin(name: string): boolean;
//# sourceMappingURL=helpers.d.ts.map
// @ts-check
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const path = require('path');
const Module = require('node:module');
const path = require('node:path');
const pathSepRegex = new RegExp(`\\${path.sep}`, 'g');

@@ -28,5 +29,16 @@ /**

}
/**
* ponyfill for `module.isBuiltin` prior to Node v16.17.0
* see: https://nodejs.org/docs/latest-v16.x/api/module.html#moduleisbuiltinmodulename
* @param {string} name
* @returns {boolean}
*/
function isBuiltin(name) {
// @ts-expect-error we've set the node version to 14 before this was added.
return Module.isBuiltin?.(name) ?? (Module.builtinModules.indexOf(name) >= 0 || (name.startsWith('node:') && Module.builtinModules.indexOf(name.substring(5)) >= 0));
}
module.exports = {
getShortname
getShortname,
isBuiltin,
};
//# sourceMappingURL=helpers.js.map
// @ts-check
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const Module = require('module');
const Module = require('node:module');
const ExportHandlerRegistry = require('./export-handler-registry');

@@ -6,0 +6,0 @@ const ExportHookDescriptor = require('./export-hook-descriptor');

@@ -32,7 +32,2 @@ export type Metadata = {

/**
* @param {string} name
* @returns {boolean}
*/
export function isNative(name: string): boolean;
/**
* Resolves the metadata of a package given it's resolved name.

@@ -39,0 +34,0 @@ * @param {string=} filename Absolute path to the module file

// @ts-check
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const Module = require('module');
const path = require('node:path');
const parentPackageJson = require('parent-package-json');
const path = require('path');
const { isBuiltin } = require('./helpers');
/**

@@ -16,9 +16,2 @@ * @typedef {Object} Metadata

/**
* @param {string} name
* @returns {boolean}
*/
function isNative(name) {
return Module.builtinModules.indexOf(name) >= 0;
}
/**
* Resolves the metadata of a package given it's resolved name.

@@ -33,8 +26,9 @@ * @param {string=} filename Absolute path to the module file

}
if (isNative(filename)) {
if (isBuiltin(filename)) {
filename = filename.replace(/^(node:)?/, 'node:');
return {
name: filename,
version: process.version.substring(1),
packageDir: `node:${filename}`,
file: `node:${filename}`,
packageDir: filename,
file: filename,
};

@@ -63,5 +57,4 @@ }

module.exports = {
isNative,
resolveMetadata,
};
//# sourceMappingURL=package-finder.js.map
{
"name": "@contrast/require-hook",
"version": "4.1.0",
"version": "4.1.1",
"description": "Post hooks for Module.prototype.require",

@@ -5,0 +5,0 @@ "license": "MIT",

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

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

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

Sorry, the diff of this file is not supported yet

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