feat: bun patch (#11470)

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: zackradisic <zackradisic@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
Zack Radisic
2024-06-06 17:48:05 -07:00
committed by GitHub
parent 12f070d1a0
commit c85dd4e3bf
31 changed files with 6273 additions and 1420 deletions

View File

@@ -4037,6 +4037,20 @@ pub fn encodeBytesToHex(destination: []u8, source: []const u8) usize {
return to_read * 2;
}
/// Leave a single leading char
/// ```zig
/// trimSubsequentLeadingChars("foo\n\n\n\n", '\n') -> "foo\n"
/// ```
pub fn trimSubsequentLeadingChars(slice: []const u8, char: u8) []const u8 {
if (slice.len == 0) return slice;
var end = slice.len - 1;
var endend = slice.len;
while (end > 0 and slice[end] == char) : (end -= 1) {
endend = end + 1;
}
return slice[0..endend];
}
pub fn trimLeadingChar(slice: []const u8, char: u8) []const u8 {
if (indexOfNotChar(slice, char)) |i| {
return slice[i..];