MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / makeWeakRef

Function makeWeakRef

packages/core/src/utils/weakRef.ts:28–39  ·  view source on GitHub ↗
(value: T)

Source from the content-addressed store, hash-verified

26 * @returns A WeakRef wrapper if available, or the original object as fallback
27 */
28export function makeWeakRef<T extends object>(value: T): MaybeWeakRef<T> {
29 try {
30 // @ts-expect-error - WeakRef may not be in the type definitions for older TS targets
31 const WeakRefImpl = GLOBAL_OBJ.WeakRef;
32 if (typeof WeakRefImpl === 'function') {
33 return new WeakRefImpl(value);
34 }
35 } catch {
36 // WeakRef not available or construction failed
37 }
38 return value;
39}
40
41/**
42 * Resolves a potentially weak reference, returning the underlying object

Callers 4

weakRef.test.tsFile · 0.90
_setSpanForScopeFunction · 0.90
setCapturedScopesOnSpanFunction · 0.90
setContextOnScopeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected