← All repos

nth-check

Parses and compiles CSS nth-checks to highly optimized functions.

csscss-selectornth-check
Browse cluster: HTML Parsing & Error Tracking
1,091commits
10contributors
2languages

Tech stack & purpose

nth-check is a JavaScript module that parses and compiles CSS nth-checks—the selector formulas used in CSS3's `nth-child()` and `nth-last-of-type()` pseudo-classes—into highly optimized functions. The module provides an API for checking whether a given index matches an nth-rule, as well as for generating sequences of indices that satisfy a given rule, with a focus on performance while adhering to the CSS3 selector specification. It exports functions for parsing formulas into step and offset components, compiling those components into check functions, and generating index sequences, along with convenience methods that combine parsing and compilation.

Languages

TypeScript
91.7%
JavaScript
8.3%

Contributors