()
| 191 | // statements) so the whole selection is pure-annotated by the build and |
| 192 | // tree-shakable when `internalCall` is unused. |
| 193 | const pickInternalCall = (): <A>(body: () => A) => A => { |
| 194 | const InternalTypeId = "~effect/Utils/internal" |
| 195 | |
| 196 | const standard = { |
| 197 | [InternalTypeId]: <A>(body: () => A) => { |
| 198 | return body() |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | const forced = { |
| 203 | [InternalTypeId]: <A>(body: () => A) => { |
| 204 | try { |
| 205 | return body() |
| 206 | } finally { |
| 207 | // |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | const limit = getStackTraceLimit() |
| 213 | if (limit === 0) return forced[InternalTypeId] |
| 214 | // Only the callback and internal call frames are needed for detection. |
| 215 | setStackTraceLimit(2) |
| 216 | const error = standard[InternalTypeId](() => new Error()) |
| 217 | setStackTraceLimit(limit) |
| 218 | return error.stack?.includes(InternalTypeId) === true ? standard[InternalTypeId] : forced[InternalTypeId] |
| 219 | } |
| 220 | |
| 221 | /** @internal */ |
| 222 | export const internalCall = pickInternalCall() |
no test coverage detected