Package list node-nth-check / 3ca5825
New upstream version 1.0.2 Xavier Guimard 1 year, 1 month ago
6 changed file(s) with 38 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
+0
-5
.travis.yml less more
0 language: node_js
1 node_js:
2 - 0.8
3 - "0.10"
4 - 0.11
0 Copyright (c) Felix Böhm
1 All rights reserved.
2
3 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
5 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
7 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
9 THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
10 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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)
11
22 A performant nth-check parser & compiler.
33
4 ###About
4 ### About
55
66 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()`.
77
88 `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).
99
10 ###API
10 ### API
1111
1212 ```js
1313 var nthCheck = require("nth-check");
1414 ```
1515
16 #####`nthCheck(formula)`
16 ##### `nthCheck(formula)`
1717
1818 First parses, then compiles the formula.
1919
20 #####`nthCheck.parse(formula)`
20 ##### `nthCheck.parse(formula)`
2121
2222 Parses the expression, throws a `SyntaxError` if it fails, otherwise returns an array containing two elements.
2323
2727 nthCheck.parse("2n+3") //[2, 3]
2828 ```
2929
30 #####`nthCheck.compile([a, b])`
30 ##### `nthCheck.compile([a, b])`
3131
3232 Takes an array with two elements (as returned by `.parse`) and returns a highly optimized function.
3333
0 {
1 "name": "nth-check",
2 "version": "1.0.2",
3 "lockfileVersion": 1,
4 "requires": true,
5 "dependencies": {
6 "boolbase": {
7 "version": "1.0.0",
8 "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
9 "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
10 }
11 }
12 }
00 {
11 "name": "nth-check",
2 "version": "1.0.1",
2 "version": "1.0.2",
33 "description": "performant nth-check parser & compiler",
44 "main": "index.js",
55 "scripts": {
99 "type": "git",
1010 "url": "https://github.com/fb55/nth-check"
1111 },
12 "files": [
13 "compile.js",
14 "index.js",
15 "parse.js"
16 ],
1217 "keywords": [
1318 "nth-child",
1419 "nth",
1520 "css"
1621 ],
1722 "author": "Felix Boehm <me@feedic.com>",
18 "license": "BSD",
23 "license": "BSD-2-Clause",
1924 "bugs": {
2025 "url": "https://github.com/fb55/nth-check/issues"
2126 },
00 var nthCheck = require("./"),
11 assert = require("assert");
22
3 var invalid = ["-", "asdf", "2n+-0", "2+0", "- 1n", "-1 n"];
3 var invalid = ["-", "- 1n", "-1 n", "2+0", "2n+-0", "an+b", "asdf", "b", "expr", "odd|even|x"];
44
55 function parseInvalid(){
66 invalid.forEach(function(formula){