New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tiny-css-parser

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-css-parser

A very small css parser

  • 0.10.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-18.18%
Maintainers
1
Weekly downloads
 
Created
Source

Tiny Css Parser

Install size Dependencies NPM version

A very small css parser.

Consists of a lazy tokenizer, a lazy parser and an incremental tree builder. Both the tokenizer as well as the parser produce a stream of tokens.

The parser inserts properly balanced start and end tokens into the stream, effectively producing a traversal of the full parse tree. This stream can be fed to the tree builder to incrementally build an object tree from the stream.

Example

To parse a stylesheet into an object tree:

var css = require ('tiny-css-parser')
var tree = css.parseTree ('#menu { padding:0; margin:0; display:block }')
console.log (tree)

To lazily parse and traverse a stylesheet:

var stream = css.parse ('#menu { padding:0; margin:0; display:block }')

for (var token of stream)
  console.log (token)

It is possible to query the stream for state info and source position, as follows:

var stream = css.parse ('#menu { padding:0; margin:0; display:block }')

for (var token of stream)
  console.log (token, stream.state)

API

  • tokenize (string) (generator function)
  • parse (string) (generator function)
  • parseTree (string) (function)
  • tokens (object/ dictionary)

Keywords

FAQs

Package last updated on 15 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc