CSS AST traversal filters designed for CSS parsed by read-css
or css.parse
npm install reap-css
const reap = require('reap-css')
const read = require('read-css')
const tree = read("test.css")
const harvest = reap(tree)
harvest.selectors() // [".apple", ".orange", "button:enabled", ".flex\\@portrait"]
harvest.properties() // ["color", "border-radius", "color", "cursor", "display"]
harvest.media() // ["(color), (update)", "(orientation: portrait)"]
Collect array of selectors.
reap(tree).selectors()
Collect array of properties.
reap(tree).properties()
Collect array of media queries.
reap(tree).media()
Collect array of values.
reap(tree).collect("selectors")
Get array of AST nodes having the specified key
reap(tree).having("media")
Get array of AST nodes with the specified type.
reap(tree).type("rule")
Reap uses traverse to travese the AST. The traversal instance for the current tree is accessible via .traversal
reap(tree).traversal
npm install
npm test
npm run demo