1- // import type { Matcher, Expression } from 'path-expression-matcher';
1+ import type pem = require( './pem' ) ;
2+ type Expression = pem . Expression ;
3+ type ReadonlyMatcher = pem . ReadonlyMatcher ;
24
3- type Matcher = unknown ;
4- type Expression = unknown ;
5+ // jPath: true → string
6+ // jPath: false → ReadonlyMatcher
7+ type JPathOrMatcher = string | ReadonlyMatcher ;
8+ type JPathOrExpression = string | Expression ;
59
610type ProcessEntitiesOptions = {
711 /**
@@ -63,7 +67,7 @@ type ProcessEntitiesOptions = {
6367 *
6468 * Defaults to `null`
6569 */
66- tagFilter ?: ( ( tagName : string , jPathOrMatcher : string | Matcher ) => boolean ) | null ;
70+ tagFilter ?: ( ( tagName : string , jPathOrMatcher : JPathOrMatcher ) => boolean ) | null ;
6771} ;
6872
6973type X2jOptions = {
@@ -108,7 +112,7 @@ type X2jOptions = {
108112 *
109113 * Defaults to `true`
110114 */
111- ignoreAttributes ?: boolean | ( string | RegExp ) [ ] | ( ( attrName : string , jPathOrMatcher : string | Matcher ) => boolean ) ;
115+ ignoreAttributes ?: boolean | ( string | RegExp ) [ ] | ( ( attrName : string , jPathOrMatcher : JPathOrMatcher ) => boolean ) ;
112116
113117 /**
114118 * Whether to remove namespace string from tag and attribute names
@@ -175,7 +179,7 @@ type X2jOptions = {
175179 *
176180 * Defaults to `(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode) => val`
177181 */
178- tagValueProcessor ?: ( tagName : string , tagValue : string , jPathOrMatcher : string | Matcher , hasAttributes : boolean , isLeafNode : boolean ) => unknown ;
182+ tagValueProcessor ?: ( tagName : string , tagValue : string , jPathOrMatcher : JPathOrMatcher , hasAttributes : boolean , isLeafNode : boolean ) => unknown ;
179183
180184 /**
181185 * Control how attribute value should be parsed
@@ -188,7 +192,7 @@ type X2jOptions = {
188192 *
189193 * Defaults to `(attrName, val, jPathOrMatcher) => val`
190194 */
191- attributeValueProcessor ?: ( attrName : string , attrValue : string , jPathOrMatcher : string | Matcher ) => unknown ;
195+ attributeValueProcessor ?: ( attrName : string , attrValue : string , jPathOrMatcher : JPathOrMatcher ) => unknown ;
192196
193197 /**
194198 * Options to pass to `strnum` for parsing numbers
@@ -206,7 +210,7 @@ type X2jOptions = {
206210 *
207211 * Defaults to `[]`
208212 */
209- stopNodes ?: ( string | Expression ) [ ] ;
213+ stopNodes ?: JPathOrExpression [ ] ;
210214
211215 /**
212216 * List of tags without closing tags
@@ -233,7 +237,7 @@ type X2jOptions = {
233237 *
234238 * Defaults to `() => false`
235239 */
236- isArray ?: ( tagName : string , jPathOrMatcher : string | Matcher , isLeafNode : boolean , isAttribute : boolean ) => boolean ;
240+ isArray ?: ( tagName : string , jPathOrMatcher : JPathOrMatcher , isLeafNode : boolean , isAttribute : boolean ) => boolean ;
237241
238242 /**
239243 * Whether to process default and DOCTYPE entities
@@ -295,7 +299,7 @@ type X2jOptions = {
295299 *
296300 * Defaults to `(tagName, jPathOrMatcher, attrs) => tagName`
297301 */
298- updateTag ?: ( tagName : string , jPathOrMatcher : string | Matcher , attrs : { [ k : string ] : string } ) => string | boolean ;
302+ updateTag ?: ( tagName : string , jPathOrMatcher : JPathOrMatcher , attrs : { [ k : string ] : string } ) => string | boolean ;
299303
300304 /**
301305 * If true, adds a Symbol to all object nodes, accessible by {@link XMLParser.getMetaDataSymbol} with
@@ -477,7 +481,7 @@ type XmlBuilderOptions = {
477481 *
478482 * Defaults to `[]`
479483 */
480- stopNodes ?: ( string | Expression ) [ ] ;
484+ stopNodes ?: JPathOrExpression [ ] ;
481485
482486 /**
483487 * Control how tag value should be parsed. Called only if tag value is not empty
@@ -589,7 +593,11 @@ declare namespace fxp {
589593 strnumOptions ,
590594 validationOptions ,
591595 ProcessEntitiesOptions ,
596+ Expression ,
597+ ReadonlyMatcher ,
598+ JPathOrMatcher ,
599+ JPathOrExpression ,
592600 }
593601}
594602
595- export = fxp ;
603+ export = fxp ;
0 commit comments