mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
Parse "exports" field from package.json (WIP)
This commit is contained in:
@@ -206,6 +206,10 @@ pub inline fn endsWith(self: string, str: string) bool {
|
||||
return str.len == 0 or @call(.{ .modifier = .always_inline }, std.mem.endsWith, .{ u8, self, str });
|
||||
}
|
||||
|
||||
pub inline fn startsWithChar(self: string, char: u8) bool {
|
||||
return self.len > 0 and self[0] == char;
|
||||
}
|
||||
|
||||
pub inline fn endsWithChar(self: string, char: u8) bool {
|
||||
return self.len == 0 or self[self.len - 1] == char;
|
||||
}
|
||||
@@ -755,6 +759,15 @@ pub fn NewCodePointIterator(comptime CodePointType: type, comptime zeroValue: co
|
||||
pub const CodepointIterator = NewCodePointIterator(CodePoint, -1);
|
||||
pub const UnsignedCodepointIterator = NewCodePointIterator(u32, 0);
|
||||
|
||||
pub fn NewLengthSorter(comptime Type: type, comptime field: string) type {
|
||||
return struct {
|
||||
const LengthSorter = @This();
|
||||
pub fn lessThan(context: LengthSorter, lhs: Type, rhs: Type) bool {
|
||||
return @field(lhs, field).len < @field(rhs, field).len;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
test "join" {
|
||||
var string_list = &[_]string{ "abc", "def", "123", "hello" };
|
||||
const list = try join(string_list, "-", std.heap.page_allocator);
|
||||
|
||||
Reference in New Issue
Block a user