UNPKG

twing

Version:

First-class Twig engine for Node.js

35 lines (34 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createNode = exports.createBaseNode = exports.getChildrenCount = exports.getChildren = void 0; const getChildren = (node) => { return Object.entries(node.children); }; exports.getChildren = getChildren; const getChildrenCount = (node) => { return Object.keys(node.children).length; }; exports.getChildrenCount = getChildrenCount; const createBaseNode = (type, attributes = {}, children = {}, line = 0, column = 0, tag = null) => { return { attributes, children, column, line, tag, type }; }; exports.createBaseNode = createBaseNode; /** * Create a node acting as a container for the passed list of indexed nodes. * * @param children The children of the created node * @param line The line of the created node * @param column The column of the created node * @param tag The tag of the created node */ const createNode = (children = {}, line = 0, column = 0, tag = null) => { return (0, exports.createBaseNode)(null, {}, children, line, column, tag); }; exports.createNode = createNode;