Update README.md
Felix Böhm authored 6 years ago
GitHub committed 6 years ago
0 | #nth-check [![Build Status](https://travis-ci.org/fb55/nth-check.png)](https://travis-ci.org/fb55/nth-check) | |
0 | # nth-check [![Build Status](https://travis-ci.org/fb55/nth-check.svg)](https://travis-ci.org/fb55/nth-check) | |
1 | 1 | |
2 | 2 | A performant nth-check parser & compiler. |
3 | 3 | |
4 | ###About | |
4 | ### About | |
5 | 5 | |
6 | 6 | This module can be used to parse & compile nth-checks, as they are found in CSS 3's `nth-child()` and `nth-last-of-type()`. |
7 | 7 | |
8 | 8 | `nth-check` focusses on speed, providing optimized functions for different kinds of nth-child formulas, while still following the [spec](http://www.w3.org/TR/css3-selectors/#nth-child-pseudo). |
9 | 9 | |
10 | ###API | |
10 | ### API | |
11 | 11 | |
12 | 12 | ```js |
13 | 13 | var nthCheck = require("nth-check"); |
14 | 14 | ``` |
15 | 15 | |
16 | #####`nthCheck(formula)` | |
16 | ##### `nthCheck(formula)` | |
17 | 17 | |
18 | 18 | First parses, then compiles the formula. |
19 | 19 | |
20 | #####`nthCheck.parse(formula)` | |
20 | ##### `nthCheck.parse(formula)` | |
21 | 21 | |
22 | 22 | Parses the expression, throws a `SyntaxError` if it fails, otherwise returns an array containing two elements. |
23 | 23 | |
27 | 27 | nthCheck.parse("2n+3") //[2, 3] |
28 | 28 | ``` |
29 | 29 | |
30 | #####`nthCheck.compile([a, b])` | |
30 | ##### `nthCheck.compile([a, b])` | |
31 | 31 | |
32 | 32 | Takes an array with two elements (as returned by `.parse`) and returns a highly optimized function. |
33 | 33 |