Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

css-scanner

douzi833ISC1.0.3

Scanner for css element

css, cssdom, css scanner

readme

css-scanner

Scanner for css element, refer to w3c css

var CssScanner = require('css-scanner');

install

npm install css-scanner --save

test

mocha

API

CssScanner(str, filepath)

CssScanner is inherit to Writable stream.

  • {string|undefined} str
    The css code string or empty
  • {string} filepath
    it's useful for see error message. `js var css = new CssScanner('a{color:red;}');

// or use pipe var css = new CssScanner(); fs.createReadStream('path/bootstrap.css').pipe(css);


### on
inherit the System events module. List emit event name
* ``comment``  
* ``rule``  
* ``@meida``  
if the name is undefined, it's means media close, otherwise media open
* ``@keyframes``  
if the name is undefined, it's means keyframes close, otherwise keyframes open
* ``@import``
* ``@charset``

```js
css.on('comment', function(match) {

});

css.on('rule', function(rule, type) {
  // rule: { selector: [], declaration: [{ property: '', value: ''}] }
  // type: if type exists, it's means this role is in @ rule, otherwise it's only a rule
});

css.on('@media', function(name) {
  // name -> string
  if (name) {
    // open

  } else {
    // close
  }
});

css.on('@keyframes', function(name) {
  // name -> { vendor: '', name: '' }
});

css.on('@import', function(name) {

});

css.on('@charset', function(name) {
});

scanner()

Start to scanner

// string
css.scanner();

// pipe
css.on('finish', function() {
  this.scanner();
});