@@ -18,7 +18,7 @@ export type ReturnObject = {
1818 pointer ?: string | undefined ;
1919} ;
2020export type JSONPathCallback = ( preferredOutput : any , type : "value" | "property" , fullRetObj : ReturnObject ) => void ;
21- export type OtherTypeCallback = ( val : unknown , path : ExpressionArray , parent : ParentValue , parentPropName : string | null ) => boolean | null ;
21+ export type OtherTypeCallback = ( val : unknown , path : ExpressionArray , parent : ParentValue , parentPropName : string | number | null ) => boolean | null ;
2222export type ContextItem = any ;
2323export type EvaluatedResult = any ;
2424export type EvalCallback = ( code : string , context : ContextItem ) => EvaluatedResult ;
@@ -60,6 +60,11 @@ export type JSONPathOptions = {
6060 * function which throws on encountering `@other`
6161 */
6262 otherTypeCallback ?: OtherTypeCallback | undefined ;
63+ /**
64+ * Map of custom
65+ * type operator names to their evaluation callbacks
66+ */
67+ customTypes ?: Record < string , OtherTypeCallback > | undefined ;
6368 autostart ?: boolean | undefined ;
6469 ignoreEvalErrors ?: boolean | undefined ;
6570} ;
@@ -99,7 +104,11 @@ export function JSONPath(opts: JSONPathOptions & {
99104 */
100105export function JSONPath ( opts : JSONPathOptions ) : unknown ;
101106export namespace JSONPath {
102- let cache : Record < string , unknown > ;
107+ /**
108+ * Clears cached parsed paths and compiled scripts.
109+ * @returns {void }
110+ */
111+ function clearCache ( ) : void ;
103112 /**
104113 * @param {string[] } pathArr Array to convert
105114 * @returns {string } The path string
@@ -148,6 +157,8 @@ export class JSONPathClass {
148157 currEval : EvalValue | undefined ;
149158 /** @type {OtherTypeCallback|undefined } */
150159 currOtherTypeCallback : OtherTypeCallback | undefined ;
160+ /** @type {Record<string, OtherTypeCallback>|undefined } */
161+ currCustomTypes : Record < string , OtherTypeCallback > | undefined ;
151162 /** @type {SandboxType|undefined } */
152163 currSandbox : SandboxType | undefined ;
153164 _hasParentSelector : boolean ;
@@ -163,6 +174,7 @@ export class JSONPathClass {
163174 parentProperty : ParentProperty | undefined ;
164175 callback : JSONPathCallback ;
165176 otherTypeCallback : OtherTypeCallback ;
177+ customTypes : Record < string , OtherTypeCallback > ;
166178 /**
167179 * @overload
168180 * @param {JSONPathOptions } [expr]
0 commit comments