UNPKG

underscore-es

Version:

javaScript's functional programming helper library for ES6 and beyond.

14 lines (12 loc) 451 B
// `_result` : an utility's function // ---------------------------------- import _isFunction from './isFunction'; // If the value of the named `property` is a function then invoke it with the // `object` as context; otherwise, return it. export default function (object, prop, fallback) { let value = object == null ? void 0 : object[prop]; if (value === void 0) { value = fallback; } return _isFunction(value) ? value.call(object) : value; }