22 * Declaration for https://github.com/s3u/JSONPath
33 */
44declare module 'jsonpath-plus' {
5- type JSONPathCallback = ( payload : any , payloadType : any , fullPayload : any ) => any
5+ type JSONPathCallback = (
6+ payload : any , payloadType : any , fullPayload : any
7+ ) => any
68
79 type JSONPathOtherTypeCallback = ( ...args : any [ ] ) => void
810
911 interface JSONPathOptions {
1012 /**
11- * The JSONPath expression as a (normalized or unnormalized) string or array.
13+ * The JSONPath expression as a (normalized or unnormalized) string or
14+ * array.
1215 */
1316 path : string | any [ ]
1417 /**
15- * The JSON object to evaluate (whether of null, boolean, number, string, object, or array type).
18+ * The JSON object to evaluate (whether of null, boolean, number,
19+ * string, object, or array type).
1620 */
1721 json : null | boolean | number | string | object | any [ ]
1822 /**
19- * If this is supplied as false, one may call the evaluate method manually.
23+ * If this is supplied as false, one may call the evaluate method
24+ * manually.
2025 *
2126 * @default true
2227 */
2328 autostart ?: true | boolean
2429 /**
25- * Whether the returned array of results will be flattened to a single dimension array.
30+ * Whether the returned array of results will be flattened to a
31+ * single dimension array.
2632 *
2733 * @default false
2834 */
2935 flatten ?: false | boolean
3036 /**
31- * Can be case-insensitive form of "value", "path", "pointer", "parent", or "parentProperty" to determine respectively whether to return results as the values of the found items,
32- * as their absolute paths, as JSON Pointers to the absolute paths, as their parent objects, or as their parent's property name.
37+ * Can be case-insensitive form of "value", "path", "pointer", "parent",
38+ * or "parentProperty" to determine respectively whether to return
39+ * results as the values of the found items, as their absolute paths,
40+ * as JSON Pointers to the absolute paths, as their parent objects,
41+ * or as their parent's property name.
3342 *
34- * If set to "all", all of these types will be returned on an object with the type as key name.
43+ * If set to "all", all of these types will be returned on an object with
44+ * the type as key name.
3545 *
3646 * @default 'value'
3747 */
38- resultType ?: 'value' | 'path' | 'pointer' | 'parent' | 'parentProperty' | 'all'
48+ resultType ?:
49+ 'value' | 'path' | 'pointer' | 'parent' | 'parentProperty' | 'all'
3950
4051 /**
41- * Key-value map of variables to be available to code evaluations such as filtering expressions.
42- * (Note that the current path and value will also be available to those expressions; see the Syntax section for details.)
52+ * Key-value map of variables to be available to code evaluations such
53+ * as filtering expressions.
54+ * (Note that the current path and value will also be available to those
55+ * expressions; see the Syntax section for details.)
4356 */
4457 sandbox ?: Map < string , any >
4558 /**
4659 * Whether or not to wrap the results in an array.
4760 *
48- * If wrap is set to false, and no results are found, undefined will be returned (as opposed to an empty array when wrap is set to true).
61+ * If wrap is set to false, and no results are found, undefined will be
62+ * returned (as opposed to an empty array when wrap is set to true).
4963 *
50- * If wrap is set to false and a single non-array result is found, that result will be the only item returned (not within an array).
64+ * If wrap is set to false and a single non-array result is found, that
65+ * result will be the only item returned (not within an array).
5166 *
5267 * An array will still be returned if multiple results are found, however.
53- * To avoid ambiguities (in the case where it is necessary to distinguish between a result which is a failure and one which is an empty array),
68+ * To avoid ambiguities (in the case where it is necessary to distinguish
69+ * between a result which is a failure and one which is an empty array),
5470 * it is recommended to switch the default to false.
5571 *
5672 * @default true
5773 */
5874 wrap ?: true | boolean
5975 /**
6076 * Although JavaScript evaluation expressions are allowed by default,
61- * for security reasons (if one is operating on untrusted user input, for example),
62- * one may wish to set this option to true to throw exceptions when these expressions are attempted.
77+ * for security reasons (if one is operating on untrusted user input,
78+ * for example), one may wish to set this option to true to throw
79+ * exceptions when these expressions are attempted.
6380 *
6481 * @default false
6582 */
@@ -73,31 +90,37 @@ declare module 'jsonpath-plus' {
7390 parent ?: null | any
7491 /**
7592 * In the event that a query could be made to return the root node,
76- * this allows the parentProperty of that root node to be returned within results.
93+ * this allows the parentProperty of that root node to be returned within
94+ * results.
7795 *
7896 * @default null
7997 */
8098 parentProperty ?: null | any
8199 /**
82- * If supplied, a callback will be called immediately upon retrieval of an end point value.
100+ * If supplied, a callback will be called immediately upon retrieval of
101+ * an end point value.
83102 *
84- * The three arguments supplied will be the value of the payload (according to resultType),
85- * the type of the payload (whether it is a normal "value" or a "property" name),
86- * and a full payload object (with all resultTypes).
103+ * The three arguments supplied will be the value of the payload
104+ * (according to `resultType`), the type of the payload (whether it is
105+ * a normal "value" or a "property" name), and a full payload object
106+ * (with all `resultType`s).
87107 *
88108 * @default undefined
89109 */
90110 callback ?: undefined | JSONPathCallback
91111 /**
92112 * In the current absence of JSON Schema support,
93- * one can determine types beyond the built-in types by adding the operator @other() at the end of one's query.
113+ * one can determine types beyond the built-in types by adding the
114+ * perator `@other()` at the end of one's query.
94115 *
95- * If such a path is encountered, the otherTypeCallback will be invoked with the value of the item,
96- * its path, its parent, and its parent's property name, and
97- * it should return a boolean indicating whether the supplied value belongs to the "other" type or not
98- * (or it may handle transformations and return false).
116+ * If such a path is encountered, the `otherTypeCallback` will be invoked
117+ * with the value of the item, its path, its parent, and its parent's
118+ * property name, and it should return a boolean indicating whether the
119+ * supplied value belongs to the "other" type or not (or it may handle
120+ * transformations and return false).
99121 *
100- * @default undefined <A function that throws an error when @other() is encountered>
122+ * @default undefined
123+ * <A function that throws an error when `@other()` is encountered>
101124 */
102125 otherTypeCallback ?: undefined | JSONPathOtherTypeCallback
103126 }
@@ -110,40 +133,61 @@ declare module 'jsonpath-plus' {
110133 < T = any > ( options : JSONPathOptionsAutoStart ) : JSONPathClass
111134 < T = any > ( options : JSONPathOptions ) : T
112135
113- < T = any > ( path : JSONPathOptions [ 'path' ] , json : JSONPathOptions [ 'json' ] , callback : JSONPathOptions [ 'callback' ] , otherTypeCallback : JSONPathOptions [ 'otherTypeCallback' ] ) : T
136+ < T = any > (
137+ path : JSONPathOptions [ 'path' ] ,
138+ json : JSONPathOptions [ 'json' ] ,
139+ callback : JSONPathOptions [ 'callback' ] ,
140+ otherTypeCallback : JSONPathOptions [ 'otherTypeCallback' ]
141+ ) : T
114142 }
115143
116144 class JSONPathClass {
117145 /**
118- * Exposes the cache object for those who wish to preserve and reuse it for optimization purposes.
146+ * Exposes the cache object for those who wish to preserve and reuse
147+ * it for optimization purposes.
119148 */
120149 static cache : any
121150
122151 /**
123152 * Accepts a normalized or unnormalized path as string and
124- * converts to an array: for example, ['$', 'aProperty', 'anotherProperty'].
153+ * converts to an array: for example,
154+ * `['$', 'aProperty', 'anotherProperty']`.
125155 */
126156 static toPathArray ( path : string) : string[ ]
127157
128158 /**
129159 * Accepts a path array and converts to a normalized path string.
130- * The string will be in a form like: $['aProperty']['anotherProperty][0].
131- * The JSONPath terminal constructions ~ and ^ and type operators like @string() are silently stripped.
160+ * The string will be in a form like:
161+ * `$['aProperty']['anotherProperty][0]`.
162+ * The JSONPath terminal constructions `~` and `^` and type operators
163+ * like `@string()` are silently stripped.
132164 */
133165 static toPathString ( path : string[ ] ) : string
134166
135167 /**
136168 * Accepts a path array and converts to a JSON Pointer.
137169 *
138- * The string will be in a form like: '/aProperty/anotherProperty/0
139- * (with any ~ and / internal characters escaped as per the JSON Pointer spec).
170+ * The string will be in a form like: `/aProperty/anotherProperty/0`
171+ * (with any `~` and `/` internal characters escaped as per the JSON
172+ * Pointer spec).
140173 *
141- * The JSONPath terminal constructions ~ and ^ and type operators like @string() are silently stripped.
174+ * The JSONPath terminal constructions `~` and `^` and type operators
175+ * like `@string()` are silently stripped.
142176 */
143177 static toPointer ( path : string [ ] ) : any
144178
145- evaluate ( path : JSONPathOptions [ 'path' ] , json : JSONPathOptions [ 'json' ] , callback : JSONPathOptions [ 'callback' ] , otherTypeCallback : JSONPathOptions [ 'otherTypeCallback' ] )
146- evaluate ( options : { path : JSONPathOptions [ 'path' ] , json : JSONPathOptions [ 'json' ] , callback : JSONPathOptions [ 'callback' ] , otherTypeCallback : JSONPathOptions [ 'otherTypeCallback' ] } )
179+ evaluate (
180+ path : JSONPathOptions [ 'path' ] ,
181+ json : JSONPathOptions [ 'json' ] ,
182+ callback : JSONPathOptions [ 'callback' ] ,
183+ otherTypeCallback : JSONPathOptions [ 'otherTypeCallback' ]
184+ )
185+ evaluate ( options : {
186+ path : JSONPathOptions [ 'path' ] ,
187+ json : JSONPathOptions [ 'json' ] ,
188+ callback : JSONPathOptions [ 'callback' ] ,
189+ otherTypeCallback : JSONPathOptions [ 'otherTypeCallback' ]
190+ } )
147191 }
148192
149193 type JSONPathType = JSONPathCallable & JSONPathClass
0 commit comments