From c84d19d4ad54cc3422f2c304a391d6bcc18dd998 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 30 Sep 2015 21:25:51 +0500 Subject: [PATCH] lodash: changed _.compact() method --- lodash/lodash-tests.ts | 14 ++++++++++++-- lodash/lodash.d.ts | 27 +++++++++++++++------------ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1d5525300..bdab83269 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -174,8 +174,18 @@ module TestChunk { result = _(list).chunk(42).value(); } -result = _.compact([0, 1, false, 2, '', 3]); -result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); +// _.compact +module TestCompact { + let array: TResult[]; + let list: _.List; + let result: TResult[]; + + result = _.compact(); + result = _.compact(array); + result = _.compact(list); + result = _(array).compact().value(); + result = _(list).compact().value(); +} // _.difference { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 102811a16..c93152e75 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -349,26 +349,29 @@ declare module _ { //_.compact interface LoDashStatic { /** - * Returns a copy of the array with all falsy values removed. In JavaScript, false, null, 0, "", - * undefined and NaN are all falsy. - * @param array Array to compact. - * @return (Array) Returns a new array of filtered values. - **/ - compact(array?: Array): T[]; - - /** - * @see _.compact - **/ + * Creates an array with all falsey values removed. The values false, null, 0, "", undefined, and NaN are + * falsey. + * + * @param array The array to compact. + * @return (Array) Returns the new array of filtered values. + */ compact(array?: List): T[]; } interface LoDashArrayWrapper { /** - * @see _.compact - **/ + * @see _.compact + */ compact(): LoDashArrayWrapper; } + interface LoDashObjectWrapper { + /** + * @see _.compact + */ + compact(): LoDashArrayWrapper; + } + //_.difference interface LoDashStatic { /**