Socket
Socket
Sign inDemoInstall

jest-leak-detector

Package Overview
Dependencies
7
Maintainers
5
Versions
164
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 28.1.1 to 28.1.3

3

build/index.d.ts

@@ -7,5 +7,8 @@ /**

*/
/// <reference lib="es2021.weakref" />
/// <reference lib="es2021.weakref" />
declare class LeakDetector {
private _isReferenceBeingHeld;
private _finalizationRegistry?;
constructor(value: unknown);

@@ -12,0 +15,0 @@ isLeaking(): Promise<boolean>;

40

build/index.js

@@ -64,2 +64,3 @@ 'use strict';

*/
/// <reference lib="es2021.WeakRef" />
const tick = (0, _util().promisify)(setImmediate);

@@ -69,2 +70,3 @@

_isReferenceBeingHeld;
_finalizationRegistry;

@@ -81,21 +83,33 @@ constructor(value) {

);
}
} // TODO: Remove the `if` and `weak-napi` when we drop node 12, as v14 supports FinalizationRegistry
let weak;
if (globalThis.FinalizationRegistry) {
// When `_finalizationRegistry` is GCed the callback we set will no longer be called,
// so we need to assign it to `this` to keep it referenced
this._finalizationRegistry = new FinalizationRegistry(() => {
this._isReferenceBeingHeld = false;
});
try {
// eslint-disable-next-line import/no-extraneous-dependencies
weak = require('weak-napi');
} catch (err) {
if (!err || err.code !== 'MODULE_NOT_FOUND') {
throw err;
this._finalizationRegistry.register(value, undefined);
} else {
let weak;
try {
// eslint-disable-next-line import/no-extraneous-dependencies
weak = require('weak-napi');
} catch (err) {
if (!err || err.code !== 'MODULE_NOT_FOUND') {
throw err;
}
throw new Error(
'The leaking detection mechanism requires newer version of node that supports ' +
'FinalizationRegistry, update your node or install the "weak-napi" package ' +
'which support current node version as a dependency on your main project.'
);
}
throw new Error(
'The leaking detection mechanism requires the "weak-napi" package to be installed and work. ' +
'Please install it as a dependency on your main project'
);
weak(value, () => (this._isReferenceBeingHeld = false));
}
weak(value, () => (this._isReferenceBeingHeld = false));
this._isReferenceBeingHeld = true; // Ensure value is not leaked by the closure created by the "weak" callback.

@@ -102,0 +116,0 @@

{
"name": "jest-leak-detector",
"version": "28.1.1",
"version": "28.1.3",
"repository": {

@@ -21,3 +21,3 @@ "type": "git",

"jest-get-type": "^28.0.2",
"pretty-format": "^28.1.1"
"pretty-format": "^28.1.3"
},

@@ -34,3 +34,3 @@ "devDependencies": {

},
"gitHead": "eb954f8874960920ac50a8f976bb333fbb06ada9"
"gitHead": "2cce069800dab3fc8ca7c469b32d2e2b2f7e2bb1"
}
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