csset
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

csset

Set operations for CSS selectors

GitHub license Issues Build Status Coverage Status Code Size Weekly downloads

Install

npm install --save csset

Requirements

Works in all modern browsers :)

Usage

Basic

import { Csset } from 'csset';

// Create your sets
const set1 = new Csset('div > p');
const set2 = new Csset('div');
const set3 = new Csset('p');

// Make set operations
// supersetOf
console.assert(set1.supersetOf(set2) === false);
console.assert(set2.supersetOf(set1) === false);
console.assert(set3.supersetOf(set1) === true);

// subsetOf
console.assert(set1.subsetOf(set3) === true);
console.assert(set1.subsetOf(set2) === false);

// union
console.assert(set1.union(set3).toString() === 'p');
console.assert(set1.union(set2).toString() === 'div > p, div');

// intersection
console.assert(set1.intersection(set3).toString() === 'div > p');
console.assert(set1.intersection(set2) === undefined); // void means empty set

Known issues & limitations

  • As for now pseudo selectors are not supported

Roadmap

  • Add better support for complex CSS selectors using parsel-ts package
  • consider other set operations (diff, complementary, ...)

Release notes

[0.0.9]

  • Added build for ESM modules

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.9
    0
    • latest

Version History

Package Sidebar

Install

npm i csset

Weekly Downloads

3

Version

0.0.9

License

MIT

Unpacked Size

186 kB

Total Files

133

Last publish

Collaborators

  • david.luna