| 388 | * @returns The parsed BigInt value or undefined if the value is not a valid BigInt. |
| 389 | */ |
| 390 | export const parseToBigIntOrUndefined = ( |
| 391 | value: string | number | bigint | null | undefined, |
| 392 | ): bigint | undefined => { |
| 393 | try { |
| 394 | if (value === undefined || value === null) { |
| 395 | return undefined; |
| 396 | } |
| 397 | |
| 398 | if (typeof value === 'bigint') { |
| 399 | return value; |
| 400 | } |
| 401 | |
| 402 | if (typeof value === 'string') { |
| 403 | return value.trim() !== '' ? BigInt(value) : undefined; |
| 404 | } |
| 405 | |
| 406 | return BigInt(value); |
| 407 | } catch (_error) { |
| 408 | return undefined; |
| 409 | } |
| 410 | }; |
| 411 | |
| 412 | export const parseToNumberOrUndefined = ( |
| 413 | value: string | number | bigint | null | undefined, |