( metadata: Record<string, V>, )
| 43 | * Returns the input unchanged (same reference) when no _PROTO_ keys present. |
| 44 | */ |
| 45 | export function stripProtoFields<V>( |
| 46 | metadata: Record<string, V>, |
| 47 | ): Record<string, V> { |
| 48 | let result: Record<string, V> | undefined |
| 49 | for (const key in metadata) { |
| 50 | if (key.startsWith('_PROTO_')) { |
| 51 | if (result === undefined) { |
| 52 | result = { ...metadata } |
| 53 | } |
| 54 | delete result[key] |
| 55 | } |
| 56 | } |
| 57 | return result ?? metadata |
| 58 | } |
| 59 | |
| 60 | // Internal type for logEvent metadata - different from the enriched EventMetadata in metadata.ts |
| 61 | type LogEventMetadata = { [key: string]: boolean | number | undefined } |
no outgoing calls
no test coverage detected