mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-26 11:12:19 +08:00
Merge pull request #5382 from chrootsu/lodash-attempt
lodash: added _.attempt() method
This commit is contained in:
+15
-1
@@ -91,6 +91,12 @@ var result: any;
|
||||
|
||||
var any: any;
|
||||
|
||||
interface TResult {
|
||||
a: number;
|
||||
b: string;
|
||||
c: boolean;
|
||||
}
|
||||
|
||||
// _.MapCache
|
||||
var testMapCache: _.MapCache;
|
||||
result = <(key: string) => boolean>testMapCache.delete;
|
||||
@@ -1539,9 +1545,17 @@ result = <number[]>_(new TestValueIn()).valuesIn<number>().value();
|
||||
// → [1, 2, 3]
|
||||
|
||||
/**********
|
||||
* Utilities *
|
||||
* Utility *
|
||||
***********/
|
||||
|
||||
// _.attempt
|
||||
interface TestAttemptFn {
|
||||
(): TResult;
|
||||
}
|
||||
var testAttempFn: TestAttemptFn;
|
||||
result = <TResult|Error>_.attempt<TResult>(testAttempFn);
|
||||
result = <TResult|Error>_(testAttempFn).attempt<TResult>();
|
||||
|
||||
result = <{ name: string }>_.identity({ 'name': 'moe' });
|
||||
|
||||
_.mixin({
|
||||
|
||||
Vendored
+21
-3
@@ -7614,9 +7614,27 @@ declare module _ {
|
||||
words(str?: string, pattern?: string|RegExp): string[];
|
||||
}
|
||||
|
||||
/*************
|
||||
* Utilities *
|
||||
*************/
|
||||
/***********
|
||||
* Utility *
|
||||
***********/
|
||||
|
||||
//_.attempt
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Attempts to invoke func, returning either the result or the caught error object. Any additional arguments
|
||||
* are provided to func when it’s invoked.
|
||||
* @param func The function to attempt.
|
||||
* @return Returns the func result or error object.
|
||||
*/
|
||||
attempt<TResult>(func: (...args: any[]) => TResult): TResult|Error;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.attempt
|
||||
*/
|
||||
attempt<TResult>(): TResult|Error;
|
||||
}
|
||||
|
||||
//_.identity
|
||||
interface LoDashStatic {
|
||||
|
||||
Reference in New Issue
Block a user