diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 4f5aa03e9..89be7405b 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -732,6 +732,16 @@ result = _.random(5, true); result = _.random(1.2, 5.2); result = _.random(0, 5, true); +var object = { + 'cheese': 'crumpets', + 'stuff': function() { + return 'nonsense'; + } +}; + +result = _.result(object, 'cheese'); +result = _.result(object, 'stuff'); + ////////////////////////////////////////////////////////////////////////////////////////////////// var iceCream = { flavor: "chocolate" }; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 0739e996b..4be1561a4 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2762,7 +2762,15 @@ declare module _ { **/ export function random(min: number, max: number, floating?: boolean): number; - + /** + * Resolves the value of property on object. If property is a function it will be invoked with + * the this binding of object and its result returned, else the property value is returned. If + * object is falsey then undefined is returned. + * @param object The object to inspect. + * @param property The property to get the value of. + * @return The resolved value. + **/ + export function result(object: any, property: string): any; @@ -2795,14 +2803,6 @@ declare module _ { - /** - * If the value of the named property is a function then invoke it; otherwise, return it. - * @param object Object to maybe invoke function `property` on. - * @param property The function by name to invoke on `object`. - * @return The result of invoking the function `property` on `object. - **/ - export function result(object: any, property: string): any; - /** * Compiles JavaScript templates into functions that can be evaluated for rendering. Useful * for rendering complicated bits of HTML from JSON data sources. Template functions can both