diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 63f36e263..3551515fc 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2777,10 +2777,6 @@ module TestMap { } } -result = _.pluck(stoogesAges, 'name'); -result = _(stoogesAges).pluck('name').value(); -result = _.pluck(stoogesAges, ['name']); - // _.partition result = _.partition('abcd', (n) => n < 'c'); result = _.partition(['a', 'b', 'c', 'd'], (n) => n < 'c'); @@ -2809,6 +2805,69 @@ 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(); +// _.pluck +module TestPluck { + interface SampleObject { + d: {b: TResult}[]; + } + + let array: SampleObject[]; + let list: _.List; + let dictionary: _.Dictionary; + + { + let result: any[]; + + result = _.pluck(array, 'd.0.b'); + result = _.pluck(array, ['d', 0, 'b']); + + result = _.pluck(list, 'd.0.b'); + result = _.pluck(list, ['d', 0, 'b']); + + result = _.pluck(dictionary, 'd.0.b'); + result = _.pluck(dictionary, ['d', 0, 'b']); + } + + { + let result: TResult[]; + + result = _.pluck(array, 'd.0.b'); + result = _.pluck(array, ['d', 0, 'b']); + + result = _.pluck(list, 'd.0.b'); + result = _.pluck(list, ['d', 0, 'b']); + + result = _.pluck(dictionary, 'd.0.b'); + result = _.pluck(dictionary, ['d', 0, 'b']); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).pluck('d.0.b'); + result = _(array).pluck(['d', 0, 'b']); + + result = _(list).pluck('d.0.b'); + result = _(list).pluck(['d', 0, 'b']); + + result = _(dictionary).pluck('d.0.b'); + result = _(dictionary).pluck(['d', 0, 'b']); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().pluck('d.0.b'); + result = _(array).chain().pluck(['d', 0, 'b']); + + result = _(list).chain().pluck('d.0.b'); + result = _(list).chain().pluck(['d', 0, 'b']); + + result = _(dictionary).chain().pluck('d.0.b'); + result = _(dictionary).chain().pluck(['d', 0, 'b']); + } +} + interface ABC { [index: string]: number; a: number; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 6fe30eb1f..b3edd5215 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -5291,49 +5291,6 @@ declare module _ { ): LoDashExplicitArrayWrapper; } - //_.pluck - interface LoDashStatic { - /** - * Retrieves the value of a specified property from all elements in the collection. - * @param collection The collection to iterate over. - * @param property The property to pluck. - * @return A new array of property values. - **/ - pluck( - collection: Array, - property: string|string[]): any[]; - - /** - * @see _.pluck - **/ - pluck( - collection: List, - property: string|string[]): any[]; - - /** - * @see _.pluck - **/ - pluck( - collection: Dictionary, - property: string|string[]): any[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.pluck - **/ - pluck( - property: string): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.pluck - **/ - pluck( - property: string): LoDashImplicitArrayWrapper; - } - //_.partition interface LoDashStatic { /** @@ -5482,6 +5439,57 @@ declare module _ { pluckValue: string): LoDashImplicitArrayWrapper; } + //_.pluck + interface LoDashStatic { + /** + * Gets the property value of path from all elements in collection. + * + * @param collection The collection to iterate over. + * @param path The path of the property to pluck. + * @return A new array of property values. + */ + pluck( + collection: List|Dictionary, + path: StringRepresentable|StringRepresentable[] + ): any[]; + + /** + * @see _.pluck + */ + pluck( + collection: List|Dictionary, + path: StringRepresentable|StringRepresentable[] + ): TResult[]; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.pluck + */ + pluck(path: StringRepresentable|StringRepresentable[]): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.pluck + */ + pluck(path: StringRepresentable|StringRepresentable[]): LoDashImplicitArrayWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.pluck + */ + pluck(path: StringRepresentable|StringRepresentable[]): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.pluck + */ + pluck(path: StringRepresentable|StringRepresentable[]): LoDashExplicitArrayWrapper; + } + //_.reduce interface LoDashStatic { /**