Skip to content

Commit

Permalink
refactor: remove code duplication on unwrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
rauno56 committed Oct 10, 2022
1 parent b9658e1 commit b34355d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions plugins/node/instrumentation-fs/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,19 @@ export default class FsInstrumentation extends InstrumentationBase<FS> {
);
}
for (const fName of CALLBACK_FUNCTIONS) {
if (isWrapped(fs[fName])) {
this._unwrap(fs, fName);
}
if (fName === 'exists') {
// handling separately because of the inconsistent cb style:
// `exists` doesn't have error as the first argument, but the result
if (isWrapped(fs[fName])) {
this._unwrap(fs, fName);
}
this._wrap(
fs,
fName,
<any>this._patchExistsCallbackFunction.bind(this, fName)
);
continue;
}
if (isWrapped(fs[fName])) {
this._unwrap(fs, fName);
}
this._wrap(
fs,
fName,
Expand Down

0 comments on commit b34355d

Please sign in to comment.