package.build.esm.memo.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utils Show documentation
Show all versions of utils Show documentation
Utilities for all Sentry JavaScript SDKs
{"version":3,"file":"memo.js","sources":["../../src/memo.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nexport type MemoFunc = [\n // memoize\n (obj: any) => boolean,\n // unmemoize\n (obj: any) => void,\n];\n\n/**\n * Helper to decycle json objects\n */\nexport function memoBuilder(): MemoFunc {\n const hasWeakSet = typeof WeakSet === 'function';\n const inner: any = hasWeakSet ? new WeakSet() : [];\n function memoize(obj: any): boolean {\n if (hasWeakSet) {\n if (inner.has(obj)) {\n return true;\n }\n inner.add(obj);\n return false;\n }\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < inner.length; i++) {\n const value = inner[i];\n if (value === obj) {\n return true;\n }\n }\n inner.push(obj);\n return false;\n }\n\n function unmemoize(obj: any): void {\n if (hasWeakSet) {\n inner.delete(obj);\n } else {\n for (let i = 0; i < inner.length; i++) {\n if (inner[i] === obj) {\n inner.splice(i, 1);\n break;\n }\n }\n }\n }\n return [memoize, unmemoize];\n}\n"],"names":[],"mappings":"AAAA;AACA;;AASA;AACA;AACA;AACO,SAAS,WAAW,GAAa;AACxC,EAAE,MAAM,UAAW,GAAE,OAAO,OAAA,KAAY,UAAU,CAAA;AAClD,EAAE,MAAM,KAAK,GAAQ,UAAW,GAAE,IAAI,OAAO,EAAC,GAAI,EAAE,CAAA;AACpD,EAAE,SAAS,OAAO,CAAC,GAAG,EAAgB;AACtC,IAAI,IAAI,UAAU,EAAE;AACpB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AAC1B,QAAQ,OAAO,IAAI,CAAA;AACnB,OAAM;AACN,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACpB,MAAM,OAAO,KAAK,CAAA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