Gathering detailed insights and metrics for nth-check
Gathering detailed insights and metrics for nth-check
Gathering detailed insights and metrics for nth-check
Gathering detailed insights and metrics for nth-check
esquery
A query library for ECMAScript AST using a CSS selector like query language.
cheerio-select
CSS selector engine supporting jQuery selectors
@stdlib/constants-float64-max-safe-nth-factorial
Maximum safe nth factorial when stored in double-precision floating-point format.
croner
Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. All environments.
Parses and compiles CSS nth-checks to highly optimized functions.
npm install nth-check
99.6
Supply Chain
100
Quality
75.5
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
57 Stars
781 Commits
30 Forks
3 Watching
2 Branches
6 Contributors
Updated on 28 Nov 2024
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
-21.3%
3,915,961
Compared to previous day
Last week
-8.7%
27,830,542
Compared to previous week
Last month
2.1%
123,319,576
Compared to previous month
Last year
4.4%
1,330,364,669
Compared to previous year
Parses and compiles CSS nth-checks to highly optimized functions.
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()
. It can be used to check if a given index matches a given nth-rule, or to generate a sequence of indices matching a given nth-rule.
nth-check
focusses on speed, providing optimized functions for different kinds of nth-child formulas, while still following the spec.
1import nthCheck, { parse, compile } from "nth-check";
nthCheck(formula)
Parses and compiles a formula to a highly optimized function. Combination of parse
and compile
.
If the formula doesn't match any elements, it returns boolbase
's falseFunc
. Otherwise, a function accepting an index is returned, which returns whether or not the passed index matches the formula.
Note: The nth-rule starts counting at 1
, the returned function at 0
.
Example:
1const check = nthCheck("2n+3"); 2 3check(0); // `false` 4check(1); // `false` 5check(2); // `true` 6check(3); // `false` 7check(4); // `true` 8check(5); // `false` 9check(6); // `true`
parse(formula)
Parses the expression, throws an Error
if it fails. Otherwise, returns an array containing the integer step size and the integer offset of the nth rule.
Example:
1parse("2n+3"); // [2, 3]
compile([a, b])
Takes an array with two elements (as returned by .parse
) and returns a highly optimized function.
Example:
1const check = compile([2, 3]); 2 3check(0); // `false` 4check(1); // `false` 5check(2); // `true` 6check(3); // `false` 7check(4); // `true` 8check(5); // `false` 9check(6); // `true`
generate([a, b])
Returns a function that produces a monotonously increasing sequence of indices.
If the sequence has an end, the returned function will return null
after the last index in the sequence.
Example: An always increasing sequence
1const gen = nthCheck.generate([2, 3]); 2 3gen(); // `1` 4gen(); // `3` 5gen(); // `5` 6gen(); // `8` 7gen(); // `11`
Example: With an end value
1const gen = nthCheck.generate([-2, 5]); 2 3gen(); // 0 4gen(); // 2 5gen(); // 4 6gen(); // null
sequence(formula)
Parses and compiles a formula to a generator that produces a sequence of indices. Combination of parse
and generate
.
Example: An always increasing sequence
1const gen = nthCheck.sequence("2n+3"); 2 3gen(); // `1` 4gen(); // `3` 5gen(); // `5` 6gen(); // `8` 7gen(); // `11`
Example: With an end value
1const gen = nthCheck.sequence("-2n+5"); 2 3gen(); // 0 4gen(); // 2 5gen(); // 4 6gen(); // null
License: BSD-2-Clause
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
nth-check
for enterpriseAvailable as part of the Tidelift Subscription
The maintainers of nth-check
and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
The latest stable version of the package.
Stable Version
1
7.5/10
Summary
Inefficient Regular Expression Complexity in nth-check
Affected Versions
< 2.0.1
Patched Versions
2.0.1
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
SAST tool is run on all commits
Details
Reason
2 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More