lodash: added _.negate() method

This commit is contained in:
Ilya Mochalov
2015-08-02 00:34:19 +05:00
parent 4df20c9706
commit 4188f4d9ad
2 changed files with 42 additions and 1 deletions
+14 -1
View File
@@ -893,9 +893,22 @@ result = <string[]>result(1, true);
result = <ModArgsResult>_<ModArgsFunc>((x: string, y: string) => [x, y]).modArgs<ModArgsResult>([modArgsFn1, modArgsFn2]).value();
result = <string[]>result(1, true);
// _.negate
interface TestNegatePredicate {
(a1: number, a2: number): boolean;
}
interface TestNegateResult {
(a1: number, a2: number): boolean;
}
var testNegatePredicate = (a1: number, a2: number) => a1 > a2;
result = <TestNegateResult>_.negate<TestNegatePredicate>(testNegatePredicate);
result = <TestNegateResult>_.negate<TestNegatePredicate, TestNegateResult>(testNegatePredicate);
result = <TestNegateResult>_(testNegatePredicate).negate().value();
result = <TestNegateResult>_(testNegatePredicate).negate<TestNegateResult>().value();
var initialize = _.once(function () { });
initialize();
initialize();''
initialize();
var returnedOnce = _.throttle(function (a: any) { return a * 5; }, 5);
returnedOnce(4);
+28
View File
@@ -5474,6 +5474,34 @@ declare module _ {
modArgs<TResult>(transforms: Function[]): LoDashObjectWrapper<TResult>;
}
//_.negate
interface LoDashStatic {
/**
* Creates a function that negates the result of the predicate func. The func predicate is invoked with
* the this binding and arguments of the created function.
* @param predicate The predicate to negate.
* @return Returns the new function.
*/
negate<T extends Function>(predicate: T): (...args: any[]) => boolean;
/**
* @see _.negate
*/
negate<T extends Function, TResult extends Function>(predicate: T): TResult;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.negate
*/
negate(): LoDashObjectWrapper<(...args: any[]) => boolean>;
/**
* @see _.negate
*/
negate<TResult extends Function>(): LoDashObjectWrapper<TResult>;
}
//_.once
interface LoDashStatic {
/**