Merge pull request #7112 from chrootsu/lodash-before

lodash: signatures of _.before have been changed
This commit is contained in:
Masahiro Wakame
2015-12-10 23:23:33 +09:00
2 changed files with 41 additions and 21 deletions
+25 -16
View File
@@ -4658,22 +4658,31 @@ module TestBackflow {
}
// _.before
var testBeforeFn = ((n: number) => () => ++n)(0);
var testBeforeResultFn = <() => number>_.before<() => number>(3, testBeforeFn);
result = <number>testBeforeResultFn();
// → 1
result = <number>testBeforeResultFn();
// → 2
result = <number>testBeforeResultFn();
// → 2
var testBeforeFn = ((n: number) => () => ++n)(0);
var testBeforeResultFn = <() => number>_(3).before<() => number>(testBeforeFn);
result = <number>testBeforeResultFn();
// → 1
result = <number>testBeforeResultFn();
// → 2
result = <number>testBeforeResultFn();
// → 2
module TestBefore {
interface Func {
(a: string, b: number): boolean;
}
let func: Func;
{
let result: Func;
_.before(42, func);
}
{
let result: _.LoDashImplicitObjectWrapper<Func>;
_(42).before(func);
}
{
let result: _.LoDashExplicitObjectWrapper<Func>;
_(42).chain().before(func);
}
}
var funcBind = function(greeting: string, punctuation: string) { return greeting + ' ' + this.user + punctuation; };
var funcBound1: (punctuation: string) => any = _.bind(funcBind, { 'name': 'moe' }, 'hi');
+16 -5
View File
@@ -8048,20 +8048,31 @@ declare module _ {
interface LoDashStatic {
/**
* Creates a function that invokes func, with the this binding and arguments of the created function, while
* it is called less than n times. Subsequent calls to the created function return the result of the last func
* its called less than n times. Subsequent calls to the created function return the result of the last func
* invocation.
*
* @param n The number of calls at which func is no longer invoked.
* @param func The function to restrict.
* @return Returns the new restricted function.
*/
before<TFunc extends Function>(n: number, func: TFunc): TFunc;
before<TFunc extends Function>(
n: number,
func: TFunc
): TFunc;
}
interface LoDashImplicitWrapper<T> {
/**
* @sed _.before
*/
before<TFunc extends Function>(func: TFunc): TFunc;
* @see _.before
**/
before<TFunc extends Function>(func: TFunc): LoDashImplicitObjectWrapper<TFunc>;
}
interface LoDashExplicitWrapper<T> {
/**
* @see _.before
**/
before<TFunc extends Function>(func: TFunc): LoDashExplicitObjectWrapper<TFunc>;
}
//_.bind