* Compare the first `matchDigits` significant digits of two numeric strings. * Returns true if they match.
( ours: string, theirs: string, matchDigits: number )
| 42 | * Returns true if they match. |
| 43 | */ |
| 44 | function compareDigits( |
| 45 | ours: string, |
| 46 | theirs: string, |
| 47 | matchDigits: number |
| 48 | ): boolean { |
| 49 | const ourDigits = significantDigits(ours); |
| 50 | const theirDigits = significantDigits(theirs); |
| 51 | |
| 52 | const ourSlice = ourDigits.slice(0, matchDigits); |
| 53 | const theirSlice = theirDigits.slice(0, matchDigits); |
| 54 | |
| 55 | return ourSlice === theirSlice; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Format a comparison failure message showing where the digits diverge. |
no test coverage detected