mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-10 11:40:16 +08:00
added _.result definition
This commit is contained in:
@@ -732,6 +732,16 @@ result = <number>_.random(5, true);
|
||||
result = <number>_.random(1.2, 5.2);
|
||||
result = <number>_.random(0, 5, true);
|
||||
|
||||
var object = {
|
||||
'cheese': 'crumpets',
|
||||
'stuff': function() {
|
||||
return 'nonsense';
|
||||
}
|
||||
};
|
||||
|
||||
result = <any>_.result(object, 'cheese');
|
||||
result = <any>_.result(object, 'stuff');
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var iceCream = { flavor: "chocolate" };
|
||||
|
||||
Vendored
+9
-9
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user