0x-2a / esprima-selector

ask whether a particular esprima node matches a CSS-like selector

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

esprima-selector

Reeeeally early days, I'm sort of thinking out loud here.

var eselector = require('esprima-selector');

var src = falafel(fs.readFileSync('test.js', 'utf8'), eselector.tester([
	{
		selector: '*',
		callback: function (node) { console.log('node', node.name, node.classes) },
	},
	{
		selector: 'program',
		callback: function (node) {
			node.update("var indent = []; function start() { console.log(indent.join('') + '*'); indent.push('\t') } function end() { indent.pop() }" + node.source());
		},
	},
	{
		selector: 'program declaration.function > block',
		callback: function (node) {
			node.update("start();" + node.source() + "end();");
		},
	},
]));

About

ask whether a particular esprima node matches a CSS-like selector

License:MIT License


Languages

Language:JavaScript 100.0%