Get unlimited public & private packages + team-based management with npm Teams.Learn more »

css-obj

0.0.1 • Public • Published

css-obj

Parse css to js obj model

It is very simple right now

It requires:

  • no comments
  • one space before {
  • } or one key/value pair in each line
  • strictly {key}: {value};
  • so on ..

Usage

Source:

.hidden {
  display: none;
}
a:hover,
.btn.active {
  display: block;
  color: yellow;
}

Parsing:

var parseCss = require('css-obj')
parseCss(css, function(err, obj){
  console.log(obj)
})

Outputs:

[
  [
    '.hidden', {
      'display': 'none'
    }
  ],
  [
    'a:hover, .btn.active', {
      'display': 'block',
      'color': 'yellow'
    }
  ]
]

Install

npm i css-obj

DownloadsWeekly Downloads

8

Version

0.0.1

License

none

Last publish

Collaborators

  • avatar