From f6bf1593866905d9503ebe8a12bb7a3b18eaee53 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 14 Sep 2015 23:04:49 +0500 Subject: [PATCH] lodash: changed _.drop() method --- lodash/lodash-tests.ts | 21 +++++++--- lodash/lodash.d.ts | 94 ++++++++++++------------------------------ 2 files changed, 41 insertions(+), 74 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5b9add244..54b6586c2 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -175,18 +175,27 @@ result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); result = _.difference([1, 2, 3, 4, 5], [5, 2, 10]); result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); +// _.drop +{ + let testDropArray: TResult[]; + let testDropList: _.List; + let result: TResult[]; + result = _.drop(testDropArray); + result = _.drop(testDropArray, 42); + result = _.drop(testDropList); + result = _.drop(testDropList, 42); + result = _(testDropArray).drop().value(); + result = _(testDropArray).drop(42).value(); + result = _(testDropList).drop().value(); + result = _(testDropList).drop(42).value(); +} + result = _.rest([1, 2, 3]); result = _.rest([1, 2, 3], 2); result = _.rest([1, 2, 3], (num) => num < 3) result = _.rest(foodsOrganic, 'test'); result = _.rest(foodsType, { 'type': 'value' }); -result = _.drop([1, 2, 3]); -result = _.drop([1, 2, 3], 2); -result = _.drop([1, 2, 3], (num) => num < 3) -result = _.drop(foodsOrganic, 'test'); -result = _.drop(foodsType, { 'type': 'value' }); - result = _.tail([1, 2, 3]) result = _.tail([1, 2, 3], 2) result = _.tail([1, 2, 3], (num) => num < 3) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b6c95710b..39263df8b 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -397,6 +397,32 @@ declare module _ { ...others: List[]): LoDashArrayWrapper; } + //_.drop + interface LoDashStatic { + /** + * Creates a slice of array with n elements dropped from the beginning. + * + * @param array The array to query. + * @param n The number of elements to drop. + * @return Returns the slice of array. + */ + drop(array: T[]|List, n?: number): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.drop + */ + drop(n?: number): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.drop + */ + drop(n?: number): LoDashArrayWrapper; + } + //_.findIndex interface LoDashStatic { /** @@ -1280,74 +1306,6 @@ declare module _ { array: List, whereValue: W): T[]; - /** - * @see _.rest - **/ - drop(array: Array): T[]; - - /** - * @see _.rest - **/ - drop(array: List): T[]; - - /** - * @see _.rest - **/ - drop( - array: Array, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.rest - **/ - drop( - array: Array, - n: number): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - n: number): T[]; - - /** - * @see _.rest - **/ - drop( - array: Array, - pluckValue: string): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - pluckValue: string): T[]; - - /** - * @see _.rest - **/ - drop( - array: Array, - whereValue: W): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - whereValue: W): T[]; - /** * @see _.rest **/