Socket
Socket
Sign inDemoInstall

css-zero-lexer

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    css-zero-lexer

Friendly and forgiving CSS lexer/parser with lots of tests. Memory-efficient and Web Worker compatible.


Version published
Maintainers
1
Install size
64.5 kB
Created

Readme

Source

xml-zero-lexer

Friendly and forgiving CSS/SASS/LESS lexer/parser with lots of tests. Memory-efficient and Web Worker compatible.

Features

  • Supports CSS, SASS and LESS.
  • Zero-copy

Usage

This is a zero-copy lexer/parser so it returns an array of offsets.

import Lexx, { NodeTypes } from 'css-zero-lexer';

const css = 'text { prop; prop2: value }';
const tokens = Lexx(xml);

// 'tokens' is now:
//   [
//    [NodeTypes.SELECTOR_NODE, 0, 4],
//    [NodeTypes.OPEN_RULE],
//    [NodeTypes.PROPERTY_NODE, 7, 11],
//    [NodeTypes.CLOSE_PROPERTY],
//    [NodeTypes.PROPERTY_NODE, 13, 27],
//    [NodeTypes.CLOSE_PROPERTY],
//    [NodeTypes.CLOSE_RULE]
//   ]

css.substring(tokens[0][1], tokens[0][2]);
// would return "text"

2.4KB gzipped.

Want to turn it back into CSS? Try css-zero-beautify.


Part of XML-Zero.js

Keywords

FAQs

Last updated on 24 Mar 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc