packageDocumentation module import { Node , NodeJSON } from "./Node" ; public export interface NodePathElementJSON { node : NodeJSON ; index : number ; isMarked ? : boolean ; children : NodePathElementJSON [ ] ; filteringData ? : NodePathFilteringDataJSON ; } public export interface NodePathElement { /** Node instance */ node : Node ; /** Node index  */ index : number ; /** Is this element part of the marked path */ isMarked ? : boolean ; /** Child path elements */ children : NodePathElement [ ] ; /** Additional filtering-related information */ filteringData ? : NodePathFilteringData ; } public export namespace NodePathElement { /** Serialize given [[NodePathElement]] to JSON */ export function toJSON ( npe ) { const result = { node : Node . toJSON ( npe . node ) , index : npe . index , children : npe . children . map ( NodePathElement . toJSON ) } ; if ( undefined !== npe . isMarked ) result . isMarked = npe . isMarked ; if ( undefined !== npe . filteringData ) result . filteringData = NodePathFilteringData . toJSON ( npe . filteringData ) ; return result ; } /** Deserialize [[NodePathElement]] from JSON */ export function fromJSON ( json ) { if ( typeof json === "string" ) return JSON . parse ( json , reviver ) ; const result = { index : json . index , node : Node . fromJSON ( json . node ) , children : listFromJSON ( json . children ) } ; if ( undefined !== json . isMarked ) result . isMarked = json . isMarked ; if ( undefined !== json . filteringData ) result . filteringData = NodePathFilteringData . fromJSON ( json . filteringData ) ; return result ; } internal export function reviver ( key , value ) { return key === "" ? fromJSON ( value ) : value ; } param json returns internal export function listFromJSON ( json ) { if ( typeof json === "string" ) return JSON . parse ( json , listReviver ) ; return json . map ( ( m ) => fromJSON ( m ) ) ; } internal export function listReviver ( key , value ) { return key === "" ? listFromJSON ( value ) : value ; } } public export interface NodePathFilteringDataJSON { occurances : number ; childrenOccurances : number ; } public export interface NodePathFilteringData { /** Number of filter matches in the current element */ matchesCount : number ; /** Number of filter matches in the current element's children (recursively) */ childMatchesCount : number ; } public export namespace NodePathFilteringData { /** Serialize given [[NodePathFilteringData]] to JSON */ export function toJSON ( npfd ) { return { occurances : npfd . matchesCount , childrenOccurances : npfd . childMatchesCount } ; } /** Deserialize [[NodePathFilteringData]] from JSON */ export function fromJSON ( json ) { return { matchesCount : json . occurances , childMatchesCount : json . childrenOccurances } ; } }