Skip to content

Commit e35e178

Browse files
committed
- Docs: Document options in jsdoc; add return values to callbacks; fix constructor doc sig.
1 parent 66c961c commit e35e178

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

src/jsonpath.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class NewError extends Error {
132132
* @param {string|PlainObject} preferredOutput
133133
* @param {"value"|"property"} type
134134
* @param {ReturnObject} fullRetObj
135+
* @returns {void}
135136
*/
136137

137138
/**
@@ -140,16 +141,35 @@ class NewError extends Error {
140141
* @param {string} path
141142
* @param {PlainObject|GenericArray} parent
142143
* @param {string} parentPropName
144+
* @returns {boolean}
143145
*/
144146

145147
/**
146-
* @param {PlainObject} [opts] If present, must be an object
147-
* @param {string} expr JSON path to evaluate
148-
* @param {JSON} obj JSON object to evaluate against
149-
* @param {JSONPathCallback} callback Passed 3 arguments: 1) desired payload
148+
* @typedef {PlainObject} JSONPathOptions
149+
* @property {JSON} json
150+
* @property {string|string[]} path
151+
* @property {"value"|"path"|"pointer"|"parent"|"parentProperty"|"all"}
152+
* [resultType="value"]
153+
* @property {boolean} [flatten=false]
154+
* @property {boolean} [wrap=true]
155+
* @property {PlainObject} [sandbox={}]
156+
* @property {boolean} [preventEval=false]
157+
* @property {PlainObject|GenericArray|null} [parent=null]
158+
* @property {string|null} [parentProperty=null]
159+
* @property {JSONPathCallback} [callback]
160+
* @property {OtherTypeCallback} [otherTypeCallback] Defaults to
161+
* function which throws on encountering `@other`
162+
* @property {boolean} [autostart=true]
163+
*/
164+
165+
/**
166+
* @param {string|JSONPathOptions} opts If a string, will be treated as `expr`
167+
* @param {string} [expr] JSON path to evaluate
168+
* @param {JSON} [obj] JSON object to evaluate against
169+
* @param {JSONPathCallback} [callback] Passed 3 arguments: 1) desired payload
150170
* per `resultType`, 2) `"value"|"property"`, 3) Full returned object with
151171
* all payloads
152-
* @param {OtherTypeCallback} otherTypeCallback If `@other()` is at the end
172+
* @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the end
153173
* of one's query, this will be invoked with the value of the item, its
154174
* path, its parent, and its parent's property name, and it should return
155175
* a boolean indicating whether the supplied value belongs to the "other"

0 commit comments

Comments
 (0)