From bfdee37043dd6c1a755acab4f347cf95a255cf25 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 15 Sep 2015 01:36:11 +0500 Subject: [PATCH] lodash: changed _.initial() method --- lodash/lodash-tests.ts | 17 +++++--- lodash/lodash.d.ts | 98 +++++++----------------------------------- 2 files changed, 26 insertions(+), 89 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5b9add244..22ccc3e99 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -282,13 +282,16 @@ result = _.indexOf([1, 2, 3, 1, 2, 3], 2); result = _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); -result = _.initial([1, 2, 3]); -result = _.initial([1, 2, 3], 2); -result = _.initial([1, 2, 3], function (num) { - return num > 1; -}); -result = _.initial(foodsOrganic, 'organic'); -result = _.initial(foodsType, { 'type': 'vegetable' }); +//_.initial +{ + let testInitalArray: TResult[]; + let testInitalList: _.List; + let result: TResult[]; + result = _.initial(testInitalArray); + result = _.initial(testInitalList); + result = _(testInitalArray).initial().value(); + result = _(testInitalList).initial().value(); +} result = _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b6c95710b..4e0880850 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -937,92 +937,26 @@ declare module _ { //_.initial interface LoDashStatic { /** - * Gets all but the last element or last n elements of an array. If a callback is provided - * elements at the end of the array are excluded from the result 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. - * @param array The array to query. - * @param n Leaves this many elements behind, optional. - * @return Returns everything but the last `n` elements of `array`. - **/ - initial( - array: Array): T[]; + * Gets all but the last element of array. + * + * @param array The array to query. + * @return Returns the slice of array. + */ + initial(array: T[]|List): T[]; + } + interface LoDashArrayWrapper { /** - * @see _.initial - **/ - initial( - array: List): T[]; + * @see _.initial + */ + initial(): LoDashArrayWrapper; + } + interface LoDashObjectWrapper { /** - * @see _.initial - * @param n The number of elements to exclude. - **/ - initial( - array: Array, - n: number): T[]; - - /** - * @see _.initial - * @param n The number of elements to exclude. - **/ - initial( - array: List, - n: number): T[]; - - /** - * @see _.initial - * @param callback The function called per element - **/ - initial( - array: Array, - callback: ListIterator): T[]; - - /** - * @see _.initial - * @param callback The function called per element - **/ - initial( - array: List, - callback: ListIterator): T[]; - - /** - * @see _.initial - * @param pluckValue _.pluck style callback - **/ - initial( - array: Array, - pluckValue: string): T[]; - - /** - * @see _.initial - * @param pluckValue _.pluck style callback - **/ - initial( - array: List, - pluckValue: string): T[]; - - /** - * @see _.initial - * @param whereValue _.where style callback - **/ - initial( - array: Array, - whereValue: W): T[]; - - /** - * @see _.initial - * @param whereValue _.where style callback - **/ - initial( - array: List, - whereValue: W): T[]; + * @see _.initial + */ + initial(): LoDashArrayWrapper; } //_.intersection