Added a missing use case for flatMap

This commit is contained in:
AJ Richardson
2017-10-21 10:14:28 -04:00
parent af5a9ebed4
commit 04246ca369
2 changed files with 33 additions and 0 deletions
+18
View File
@@ -4780,6 +4780,13 @@ declare namespace _ {
collection: List<Many<T>> | Dictionary<Many<T>> | NumericDictionary<Many<T>> | null | undefined
): T[];
/**
* @see _.flatMap
*/
flatMap(
collection: object | null | undefined
): any[];
/**
* @see _.flatMap
*/
@@ -4820,6 +4827,7 @@ declare namespace _ {
iteratee: object
): boolean[];
}
type T234 = number[][0];
interface LoDashImplicitWrapper<TValue> {
/**
@@ -4827,6 +4835,11 @@ declare namespace _ {
*/
flatMap<T>(this: LoDashImplicitWrapper<List<Many<T>> | Dictionary<Many<T>> | NumericDictionary<Many<T>> | null | undefined>): LoDashImplicitWrapper<T[]>;
/**
* @see _.flatMap
*/
flatMap(): LoDashImplicitWrapper<any[]>;
/**
* @see _.flatMap
*/
@@ -4872,6 +4885,11 @@ declare namespace _ {
*/
flatMap<T>(this: LoDashExplicitWrapper<List<Many<T>> | Dictionary<Many<T>> | NumericDictionary<Many<T>> | null | undefined>): LoDashExplicitWrapper<T[]>;
/**
* @see _.flatMap
*/
flatMap(): LoDashExplicitWrapper<any[]>;
/**
* @see _.flatMap
*/
+15
View File
@@ -4462,6 +4462,21 @@ namespace TestFlatMap {
result = _(objNumericDictionary).chain().flatMap(['a', 42]);
result = _(objNumericDictionary).chain().flatMap({a: 42});
}
{
interface SampleObject {
bar: number;
foo: string[];
}
const obj: SampleObject = {
bar: 1,
foo: [''],
};
const result1: Array<string | number> = _.flatMap(obj);
const result2: _.LoDashImplicitWrapper<Array<string | number>> = _(obj).flatMap();
const result3: _.LoDashExplicitWrapper<Array<string | number>> = _.chain(obj).flatMap();
}
}
// _.flatMapDeep