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

cssauron

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssauron

create matching selectors from css for your very own nested object hierarchy

  • 1.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is cssauron?

cssauron is a lightweight library for creating custom CSS-like selectors for JavaScript objects. It allows you to define and use selectors to query and manipulate data structures in a way similar to how you would use CSS selectors to query and manipulate the DOM.

What are cssauron's main functionalities?

Creating a Custom Selector

This feature allows you to create a custom selector by defining how to map CSS-like properties to your JavaScript object properties. The code sample demonstrates creating a selector for a custom data structure and querying it.

const cssauron = require('cssauron');
const mySelector = cssauron({
  tag: 'type',
  class: 'className',
  id: 'id',
  children: 'children'
});

const data = {
  type: 'div',
  className: 'container',
  id: 'main',
  children: [
    { type: 'span', className: 'text', id: 'child1' },
    { type: 'span', className: 'text', id: 'child2' }
  ]
};

const matches = mySelector('div.container#main > span.text')(data);
console.log(matches);

Using the Selector

This feature demonstrates how to use the custom selector to query a data structure. The code sample shows how to find all 'span' elements with the class 'text' within the data structure.

const cssauron = require('cssauron');
const mySelector = cssauron({
  tag: 'type',
  class: 'className',
  id: 'id',
  children: 'children'
});

const data = {
  type: 'div',
  className: 'container',
  id: 'main',
  children: [
    { type: 'span', className: 'text', id: 'child1' },
    { type: 'span', className: 'text', id: 'child2' }
  ]
};

const matches = mySelector('span.text')(data);
console.log(matches);

Other packages similar to cssauron

Keywords

FAQs

Package last updated on 07 May 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