Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

style-search

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

style-search

Search CSS(-like) strings

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is style-search?

The style-search npm package is a utility for searching through CSS-like strings. It allows you to find specific patterns, such as selectors, properties, and values, within a CSS string. This can be particularly useful for building tools that need to analyze or transform CSS code.

What are style-search's main functionalities?

Search for Selectors

This feature allows you to search for CSS selectors within a CSS string. In the example, it searches for the '.' character, which indicates the start of a class selector, and logs the index where each selector is found.

const styleSearch = require('style-search');

const css = '.class1 { color: red; } .class2 { color: blue; }';

styleSearch({ source: css, target: '.' }, (match) => {
  console.log('Found selector at index:', match.startIndex);
});

Search for Properties

This feature allows you to search for specific CSS properties within a CSS string. In the example, it searches for the 'color' property and logs the index where each occurrence is found.

const styleSearch = require('style-search');

const css = '.class1 { color: red; } .class2 { color: blue; }';

styleSearch({ source: css, target: 'color' }, (match) => {
  console.log('Found property at index:', match.startIndex);
});

Search for Values

This feature allows you to search for specific CSS values within a CSS string. In the example, it searches for the 'red' value and logs the index where each occurrence is found.

const styleSearch = require('style-search');

const css = '.class1 { color: red; } .class2 { color: blue; }';

styleSearch({ source: css, target: 'red' }, (match) => {
  console.log('Found value at index:', match.startIndex);
});

Other packages similar to style-search

Keywords

FAQs

Package last updated on 12 Jun 2016

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