From e0438708cfda11de3f112aa892a840cb94dc6488 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Thu, 30 Jul 2015 17:30:20 +0100 Subject: [PATCH] Remove non-existent _.last overloads, add _().last chainable form --- lodash/lodash-tests.ts | 7 +--- lodash/lodash.d.ts | 86 ++++-------------------------------------- 2 files changed, 8 insertions(+), 85 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 877364ef0..d9a27fb2c 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -263,12 +263,7 @@ result = _.initial(foodsType, { 'type': 'vegetable' }); result = _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); result = _.last([1, 2, 3]); -result = _.last([1, 2, 3], 2); -result = _.last([1, 2, 3], function (num) { - return num > 1; -}); -result = _.last(foodsOrganic, 'organic'); -result = _.last(foodsType, { 'type': 'vegetable' }); +result = _([1, 2, 3]).last(); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 7bbb65a54..5d658853d 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -991,90 +991,18 @@ declare module _ { //_.last interface LoDashStatic { /** - * Gets the last element or last n elements of an array. If a callback is provided - * elements at the end of the array are returned as long as the callback returns truey. - * The callback is bound to thisArg and invoked with three arguments; (value, index, array). - * - * If a property name is provided for callback the created "_.pluck" style callback will - * return the property value of the given element. - * - * If an object is provided for callback the created "_.where" style callback will return - * true for elements that have the properties of the given object, else false. + * Gets the last element of an array. * @param array The array to query. - * @return Returns the last element(s) of array. + * @return Returns the last element of array. **/ last(array: Array): T; + } + interface LoDashArrayWrapper { /** - * @see _.last - **/ - last(array: List): T; - - /** - * @see _.last - * @param n The number of elements to return - **/ - last( - array: Array, - n: number): T[]; - - /** - * @see _.last - * @param n The number of elements to return - **/ - last( - array: List, - n: number): T[]; - - /** - * @see _.last - * @param callback The function called per element - **/ - last( - array: Array, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.last - * @param callback The function called per element - **/ - last( - array: List, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.last - * @param pluckValue _.pluck style callback - **/ - last( - array: Array, - pluckValue: string): T[]; - - /** - * @see _.last - * @param pluckValue _.pluck style callback - **/ - last( - array: List, - pluckValue: string): T[]; - - /** - * @see _.last - * @param whereValue _.where style callback - **/ - last( - array: Array, - whereValue: W): T[]; - - /** - * @see _.last - * @param whereValue _.where style callback - **/ - last( - array: List, - whereValue: W): T[]; + * @see _.last + **/ + last(): T; } //_.lastIndexOf