Improve jsdoc of util.getObjectProperty to clarify thrown error

See #2703
This commit is contained in:
Nick O'Leary 2020-09-28 14:23:23 +01:00
parent a1ab00c93e
commit 6e5f115bd5
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 14 additions and 0 deletions

View File

@ -318,9 +318,23 @@ function getMessageProperty(msg,expr) {
/**
* Gets a property of an object.
*
* Given the object:
*
* {
* "pet": {
* "type": "cat"
* }
* }
*
* - `pet.type` will return `"cat"`.
* - `pet.name` will return `undefined`
* - `car` will return `undefined`
* - `car.type` will throw an Error (as `car` does not exist)
*
* @param {Object} msg - the object
* @param {String} expr - the property expression
* @return {any} the object property, or undefined if it does not exist
* @throws Will throw an error if the *parent* of the property does not exist
* @memberof @node-red/util_util
*/
function getObjectProperty(msg,expr) {