* This method is like `_.get` except that if the resolved value is a * function it's invoked with the `this` binding of its parent object and * its result is returned. * * @static * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The obj
(object, path, defaultValue)
| 21342 | * // => 'default' |
| 21343 | */ |
| 21344 | function result(object, path, defaultValue) { |
| 21345 | path = castPath(path, object); |
| 21346 | |
| 21347 | var index = -1, |
| 21348 | length = path.length; |
| 21349 | |
| 21350 | // Ensure the loop is entered when path is empty. |
| 21351 | if (!length) { |
| 21352 | length = 1; |
| 21353 | object = undefined; |
| 21354 | } |
| 21355 | while (++index < length) { |
| 21356 | var value = object == null ? undefined : object[toKey(path[index])]; |
| 21357 | if (value === undefined) { |
| 21358 | index = length; |
| 21359 | value = defaultValue; |
| 21360 | } |
| 21361 | object = isFunction(value) ? value.call(object) : value; |
| 21362 | } |
| 21363 | return object; |
| 21364 | } |
| 21365 | |
| 21366 | /** |
| 21367 | * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, |
no test coverage detected