Use .find instead of .filter to get targetPath in ImportInjector (#10608)

This commit is contained in:
Mateusz Burzyński 2019-10-27 20:09:03 +01:00 committed by Justin Ridgewell
parent 43065a9e24
commit 9ada30c207

View File

@ -417,10 +417,10 @@ export default class ImportInjector {
node._blockHoist = blockHoist;
});
const targetPath = this._programPath.get("body").filter(p => {
const targetPath = this._programPath.get("body").find(p => {
const val = p.node._blockHoist;
return Number.isFinite(val) && val < 4;
})[0];
});
if (targetPath) {
targetPath.insertBefore(statements);