Have ideas to improve npm?Join in the discussion! »

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

0.0.8 • 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 package
  • consider other set operations (diff, complementary, ...)

Install

npm i csset

DownloadsWeekly Downloads

14

Version

0.0.8

License

MIT

Unpacked Size

90.7 kB

Total Files

67

Last publish

Collaborators

  • avatar