This commit is contained in:
eric sciple 2020-01-24 12:20:47 -05:00
parent a004f0ae58
commit fc725ba36b
7280 changed files with 19 additions and 1796407 deletions

View file

@ -1,23 +0,0 @@
MIT License
For Jest software
Copyright (c) 2014-present, Facebook, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,22 +0,0 @@
# jest-leak-detector
Module for verifying whether an object has been garbage collected or not.
Internally creates a weak reference to the object, and forces garbage collection to happen. If the reference is gone, it meant no one else was pointing to the object.
## Example
```javascript
let reference = {};
const detector = new LeakDetector(reference);
// Reference is held in memory.
console.log(detector.isLeaked()); // true
// We destroy the only reference to the object.
reference = null;
// Reference is gone.
console.log(detector.isLeaked()); // false
```

View file

@ -1,14 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export default class {
private _isReferenceBeingHeld;
constructor(value: unknown);
isLeaking(): boolean;
private _runGarbageCollector;
private _isPrimitive;
}
//# sourceMappingURL=index.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,CAAC,OAAO;IACZ,OAAO,CAAC,qBAAqB,CAAU;gBAE3B,KAAK,EAAE,OAAO;IAiC1B,SAAS,IAAI,OAAO;IAMpB,OAAO,CAAC,oBAAoB;IAa5B,OAAO,CAAC,YAAY;CAGrB"}

View file

@ -1,118 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function _v() {
const data = _interopRequireDefault(require('v8'));
_v = function _v() {
return data;
};
return data;
}
function _vm() {
const data = _interopRequireDefault(require('vm'));
_vm = function _vm() {
return data;
};
return data;
}
function _prettyFormat() {
const data = _interopRequireDefault(require('pretty-format'));
_prettyFormat = function _prettyFormat() {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class _default {
constructor(value) {
_defineProperty(this, '_isReferenceBeingHeld', void 0);
if (this._isPrimitive(value)) {
throw new TypeError(
[
'Primitives cannot leak memory.',
'You passed a ' +
typeof value +
': <' +
(0, _prettyFormat().default)(value) +
'>'
].join(' ')
);
}
let weak;
try {
// eslint-disable-next-line import/no-extraneous-dependencies
weak = require('weak');
} catch (err) {
if (!err || err.code !== 'MODULE_NOT_FOUND') {
throw err;
}
throw new Error(
'The leaking detection mechanism requires the "weak" package to be installed and work. ' +
'Please install it as a dependency on your main project'
);
}
weak(value, () => (this._isReferenceBeingHeld = false));
this._isReferenceBeingHeld = true; // Ensure value is not leaked by the closure created by the "weak" callback.
value = null;
}
isLeaking() {
this._runGarbageCollector();
return this._isReferenceBeingHeld;
}
_runGarbageCollector() {
const isGarbageCollectorHidden = !global.gc; // GC is usually hidden, so we have to expose it before running.
_v().default.setFlagsFromString('--expose-gc');
_vm().default.runInNewContext('gc')(); // The GC was not initially exposed, so let's hide it again.
if (isGarbageCollectorHidden) {
_v().default.setFlagsFromString('--no-expose-gc');
}
}
_isPrimitive(value) {
return value !== Object(value);
}
}
exports.default = _default;

View file

@ -1,60 +0,0 @@
{
"_args": [
[
"jest-leak-detector@24.8.0",
"/Users/eric/repos/actions/setup-node"
]
],
"_development": true,
"_from": "jest-leak-detector@24.8.0",
"_id": "jest-leak-detector@24.8.0",
"_inBundle": false,
"_integrity": "sha512-cG0yRSK8A831LN8lIHxI3AblB40uhv0z+SsQdW3GoMMVcK+sJwrIIyax5tu3eHHNJ8Fu6IMDpnLda2jhn2pD/g==",
"_location": "/jest-leak-detector",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "jest-leak-detector@24.8.0",
"name": "jest-leak-detector",
"escapedName": "jest-leak-detector",
"rawSpec": "24.8.0",
"saveSpec": null,
"fetchSpec": "24.8.0"
},
"_requiredBy": [
"/jest-runner"
],
"_resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-24.8.0.tgz",
"_spec": "24.8.0",
"_where": "/Users/eric/repos/actions/setup-node",
"bugs": {
"url": "https://github.com/facebook/jest/issues"
},
"dependencies": {
"pretty-format": "^24.8.0"
},
"description": "Module for verifying whether an object has been garbage collected or not.",
"devDependencies": {
"@types/weak": "^1.0.0",
"weak": "^1.0.1"
},
"engines": {
"node": ">= 6"
},
"gitHead": "845728f24b3ef41e450595c384e9b5c9fdf248a4",
"homepage": "https://github.com/facebook/jest#readme",
"license": "MIT",
"main": "build/index.js",
"name": "jest-leak-detector",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/facebook/jest.git",
"directory": "packages/jest-leak-detector"
},
"types": "build/index.d.ts",
"version": "24.8.0"
}

View file

@ -1,10 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
},
"references": [
{"path": "../pretty-format"}
]
}