Parse and stringify CSS declarations (such as the HTML style attribute).
This package is ESM only: Node 12+ is needed to use it and it must be imported
instead of required.
npm:
npm install css-declarationsimport {parse, stringify} from 'css_declarations'
var values = parse(`
color:/*red*/purple;
-webkit-border-radius: 3px !important;;
`)
// => {color: 'purple', webkitBorderRadius: '3px !important'}
stringify(values)
// => 'color: purple; -webkit-border-radius: 3px !important;'This package exports the following identifiers: parse, stringify.
There is no default export.
Parse CSS declarations from string to object.
When given, warning is called when an error is encountered
(Function).
Object.<string> — Declarations.
Serialize CSS declarations from object to string.
string — Serialized declarations.
Invoked when an error occurs.
Errors come from reworkcss/css.
reason(string) — English reason for error;offset(number) — Index-based position of error.