lodash: changed _.compact() method

This commit is contained in:
Ilya Mochalov
2015-10-03 06:13:02 +05:00
parent ffceea9dd1
commit c84d19d4ad
2 changed files with 27 additions and 14 deletions
+12 -2
View File
@@ -174,8 +174,18 @@ module TestChunk {
result = _(list).chunk<TResult>(42).value();
}
result = <any[]>_.compact([0, 1, false, 2, '', 3]);
result = <_.LoDashArrayWrapper<any>>_([0, 1, false, 2, '', 3]).compact();
// _.compact
module TestCompact {
let array: TResult[];
let list: _.List<TResult>;
let result: TResult[];
result = _.compact<TResult>();
result = _.compact<TResult>(array);
result = _.compact<TResult>(list);
result = _<TResult>(array).compact().value();
result = _(list).compact<TResult>().value();
}
// _.difference
{
+15 -12
View File
@@ -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<T>(array?: Array<T>): 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<T>(array?: List<T>): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.compact
**/
* @see _.compact
*/
compact(): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.compact
*/
compact<TResult>(): LoDashArrayWrapper<TResult>;
}
//_.difference
interface LoDashStatic {
/**