* This function extracts the prefix from a value. * @param value - The value to extract the prefix from. * @returns The prefix and the suffix.
(value: TValue)
| 479 | * @returns The prefix and the suffix. |
| 480 | */ |
| 481 | function getPrefix<TValue, TPrefix>(value: TValue): TPrefix | NO_PREFIX { |
| 482 | // If the value is an array and the first element is a string or number, then the |
| 483 | // first element is the prefix. This is used to distinguish between values without |
| 484 | // the need for hashing unless there are multiple values for the same prefix. |
| 485 | if ( |
| 486 | Array.isArray(value) && |
| 487 | (typeof value[0] === `string` || |
| 488 | typeof value[0] === `number` || |
| 489 | typeof value[0] === `bigint`) |
| 490 | ) { |
| 491 | return value[0] as TPrefix |
| 492 | } |
| 493 | return NO_PREFIX |
| 494 | } |
| 495 | |
| 496 | /** |
| 497 | * This function checks if a value is a single value. |
no outgoing calls
no test coverage detected