def split
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytesimport Base
540# The pieces between matches of sep (a byte string), left to right. n matches give n + 1
541# pieces, so a match at either end gives an empty piece. An empty sep gives b whole.
542def split(b: Bytes, +sep: String) -> List<&1, Bytes>:
543 Bytes{+len, buf} = b
544 +m = count(sep, 0)
545 split.if(Bool.or(U32.is_eq(m, 0), U32.is_lt(len, m)), len, buf, sep, m)