MCPcopy
hub / github.com/Kong/insomnia / result

Function result

packages/insomnia/bin/yarn-standalone.js:21255–21275  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

21253 * // => 'default'
21254 */
21255 function result(object, path, defaultValue) {
21256 path = castPath(path, object);
21257
21258 var index = -1,
21259 length = path.length;
21260
21261 // Ensure the loop is entered when path is empty.
21262 if (!length) {
21263 length = 1;
21264 object = undefined;
21265 }
21266 while (++index < length) {
21267 var value = object == null ? undefined : object[toKey(path[index])];
21268 if (value === undefined) {
21269 index = length;
21270 value = defaultValue;
21271 }
21272 object = isFunction(value) ? value.call(object) : value;
21273 }
21274 return object;
21275 }
21276
21277 /**
21278 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,

Callers 1

getIterateeFunction · 0.85

Calls 3

castPathFunction · 0.85
toKeyFunction · 0.85
isFunctionFunction · 0.70

Tested by

no test coverage detected