Gathering detailed insights and metrics for @csstools/css-tokenizer
Gathering detailed insights and metrics for @csstools/css-tokenizer
Gathering detailed insights and metrics for @csstools/css-tokenizer
Gathering detailed insights and metrics for @csstools/css-tokenizer
npm install @csstools/css-tokenizer
Typescript
Module System
Min. Node Version
Node Version
NPM Version
100
Supply Chain
100
Quality
84.5
Maintenance
100
Vulnerability
100
License
CSS (43.36%)
JavaScript (30.33%)
TypeScript (22.68%)
HTML (3.06%)
Nunjucks (0.48%)
Shell (0.1%)
Total Downloads
370,342,792
Last Day
1,754,529
Last Week
9,112,123
Last Month
36,828,843
Last Year
246,530,035
MIT-0 License
963 Stars
4,267 Commits
75 Forks
9 Watchers
6 Branches
130 Contributors
Updated on May 14, 2025
Minified
Minified + Gzipped
Latest Version
3.0.3
Package Id
@csstools/css-tokenizer@3.0.3
Unpacked Size
71.08 kB
Size
14.68 kB
File Count
7
NPM Version
10.7.0
Node Version
22.1.0
Published on
Oct 25, 2024
Cumulative downloads
Total Downloads
Last Day
-1.1%
1,754,529
Compared to previous day
Last Week
12.1%
9,112,123
Compared to previous week
Last Month
13.1%
36,828,843
Compared to previous month
Last Year
119.3%
246,530,035
Compared to previous year
No dependencies detected.
Implemented from : https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/
Add CSS Tokenizer to your project:
1npm install @csstools/css-tokenizer --save-dev
1import { tokenizer, TokenType } from '@csstools/css-tokenizer'; 2 3const myCSS = `@media only screen and (min-width: 768rem) { 4 .foo { 5 content: 'Some content!' !important; 6 } 7} 8`; 9 10const t = tokenizer({ 11 css: myCSS, 12}); 13 14while (true) { 15 const token = t.nextToken(); 16 if (token[0] === TokenType.EOF) { 17 break; 18 } 19 20 console.log(token); 21}
Or use the tokenize
helper function:
1import { tokenize } from '@csstools/css-tokenizer'; 2 3const myCSS = `@media only screen and (min-width: 768rem) { 4 .foo { 5 content: 'Some content!' !important; 6 } 7} 8`; 9 10const tokens = tokenize({ 11 css: myCSS, 12}); 13 14console.log(tokens);
1{ 2 onParseError?: (error: ParseError) => void 3}
onParseError
The tokenizer is forgiving and won't stop when a parse error is encountered.
To receive parsing error information you can set a callback.
1import { tokenizer, TokenType } from '@csstools/css-tokenizer'; 2 3const t = tokenizer({ 4 css: '\\', 5}, { onParseError: (err) => console.warn(err) }); 6 7while (true) { 8 const token = t.nextToken(); 9 if (token[0] === TokenType.EOF) { 10 break; 11 } 12}
Parser errors will try to inform you where in the tokenizer logic the error happened. This tells you what kind of error occurred.
Things this package aims to be:
What it is not:
No vulnerabilities found.
Reason
30 commit(s) and 7 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
SAST tool detected but not run on all commits
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 0/23 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-05-12
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