lodash: signatures of _.fill have been changed

This commit is contained in:
Ilya Mochalov
2015-11-26 06:30:50 +05:00
parent 36c6ce86fb
commit 99167e2477
2 changed files with 126 additions and 55 deletions
+51 -6
View File
@@ -453,13 +453,58 @@ module TestDropWhile {
}
// _.fill
var testFillArray = [1, 2, 3];
var testFillList: _.List<number> = {0: 1, 1: 2, 2: 3, length: 3};
module TestFill {
let array: number[];
let list: _.List<number>;
result = <string[]>_.fill<string>(testFillArray, 'a', 0, 3);
result = <_.List<string>>_.fill<string>(testFillList, 'a', 0, 3);
result = <number[]>_(testFillArray).fill<number>(0, 0, 3).value();
result = <_.List<number>>_(testFillList).fill<number>(0, 0, 3).value();
{
let result: number[];
result = _.fill<number>(array, 42);
result = _.fill<number>(array, 42, 0);
result = _.fill<number>(array, 42, 0, 10);
}
{
let result: _.List<number>;
result = _.fill<number>(list, 42);
result = _.fill<number>(list, 42, 0);
result = _.fill<number>(list, 42, 0, 10);
}
{
let result: _.LoDashImplicitArrayWrapper<number>;
result = _(array).fill<number>(42);
result = _(array).fill<number>(42, 0);
result = _(array).fill<number>(42, 0, 10);
}
{
let result: _.LoDashImplicitObjectWrapper<_.List<number>>;
result = _(list).fill<number>(42);
result = _(list).fill<number>(42, 0);
result = _(list).fill<number>(42, 0, 10);
}
{
let result: _.LoDashExplicitArrayWrapper<number>;
result = _(array).chain().fill<number>(42);
result = _(array).chain().fill<number>(42, 0);
result = _(array).chain().fill<number>(42, 0, 10);
}
{
let result: _.LoDashExplicitObjectWrapper<_.List<number>>;
result = _(list).chain().fill<number>(42);
result = _(list).chain().fill<number>(42, 0);
result = _(list).chain().fill<number>(42, 0, 10);
}
}
// _.findIndex
module TestFindIndex {
+75 -49
View File
@@ -749,6 +749,81 @@ declare module _ {
): LoDashExplicitArrayWrapper<TValue>;
}
//_.fill
interface LoDashStatic {
/**
* Fills elements of array with value from start up to, but not including, end.
*
* Note: This method mutates array.
*
* @param array The array to fill.
* @param value The value to fill array with.
* @param start The start position.
* @param end The end position.
* @return Returns array.
*/
fill<T>(
array: any[],
value: T,
start?: number,
end?: number
): T[];
/**
* @see _.fill
*/
fill<T>(
array: List<any>,
value: T,
start?: number,
end?: number
): List<T>;
}
interface LoDashImplicitArrayWrapper<T> {
/**
* @see _.fill
*/
fill<T>(
value: T,
start?: number,
end?: number
): LoDashImplicitArrayWrapper<T>;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.fill
*/
fill<T>(
value: T,
start?: number,
end?: number
): LoDashImplicitObjectWrapper<List<T>>;
}
interface LoDashExplicitArrayWrapper<T> {
/**
* @see _.fill
*/
fill<T>(
value: T,
start?: number,
end?: number
): LoDashExplicitArrayWrapper<T>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.fill
*/
fill<T>(
value: T,
start?: number,
end?: number
): LoDashExplicitObjectWrapper<List<T>>;
}
//_.findIndex
interface LoDashStatic {
/**
@@ -4552,55 +4627,6 @@ declare module _ {
): LoDashExplicitWrapper<boolean>;
}
//_.fill
interface LoDashStatic {
/**
* Fills elements of array with value from start up to, but not including, end.
*
* Note: This method mutates array.
*
* @param array (Array): The array to fill.
* @param value (*): The value to fill array with.
* @param [start=0] (number): The start position.
* @param [end=array.length] (number): The end position.
* @return (Array): Returns array.
*/
fill<TResult>(
array: any[],
value: any,
start?: number,
end?: number): TResult[];
/**
* @see _.fill
*/
fill<TResult>(
array: List<any>,
value: any,
start?: number,
end?: number): List<TResult>;
}
interface LoDashImplicitArrayWrapper<T> {
/**
* @see _.fill
*/
fill<TResult>(
value: TResult,
start?: number,
end?: number): LoDashImplicitArrayWrapper<TResult>;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.fill
*/
fill<TResult>(
value: TResult,
start?: number,
end?: number): LoDashImplicitObjectWrapper<List<TResult>>;
}
//_.filter
interface LoDashStatic {
/**