css-declarations
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.0 • Public • Published

    css-declarations

    Build Coverage Downloads Size

    Parse and stringify CSS declarations (such as the HTML style attribute).

    Install

    This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

    npm:

    npm install css-declarations

    Use

    import {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;'

    API

    This package exports the following identifiers: parse, stringify. There is no default export.

    parse(value[, options])

    Parse CSS declarations from string to object.

    options.warning

    When given, warning is called when an error is encountered (Function).

    Returns

    Object.<string> — Declarations.

    stringify(values)

    Serialize CSS declarations from object to string.

    Returns

    string — Serialized declarations.

    function warning(reason, offset)

    Invoked when an error occurs. Errors come from reworkcss/css.

    Parameters
    • reason (string) — English reason for error;
    • offset (number) — Index-based position of error.

    License

    MIT © Titus Wormer

    Install

    npm i css-declarations

    DownloadsWeekly Downloads

    5

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    8.72 kB

    Total Files

    5

    Last publish

    Collaborators

    • wooorm