css
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
inherits | 2.0.4 | 1.98 kB | ISC | prod | |
source-map-resolve | 0.6.0 | 7.46 kB | MIT | prod | 1 |
source-map | 0.6.1 | 194.96 kB | BSD-3-Clause | prod |
CSS is an npm package that is a robust CSS parser and stringifier in JavaScript. It is capable of accepting CSS strings and returning AST (Abstract Syntax Tree) objects. Moreover, it can also take an AST object to return a CSS string. CSS provides functionalities for error handling during parsing where you can either let errors be thrown or silently fail on parse errors. It also allows working with source maps, which helps identify where your code comes from.
You can use CSS by installing it first in your project using the npm install command:
$ npm install css
After installation, you can require it in your JavaScript code and start using its parse
and stringify
methods. For instance, to parse a CSS string into an AST object:
var css = require('css');
var options = { source: 'source.css' };
var obj = css.parse('body { font-size: 12px; }', options);
In this example, obj
will contain the AST object for the provided CSS string.
To turn an AST object back into a CSS string, you can use stringify
:
var cssString = css.stringify(obj, options);
In this example, cssString
will contain the CSS string that represents the obj
AST object.
For more complex and detailed usage, please reference the readme documentation.
The documentation for CSS npm package can be found in the package's readme file on GitHub at https://github.com/reworkcss/css. This contains detailed guide on how to use the package, examples to help you understand the API, and extra information such as API methods, options for methods, error handling, Abstract Syntax Tree (AST) and its properties.