@tbela99/css-parser
    Preparing search index...

    Function walkValues

    • walk ast node value tokens

      Parameters

      • values: Token[]
      • root: any = null
      • Optionalfilter:
            | WalkerValueFilter
            | {
                event?: WalkerEvent;
                fn?: WalkerValueFilter;
                type?: EnumToken
                | EnumToken[]
                | ((token: Token) => boolean);
            }
            | null
      • Optionalreverse: boolean

        Example:


        import {AstDeclaration, EnumToken, transform, walkValues} from '@tbela99/css-parser';

        const css = `
        body { color: color(from var(--base-color) display-p3 r calc(g + 0.24) calc(b + 0.15)); }
        `;

        const result = await transform(css);
        const declaration = result.ast.chi[0].chi[0] as AstDeclaration;

        // walk the node attribute's tokens in reverse order
        for (const {value} of walkValues(declaration.val, null, null,true)) {

        console.error([EnumToken[value.typ], value.val]);
        }

        // [ "Color", "color" ]
        // [ "FunctionTokenType", "calc" ]
        // [ "Number", 0.15 ]
        // [ "Add", undefined ]
        // [ "Iden", "b" ]
        // [ "Whitespace", undefined ]
        // [ "FunctionTokenType", "calc" ]
        // [ "Number", 0.24 ]
        // [ "Add", undefined ]
        // [ "Iden", "g" ]
        // [ "Whitespace", undefined ]
        // [ "Iden", "r" ]
        // [ "Whitespace", undefined ]
        // [ "Iden", "display-p3" ]
        // [ "Whitespace", undefined ]
        // [ "FunctionTokenType", "var" ]
        // [ "DashedIden", "--base-color" ]
        // [ "Whitespace", undefined ]
        // [ "Iden", "from" ]

      Returns Generator<WalkAttributesResult>