Sha256: 5a518f882978cb687e4154cff69b946eaa433b4e2749eca952287e7d3cb07017

Contents?: true

Size: 1.21 KB

Versions: 41

Compression:

Stored size: 1.21 KB

Contents

var noop = function() {};

function ensureFunction(value) {
    return typeof value === 'function' ? value : noop;
}

module.exports = function(node, options, context) {
    function walk(node) {
        enter.call(context, node);

        switch (node.type) {
            case 'Group':
                node.terms.forEach(walk);
                break;

            case 'Multiplier':
                walk(node.term);
                break;

            case 'Type':
            case 'Property':
            case 'Keyword':
            case 'AtKeyword':
            case 'Function':
            case 'String':
            case 'Token':
            case 'Comma':
                break;

            default:
                throw new Error('Unknown type: ' + node.type);
        }

        leave.call(context, node);
    }

    var enter = noop;
    var leave = noop;

    if (typeof options === 'function') {
        enter = options;
    } else if (options) {
        enter = ensureFunction(options.enter);
        leave = ensureFunction(options.leave);
    }

    if (enter === noop && leave === noop) {
        throw new Error('Neither `enter` nor `leave` walker handler is set or both aren\'t a function');
    }

    walk(node, context);
};

Version data entries

41 entries across 31 versions & 9 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/css-tree/lib/definition-syntax/walk.js
optimacms-0.1.61 spec/dummy/node_modules/csso/node_modules/css-tree/lib/definition-syntax/walk.js
disco_app-0.18.0 test/dummy/node_modules/css-tree/lib/lexer/grammar/walk.js
disco_app-0.18.2 test/dummy/node_modules/css-tree/lib/lexer/grammar/walk.js
disco_app-0.16.1 test/dummy/node_modules/css-tree/lib/lexer/grammar/walk.js
disco_app-0.15.2 test/dummy/node_modules/css-tree/lib/lexer/grammar/walk.js
disco_app-0.18.4 test/dummy/node_modules/css-tree/lib/lexer/grammar/walk.js
disco_app-0.18.1 test/dummy/node_modules/css-tree/lib/lexer/grammar/walk.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/css-tree/lib/lexer/grammar/walk.js
disco_app-0.14.0 test/dummy/node_modules/css-tree/lib/lexer/grammar/walk.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/css-tree/lib/lexer/grammar/walk.js
isomorfeus-preact-10.5.7 node_modules/css-tree/lib/definition-syntax/walk.js
isomorfeus-preact-10.5.6 node_modules/css-tree/lib/definition-syntax/walk.js
isomorfeus-preact-10.5.5 node_modules/css-tree/lib/definition-syntax/walk.js
isomorfeus-preact-10.5.4 node_modules/css-tree/lib/definition-syntax/walk.js
isomorfeus-preact-10.5.3 node_modules/css-tree/lib/definition-syntax/walk.js
isomorfeus-preact-10.5.2 node_modules/css-tree/lib/definition-syntax/walk.js
tang-0.2.1 spec/tang_app/node_modules/csso/node_modules/css-tree/lib/definition-syntax/walk.js
tang-0.2.1 spec/tang_app/node_modules/css-tree/lib/definition-syntax/walk.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/csso/node_modules/css-tree/lib/definition-syntax/walk.js