Back | Home
الـ Path الحالي: /home/picotech/domains/instantly.picotech.app/public_html/public/uploads/../uploads/../../../../instantly.picotech.app/homes/../../wa.picotech.app/public_html/node_modules/path-exists/../duplexify/./../././once/../cheerio/lib
الملفات الموجودة في هذا الـ Path:
.
..
api
cheerio.d.ts
cheerio.d.ts.map
cheerio.js
cheerio.js.map
esm
index.d.ts
index.d.ts.map
index.js
index.js.map
load.d.ts
load.d.ts.map
load.js
load.js.map
options.d.ts
options.d.ts.map
options.js
options.js.map
parse.d.ts
parse.d.ts.map
parse.js
parse.js.map
parsers
slim.d.ts
slim.d.ts.map
slim.js
slim.js.map
static.d.ts
static.d.ts.map
static.js
static.js.map
types.d.ts
types.d.ts.map
types.js
types.js.map
utils.d.ts
utils.d.ts.map
utils.js
utils.js.map

مشاهدة ملف: parse.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.update = exports.getParse = void 0;
var domutils_1 = require("domutils");
var domhandler_1 = require("domhandler");
/**
 * Get the parse function with options.
 *
 * @param parser - The parser function.
 * @returns The parse function with options.
 */
function getParse(parser) {
    /**
     * Parse a HTML string or a node.
     *
     * @param content - The HTML string or node.
     * @param options - The parser options.
     * @param isDocument - If `content` is a document.
     * @param context - The context node in the DOM tree.
     * @returns The parsed document node.
     */
    return function parse(content, options, isDocument, context) {
        if (typeof Buffer !== 'undefined' && Buffer.isBuffer(content)) {
            content = content.toString();
        }
        if (typeof content === 'string') {
            return parser(content, options, isDocument, context);
        }
        var doc = content;
        if (!Array.isArray(doc) && (0, domhandler_1.isDocument)(doc)) {
            // If `doc` is already a root, just return it
            return doc;
        }
        // Add conent to new root element
        var root = new domhandler_1.Document([]);
        // Update the DOM using the root
        update(doc, root);
        return root;
    };
}
exports.getParse = getParse;
/**
 * Update the dom structure, for one changed layer.
 *
 * @param newChilds - The new children.
 * @param parent - The new parent.
 * @returns The parent node.
 */
function update(newChilds, parent) {
    // Normalize
    var arr = Array.isArray(newChilds) ? newChilds : [newChilds];
    // Update parent
    if (parent) {
        parent.children = arr;
    }
    else {
        parent = null;
    }
    // Update neighbors
    for (var i = 0; i < arr.length; i++) {
        var node = arr[i];
        // Cleanly remove existing nodes from their previous structures.
        if (node.parent && node.parent.children !== arr) {
            (0, domutils_1.removeElement)(node);
        }
        if (parent) {
            node.prev = arr[i - 1] || null;
            node.next = arr[i + 1] || null;
        }
        else {
            node.prev = node.next = null;
        }
        node.parent = parent;
    }
    return parent;
}
exports.update = update;
//# sourceMappingURL=parse.js.map