Socket
Socket
Sign inDemoInstall

css-extractor

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    css-extractor

:gem: extracts class names and ids from CSS


Version published
Maintainers
1
Install size
7.25 kB
Created

Readme

Source

css-extractor

:gem: extracts class names and ids from CSS

Installing

$ npm install css-extractor

Basic Usage

var extractor = require('css-extractor');

var css = "#id, .class { color:#000 }";

extractor.extract(css);
// => ['#id','.class']

extract will return an array of all unique class names and ids found

Approach

This module was designed to be lightweight, with no dependencies, using RegExp patterns to trim the input CSS content and capture the class names and ids.

Testing

Tests are performed using the tap testing framework. To run:

$ npm install
$ npm test

The majority of existing test cases are meant to ensure compatibility with common and uncommon syntactic features and liberties available in CSS, including:

  • @media queries
  • attribute selectors: #id[href='#id-like']
  • arbitrary and non-mandatory spacing
  • comment blocks

For more on such cases, check out the .css files in test\fixtures

Keywords

FAQs

Last updated on 23 Mar 2017

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