Skip to content

Commit fd870be

Browse files
committed
fixup! fixup! feat(core, node): portable Express integration
1 parent 3c1ebe0 commit fd870be

2 files changed

Lines changed: 1 addition & 27 deletions

File tree

‎packages/core/src/utils/object.ts‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,6 @@ export function wrapMethod<O extends {}, T extends string & keyof O>(obj: O, fie
9696
addNonEnumerableProperty(obj, field, wrapped);
9797
}
9898

99-
/**
100-
* Unwrap a previously wrapped method on an object by name
101-
*/
102-
export function unwrapMethod<O extends {}, T extends string & keyof O>(obj: O, field: T): void {
103-
const wrapped = obj[field];
104-
if (typeof wrapped !== 'function') {
105-
throw new Error(`Cannot unwrap method: ${field} is not a function`);
106-
}
107-
const original = getOriginalFunction(wrapped);
108-
if (!original) {
109-
throw new Error(`Method ${field} is not wrapped, and cannot be unwrapped`);
110-
}
111-
addNonEnumerableProperty(obj, field, original);
112-
}
113-
11499
/**
115100
* This extracts the original function if available. See
116101
* `markFunctionWrapped` for more information.

‎packages/core/test/lib/utils/object.test.ts‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
fill,
1212
markFunctionWrapped,
1313
objectify,
14-
unwrapMethod,
1514
wrapMethod,
1615
} from '../../../src/utils/object';
1716
import { testOnlyIfNodeVersionAtLeast } from '../../testutils';
@@ -458,16 +457,14 @@ describe('markFunctionWrapped', () => {
458457
});
459458
});
460459

461-
describe('unwrapMethod, wrapMethod', () => {
460+
describe('wrapMethod', () => {
462461
it('can wrap a method on an object and unwrap it later', () => {
463462
const wrapped = () => {};
464463
const original = () => {};
465464
const obj = { m: original };
466465
wrapMethod(obj, 'm', wrapped);
467466
expect(obj.m).toBe(wrapped);
468467
expect((obj.m as WrappedFunction).__sentry_original__).toBe(original);
469-
unwrapMethod(obj, 'm');
470-
expect(obj.m).toBe(original);
471468
});
472469

473470
it('throws if misused', () => {
@@ -479,16 +476,8 @@ describe('unwrapMethod, wrapMethod', () => {
479476
//@ts-expect-error verify type checking prevents this mistake
480477
wrapMethod(obj, 'foo', wrapped);
481478
}).toThrowError('Cannot wrap method: foo is not a function');
482-
expect(() => {
483-
//@ts-expect-error verify type checking prevents this mistake
484-
unwrapMethod(obj, 'foo');
485-
}).toThrowError('Cannot unwrap method: foo is not a function');
486479
expect(() => {
487480
wrapMethod(obj, 'm', wrapped);
488481
}).toThrowError('Attempting to wrap method m multiple times');
489-
unwrapMethod(obj, 'm');
490-
expect(() => {
491-
unwrapMethod(obj, 'm');
492-
}).toThrowError('Method m is not wrapped, and cannot be unwrapped');
493482
});
494483
});

0 commit comments

Comments
 (0)