(strings)
| 379 | |
| 380 | // This runs in O(n log n). |
| 381 | function commonPrefix(strings) { |
| 382 | if (strings.length === 0) { |
| 383 | return ''; |
| 384 | } |
| 385 | if (strings.length === 1) { |
| 386 | return strings[0]; |
| 387 | } |
| 388 | const sorted = ArrayPrototypeToSorted(strings); |
| 389 | const min = sorted[0]; |
| 390 | const max = sorted[sorted.length - 1]; |
| 391 | for (let i = 0; i < min.length; i++) { |
| 392 | if (min[i] !== max[i]) { |
| 393 | return StringPrototypeSlice(min, 0, i); |
| 394 | } |
| 395 | } |
| 396 | return min; |
| 397 | } |
| 398 | |
| 399 | function reverseString(line, from = '\r', to = '\r') { |
| 400 | const parts = StringPrototypeSplit(line, from); |
no outgoing calls
no test coverage detected
searching dependent graphs…