Thụy Sĩcodpro2005/ts-regexp
A RegExp wrapper providing stronger type safety.
Thành tựu nổi bật
Những danh hiệu mới nhất của dự án
#1 Repository Của Tháng
#1 Repository Của Tháng
#1 Repository Của Tháng
🧠 ts-regexp: RegExp có type safety thực sự
Wrapper RegExp tự động suy luận kiểu capture groups tại thời điểm biên dịch.
ts-regexp là một thư viện TypeScript nhỏ gọn, cung cấp hàm regex thay thế RegExp với khả năng suy luận kiểu (type inference) chính xác cho cả capture groups thứ tự và tên. Thay vì nhận về { [key: string]: string } như RegExp native, ts-regexp trả về kiểu rõ ràng như { year: string; month: string; day: string }.
✨ Điểm nổi bật
- Type inference cho capture groups: Tự động suy luận kiểu từ pattern, không cần ép kiểu.
- Hỗ trợ capture có tên: Các nhóm
(?<name>...)được ánh xạ thành object có khóa tương ứng. - Phương thức chuẩn:
exec,testhoạt động nhưRegExpnhưng có typing chính xác. - Regex-first methods:
matchIn,replaceIn,searchIn,splitInđảo ngược thứ tự tham số để type-safe hơn. - Global flag methods:
matchAllIn,replaceAllInchỉ khả dụng khi có flagg. - Fallback RegExp: Truy cập
pattern.regExpđể lấy instanceRegExpgốc khi cần. - Utility type
Parse<T>: Phân tích pattern tại mức type để lấy captures và namedCaptures.
💡 Vì sao đáng chú ý
ts-regexp khác biệt từ RegExp native ở khả năng suy luận kiểu tĩnh thời gian biên dịch, giúp tránh lỗi truy cập sai key hoặc kiểu sai từ capture groups. Phù hợp cho dự án TypeScript cần xử lý regex phức tạp với độ tin cậy cao.
#TypeScript #RegExp #TypeSafety #Regex #OpenSource #TiniX
Dự án tương tự
Khám phá các dự án và mô hình AI khác có sự tương đồng.
ESLint plugin for finding regex mistakes and style guide violations.
A command-line tool and Rust library with Python bindings for generating regular expressions from user-provided test cases
Melody is a language that compiles to regular expressions and aims to be more readable and maintainable
A regular expression to match all Emoji-only symbols as per the Unicode Standard.
Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.