Skip to content

Commit

Permalink
Merge pull request #5117 from chrootsu/lodash-negate
Browse files Browse the repository at this point in the history
lodash: added _.negate() method
  • Loading branch information
vvakame committed Aug 2, 2015
2 parents 2a2b02f + 4188f4d commit b6c1563
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lodash/lodash-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
28 changes: 28 additions & 0 deletions lodash/lodash.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down

0 comments on commit b6c1563

Please sign in to comment.