mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-19 13:32:17 +08:00
Merge pull request #1 from chrootsu/lodash-partition
lodash: changed _.partition() method
This commit is contained in:
@@ -626,6 +626,34 @@ result = <number>_(stoogesAgesDict).sum('age');
|
||||
result = <string[]>_.pluck(stoogesAges, 'name');
|
||||
result = <string[]>_(stoogesAges).pluck('name').value();
|
||||
|
||||
// _.partition
|
||||
result = <string[][]>_.partition<string>('abcd', (n) => n < 'c');
|
||||
result = <string[][]>_.partition<string>(['a', 'b', 'c', 'd'], (n) => n < 'c');
|
||||
result = <number[][]>_.partition<number>([1, 2, 3, 4], (n) => n < 3);
|
||||
result = <number[][]>_.partition<number>({0: 1, 1: 2, 2: 3, 3: 4, length: 4}, (n) => n < 3);
|
||||
result = <number[][]>_.partition<number>({a: 1, b: 2, c: 3, d: 4}, (n) => n < 3);
|
||||
result = <{a: number}[][]>_.partition<{a: number}, {a: number}>([{a: 1}, {a: 2}], {a: 2});
|
||||
result = <{a: number}[][]>_.partition<{a: number}, {a: number}>({0: {a: 1}, 1: {a: 2}, length: 2}, {a: 2});
|
||||
result = <{a: number}[][]>_.partition<{a: number}, {a: number}>({0: {a: 1}, 1: {a: 2}}, {a: 2});
|
||||
result = <{a: number}[][]>_.partition<{a: number}>([{a: 1}, {a: 2}], 'a');
|
||||
result = <{a: number}[][]>_.partition<{a: number}>([{a: 1}, {a: 2}], 'a', 2);
|
||||
result = <{a: number}[][]>_.partition<{a: number}>({0: {a: 1}, 1: {a: 2}, length: 2}, 'a');
|
||||
result = <{a: number}[][]>_.partition<{a: number}>({0: {a: 1}, 1: {a: 2}, length: 2}, 'a', 2);
|
||||
result = <{a: number}[][]>_.partition<{a: number}>({0: {a: 1}, 1: {a: 2}}, 'a');
|
||||
result = <{a: number}[][]>_.partition<{a: number}>({0: {a: 1}, 1: {a: 2}}, 'a', 2);
|
||||
result = <string[][]>_('abcd').partition((n) => n < 'c').value();
|
||||
result = <string[][]>_(['a', 'b', 'c', 'd']).partition((n) => n < 'c').value();
|
||||
result = <number[][]>_([1, 2, 3, 4]).partition((n) => n < 3).value();
|
||||
result = <number[][]>_({0: 1, 1: 2, 2: 3, 3: 4, length: 4}).partition<number>((n) => n < 3).value();
|
||||
result = <number[][]>_({a: 1, b: 2, c: 3, d: 4}).partition<number>((n) => n < 3).value();
|
||||
result = <{a: number}[][]>_([{a: 1}, {a: 2}]).partition<{a: number}>({a: 2}).value();
|
||||
result = <{a: number}[][]>_({0: {a: 1}, 1: {a: 2}, length: 2}).partition<{a: number}, {a: number}>({a: 2}).value();
|
||||
result = <{a: number}[][]>_({0: {a: 1}, 1: {a: 2}}).partition<{a: number}, {a: number}>({a: 2}).value();
|
||||
result = <{a: number}[][]>_([{a: 1}, {a: 2}]).partition('a').value();
|
||||
result = <{a: number}[][]>_([{a: 1}, {a: 2}]).partition('a', 2).value();
|
||||
result = <{a: number}[][]>_({0: {a: 1}, 1: {a: 2}}).partition<{a: number}>('a').value();
|
||||
result = <{a: number}[][]>_({0: {a: 1}, 1: {a: 2}}).partition<{a: number}>('a', 2).value();
|
||||
|
||||
interface ABC {
|
||||
[index: string]: number;
|
||||
a: number;
|
||||
|
||||
112
lodash/lodash.d.ts
vendored
112
lodash/lodash.d.ts
vendored
@@ -4115,72 +4115,70 @@ declare module _ {
|
||||
* @return Returns the array of grouped elements.
|
||||
**/
|
||||
partition<T>(
|
||||
collection: Array<T>,
|
||||
collection: List<T>,
|
||||
callback: ListIterator<T, boolean>,
|
||||
thisArg?: any): T[][];
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
**/
|
||||
partition<T>(
|
||||
collection: List<T>,
|
||||
callback: ListIterator<T, boolean>,
|
||||
thisArg?: any): T;
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
**/
|
||||
partition<T>(
|
||||
collection: Dictionary<T>,
|
||||
callback: DictionaryIterator<T, boolean>,
|
||||
thisArg?: any): T;
|
||||
thisArg?: any): T[][];
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
* @param _.matches style callback
|
||||
**/
|
||||
partition<W, T>(
|
||||
collection: Array<T>,
|
||||
whereValue: W): T;
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
* @param _.matches style callback
|
||||
**/
|
||||
partition<W, T>(
|
||||
collection: List<T>,
|
||||
whereValue: W): T;
|
||||
whereValue: W): T[][];
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
* @param _.matches style callback
|
||||
**/
|
||||
partition<W, T>(
|
||||
collection: Dictionary<T>,
|
||||
whereValue: W): T;
|
||||
whereValue: W): T[][];
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
* @param _.property style callback
|
||||
**/
|
||||
partition<T>(
|
||||
collection: Array<T>,
|
||||
pluckValue: string): T;
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
* @param _.property style callback
|
||||
**/
|
||||
partition<T>(
|
||||
collection: List<T>,
|
||||
pluckValue: string): T;
|
||||
path: string,
|
||||
srcValue: any): T[][];
|
||||
|
||||
/**
|
||||
* @param _.property style callback
|
||||
* @see _.partition
|
||||
**/
|
||||
partition<T>(
|
||||
collection: Dictionary<T>,
|
||||
pluckValue: string): T;
|
||||
path: string,
|
||||
srcValue: any): T[][];
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
**/
|
||||
partition<T>(
|
||||
collection: List<T>,
|
||||
pluckValue: string): T[][];
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
**/
|
||||
partition<T>(
|
||||
collection: Dictionary<T>,
|
||||
pluckValue: string): T[][];
|
||||
}
|
||||
|
||||
interface LoDashStringWrapper {
|
||||
/**
|
||||
* @see _.partition
|
||||
*/
|
||||
partition(
|
||||
callback: ListIterator<string, boolean>,
|
||||
thisArg?: any): LoDashArrayWrapper<string[]>;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
@@ -4189,26 +4187,58 @@ declare module _ {
|
||||
*/
|
||||
partition(
|
||||
callback: ListIterator<T, boolean>,
|
||||
thisArg?: any): LoDashArrayWrapper<T[][]>;
|
||||
thisArg?: any): LoDashArrayWrapper<T[]>;
|
||||
/**
|
||||
* @see _.partition
|
||||
* @param _.matches style callback
|
||||
*/
|
||||
partition<W>(
|
||||
whereValue: W): LoDashArrayWrapper<T[][]>;
|
||||
whereValue: W): LoDashArrayWrapper<T[]>;
|
||||
/**
|
||||
* @see _.partition
|
||||
* @param _.matchesProperty style callback
|
||||
*/
|
||||
partition(
|
||||
path: string,
|
||||
srcValue: any): LoDashArrayWrapper<T[][]>;
|
||||
srcValue: any): LoDashArrayWrapper<T[]>;
|
||||
/**
|
||||
* @see _.partition
|
||||
* @param _.property style callback
|
||||
*/
|
||||
partition(
|
||||
pluckValue: string): LoDashArrayWrapper<T[][]>;
|
||||
pluckValue: string): LoDashArrayWrapper<T[]>;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.partition
|
||||
*/
|
||||
partition<TResult>(
|
||||
callback: ListIterator<TResult, boolean>,
|
||||
thisArg?: any): LoDashArrayWrapper<TResult[]>;
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
*/
|
||||
partition<TResult>(
|
||||
callback: DictionaryIterator<TResult, boolean>,
|
||||
thisArg?: any): LoDashArrayWrapper<TResult[]>;
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
*/
|
||||
partition<W, TResult>(
|
||||
whereValue: W): LoDashArrayWrapper<TResult[]>;
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
*/
|
||||
partition<TResult>(
|
||||
path: string,
|
||||
srcValue: any): LoDashArrayWrapper<TResult[]>;
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
*/
|
||||
partition<TResult>(
|
||||
pluckValue: string): LoDashArrayWrapper<TResult[]>;
|
||||
}
|
||||
|
||||
//_.reduce
|
||||
|
||||
Reference in New Issue
Block a user