Installations
npm install inline-style-parser
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
20.17.0
NPM Version
10.8.2
Statistics
19 Stars
309 Commits
1 Forks
1 Watching
1 Branches
1 Contributors
Updated on 27 Nov 2024
Bundle Size
1.66 kB
Minified
909.00 B
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
969,550,095
Last day
-1.6%
1,390,594
Compared to previous day
Last week
4.3%
7,302,938
Compared to previous week
Last month
12.6%
30,525,488
Compared to previous month
Last year
13.2%
313,975,418
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
inline-style-parser
Inline style parser copied from css/lib/parse/index.js
:
InlineStyleParser(string)
Example:
1const parse = require('inline-style-parser'); 2 3parse('color: #BADA55;');
Output:
1[ { type: 'declaration', 2 property: 'color', 3 value: '#BADA55', 4 position: Position { start: [Object], end: [Object], source: undefined } } ]
Installation
NPM:
1npm install inline-style-parser --save
Yarn:
1yarn add inline-style-parser
CDN:
1<script src="https://unpkg.com/inline-style-parser@latest/dist/inline-style-parser.min.js"></script> 2<script> 3 window.InlineStyleParser(/* string */); 4</script>
Usage
Import with ES Modules:
1import parse from 'inline-style-parser';
Or require with CommonJS:
1const parse = require('inline-style-parser');
Parse single declaration:
1parse('left: 0');
Output:
1[ 2 { 3 type: 'declaration', 4 property: 'left', 5 value: '0', 6 position: { 7 start: { line: 1, column: 1 }, 8 end: { line: 1, column: 8 }, 9 source: undefined 10 } 11 } 12]
Parse multiple declarations:
1parse('left: 0; right: 100px;');
Output:
1[ 2 { 3 type: 'declaration', 4 property: 'left', 5 value: '0', 6 position: { 7 start: { line: 1, column: 1 }, 8 end: { line: 1, column: 8 }, 9 source: undefined 10 } 11 }, 12 { 13 type: 'declaration', 14 property: 'right', 15 value: '100px', 16 position: { 17 start: { line: 1, column: 10 }, 18 end: { line: 1, column: 22 }, 19 source: undefined 20 } 21 } 22]
Parse declaration with missing value:
1parse('top:');
Output:
1[ 2 { 3 type: 'declaration', 4 property: 'top', 5 value: '', 6 position: { 7 start: { line: 1, column: 1 }, 8 end: { line: 1, column: 5 }, 9 source: undefined 10 } 11 } 12]
Parse unknown declaration:
1parse('answer: 42;');
Output:
1[ 2 { 3 type: 'declaration', 4 property: 'answer', 5 value: '42', 6 position: { 7 start: { line: 1, column: 1 }, 8 end: { line: 1, column: 11 }, 9 source: undefined 10 } 11 } 12]
Invalid declarations:
1parse(''); // [] 2parse(); // throws TypeError 3parse(1); // throws TypeError 4parse('width'); // throws Error 5parse('/*'); // throws Error
Testing
Run tests:
1npm test
Run tests in watch mode:
1npm run test:watch
Run tests with coverage:
1npm run test:coverage
Run tests in CI mode:
1npm run test:ci
Lint files:
1npm run lint
Fix lint errors:
1npm run lint:fix
Release
Release and publish are automated by Release Please.
License
No vulnerabilities found.
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
- Info: security policy file detected: .github/SECURITY.md:1
- Info: Found linked content: .github/SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: .github/SECURITY.md:1
- Info: Found text in security policy: .github/SECURITY.md:1
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release-please.yml:20
Reason
SAST tool is run on all commits
Details
- Info: all commits (30) are checked with a SAST tool
Reason
0 existing vulnerabilities detected
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkablemark/inline-style-parser/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkablemark/inline-style-parser/build.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkablemark/inline-style-parser/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/commitlint.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkablemark/inline-style-parser/commitlint.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/commitlint.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkablemark/inline-style-parser/commitlint.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkablemark/inline-style-parser/lint.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkablemark/inline-style-parser/lint.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release-please.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkablemark/inline-style-parser/release-please.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-please.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkablemark/inline-style-parser/release-please.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-please.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/remarkablemark/inline-style-parser/release-please.yml/master?enable=pin
- Info: 0 out of 8 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 4 out of 4 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/release-please.yml:23
- Warn: no topLevel permission defined: .github/workflows/build.yml:1
- Warn: no topLevel permission defined: .github/workflows/commitlint.yml:1
- Warn: no topLevel permission defined: .github/workflows/lint.yml:1
- Warn: no topLevel permission defined: .github/workflows/release-please.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Score
7.5
/10
Last Scanned on 2024-11-18
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 MoreOther packages similar to inline-style-parser
yargs-parser
the mighty option parser used by yargs
fast-xml-parser
Validate XML, Parse XML, Build XML without C/C++ based libraries
@typescript-eslint/parser
An ESLint custom parser which leverages TypeScript ESTree
ua-parser-js
Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent & Client Hints data. Supports browser & node.js environment