Skip to content

Commit

Permalink
remove ability to use shimmer.wrap() with two args
Browse files Browse the repository at this point in the history
  • Loading branch information
bengl committed Aug 12, 2024
1 parent ca45a19 commit 991f083
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions packages/datadog-shimmer/src/shimmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,15 @@ function copyProperties (original, wrapped) {
}

function wrapFunction (original, wrapper) {
assertNotClass(original)
// TODO This needs to be re-done so that this and wrapMethod are distinct.
const target = { func: original }
wrapMethod(target, 'func', wrapper)
return target.func
}

const wrapFn = function (original, delegate) {
if (safeMode) {
const target = { func: original }
wrapMethod(target, 'func', delegate)
return target.func
}
assertFunction(delegate)
assertNotClass(original) // TODO: support constructors of native classes

const shim = function shim () {
return delegate.apply(this, arguments)
}

unwrappers.set(shim, () => {
delegate = original
})

copyProperties(original, shim)

return shim
throw new Error('calling `wrap()` with 2 args is deprecated. Use wrapFunction instead.')
}

// This is only used in safe mode. It's a simple state machine to track if the
Expand Down

0 comments on commit 991f083

Please sign in to comment.