Function
partition
(str: string, delimiter: string)
Source from the content-addressed store, hash-verified
| 488 | } |
| 489 | |
| 490 | function partition(str: string, delimiter: string): [string, string, string] { |
| 491 | const index = str.indexOf(delimiter); |
| 492 | if (index !== -1) { |
| 493 | return [ |
| 494 | str.substring(0, index), |
| 495 | delimiter, |
| 496 | str.substring(index + delimiter.length) |
| 497 | ]; |
| 498 | } |
| 499 | |
| 500 | return [str, '', '']; |
| 501 | } |
| 502 | |
| 503 | /** |
| 504 | * Most browsers don't yet have async iterable support for ReadableStream, |
Tested by
no test coverage detected