Skip to content

Commit

Permalink
[jest-leak-detector] remove code repeat (#8438)
Browse files Browse the repository at this point in the history
* [jest-leak-detector] remove code repeat 🎨

* Update change log 📝
  • Loading branch information
Connormiha authored and jeysal committed May 7, 2019
1 parent 985d26c commit 7197b1c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

### Chore & Maintenance

- `[jest-leak-detector]` remove code repeat ([#8438](https://github.com/facebook/jest/pull/8438)

### Performance

## 24.8.0
Expand Down
1 change: 1 addition & 0 deletions packages/jest-leak-detector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"jest-get-type": "^24.8.0",
"pretty-format": "^24.8.0"
},
"devDependencies": {
Expand Down
7 changes: 2 additions & 5 deletions packages/jest-leak-detector/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
import v8 from 'v8';
import vm from 'vm';
import prettyFormat from 'pretty-format';
import {isPrimitive} from 'jest-get-type';

export default class {
private _isReferenceBeingHeld: boolean;

constructor(value: unknown) {
if (this._isPrimitive(value)) {
if (isPrimitive(value)) {
throw new TypeError(
[
'Primitives cannot leak memory.',
Expand Down Expand Up @@ -63,8 +64,4 @@ export default class {
v8.setFlagsFromString('--no-expose-gc');
}
}

private _isPrimitive(value: unknown): boolean {
return value !== Object(value);
}
}

0 comments on commit 7197b1c

Please sign in to comment.