mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 21:10:23 +00:00
Merge pull request #5986 from chrootsu/lodash-chunk
lodash: changed _.chunk() method
This commit is contained in:
+18
-11
@@ -155,17 +155,24 @@ result = <number[]>_([1, 2, 3]).run();
|
||||
result = <_.Dictionary<string>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).toJSON();
|
||||
result = <_.Dictionary<number>>_({ a: 1, b: 2}).mapValues(function(num: number) { return num * 2; }).valueOf();
|
||||
|
||||
// /*************
|
||||
// * Arrays *
|
||||
// *************/
|
||||
result = <any[][]>_.chunk([1, '2', '3', false]);
|
||||
result = <_.LoDashArrayWrapper<any[]>>_([1, '2', '3', false]).chunk();
|
||||
result = <any[][]>_.chunk([1, '2', '3', false], 2);
|
||||
result = <_.LoDashArrayWrapper<any[]>>_([1, '2', '3', false]).chunk(2);
|
||||
result = <number[][]>_.chunk([1, 2, 3, 4]);
|
||||
result = <_.LoDashArrayWrapper<number[]>>_([1, 2, 3, 4]).chunk();
|
||||
result = <number[][]>_.chunk([1, 2, 3, 4], 2);
|
||||
result = <_.LoDashArrayWrapper<number[]>>_([1, 2, 3, 4]).chunk(2);
|
||||
/*********
|
||||
* Array *
|
||||
*********/
|
||||
|
||||
// _.chunk
|
||||
module TestChunk {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let result: TResult[][];
|
||||
result = _.chunk<TResult>(array);
|
||||
result = _.chunk<TResult>(array, 42);
|
||||
result = _.chunk<TResult>(list);
|
||||
result = _.chunk<TResult>(list, 42);
|
||||
result = _(array).chunk().value();
|
||||
result = _(array).chunk(42).value();
|
||||
result = _(list).chunk<TResult>().value();
|
||||
result = _(list).chunk<TResult>(42).value();
|
||||
}
|
||||
|
||||
result = <any[]>_.compact([0, 1, false, 2, '', 3]);
|
||||
result = <_.LoDashArrayWrapper<any>>_([0, 1, false, 2, '', 3]).compact();
|
||||
|
||||
Vendored
+22
-16
@@ -313,33 +313,39 @@ declare module _ {
|
||||
}
|
||||
|
||||
/*********
|
||||
* Arrays *
|
||||
**********/
|
||||
* Array *
|
||||
*********/
|
||||
|
||||
//_.chunk
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Creates an array of elements split into groups the length of size. If collection can't be
|
||||
* split evenly, the final chunk will be the remaining elements.
|
||||
* @param array The array to process.
|
||||
* @param size The length of each chunk.
|
||||
* @return Returns the new array containing chunks.
|
||||
**/
|
||||
chunk<T>(array: Array<T>, size?: number): T[][];
|
||||
|
||||
/**
|
||||
* @see _.chunk
|
||||
**/
|
||||
chunk<T>(array: List<T>, size?: number): T[][];
|
||||
* Creates an array of elements split into groups the length of size. If collection can’t be split evenly, the
|
||||
* final chunk will be the remaining elements.
|
||||
*
|
||||
* @param array The array to process.
|
||||
* @param size The length of each chunk.
|
||||
* @return Returns the new array containing chunks.
|
||||
*/
|
||||
chunk<T>(
|
||||
array: List<T>,
|
||||
size?: number
|
||||
): T[][];
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.chunk
|
||||
**/
|
||||
* @see _.chunk
|
||||
*/
|
||||
chunk(size?: number): LoDashArrayWrapper<T[]>;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.chunk
|
||||
*/
|
||||
chunk<TResult>(size?: number): LoDashArrayWrapper<TResult[]>;
|
||||
}
|
||||
|
||||
//_.compact
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user