import { MutableTree } from './mutable-tree' ; import { transform } from './transformer' ; import { Node } from './node' ; import { SimpleOptions } from '../options' ; export const transformToTree = ( root , index , options , increment ) => { const map = new Map < string , Node > ( ) ; try { return transform ( [ index ] , root , options , map , increment ) ; } finally { map . clear ( ) ; } } ; export const createTree = ( roots ) => { const tree = new MutableTree ( ) ; tree . roots = roots ; return tree ; } ; export interface ElementTransformResult { tree : MutableTree ; count : number ; } export const createTreeFromElements = ( roots , options ) : ElementTransformResult => { const tree = new MutableTree ( ) ; let count = 0 ; tree . roots = roots . map ( ( r , index ) => transformToTree ( r , index , options , n => ( count += n ) ) ) ; return { tree , count } ; } ;