PHP 7.4.33
Preview: search.cjs Size: 1.60 KB
/var/www/cookieconsent.bitkit.dk/httpdocs/node_modules/css-tree/cjs/lexer/search.cjs
'use strict';

const List = require('../utils/List.cjs');

function getFirstMatchNode(matchNode) {
    if ('node' in matchNode) {
        return matchNode.node;
    }

    return getFirstMatchNode(matchNode.match[0]);
}

function getLastMatchNode(matchNode) {
    if ('node' in matchNode) {
        return matchNode.node;
    }

    return getLastMatchNode(matchNode.match[matchNode.match.length - 1]);
}

function matchFragments(lexer, ast, match, type, name) {
    function findFragments(matchNode) {
        if (matchNode.syntax !== null &&
            matchNode.syntax.type === type &&
            matchNode.syntax.name === name) {
            const start = getFirstMatchNode(matchNode);
            const end = getLastMatchNode(matchNode);

            lexer.syntax.walk(ast, function(node, item, list) {
                if (node === start) {
                    const nodes = new List.List();

                    do {
                        nodes.appendData(item.data);

                        if (item.data === end) {
                            break;
                        }

                        item = item.next;
                    } while (item !== null);

                    fragments.push({
                        parent: list,
                        nodes
                    });
                }
            });
        }

        if (Array.isArray(matchNode.match)) {
            matchNode.match.forEach(findFragments);
        }
    }

    const fragments = [];

    if (match.matched !== null) {
        findFragments(match.matched);
    }

    return fragments;
}

exports.matchFragments = matchFragments;

Directory Contents

Dirs: 0 × Files: 14
Name Size Perms Modified Actions
3.40 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
6.68 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
207 B lrw-r--r-- 2025-06-16 05:45:40
Edit Download
4.35 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
17.09 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
85 B lrw-r--r-- 2025-06-16 05:45:40
Edit Download
14.85 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
12.38 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
19.30 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
1.12 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
1.60 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
5.12 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
1.70 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
1.67 KB lrw-r--r-- 2025-06-16 05:45:40
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).