diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 6a1d6618c..db0328cc2 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -275,14 +275,10 @@ module TestFirst { result = _(list).first(); } -result = _.take([1, 2, 3]); -result = _.take([1, 2, 3], 2); result = _.takeWhile([1, 2, 3], (num) => num < 3); result = _.takeWhile(foodsOrganic, 'organic'); result = _.takeWhile(foodsType, { 'type': 'fruit' }); -result = _([1, 2, 3]).take().value(); -result = _([1, 2, 3]).take(2).value(); result = _([1, 2, 3]).takeWhile(function (num) { return num < 3; }).value(); @@ -456,6 +452,21 @@ result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function return this.wordToNumber[word]; }, sortedIndexDict); +// _.take +module TestTake { + let array: TResult[]; + let list: _.List; + let result: TResult[]; + result = _.take(array); + result = _.take(array, 42); + result = _.take(list); + result = _.take(list, 42); + result = _(array).take().value(); + result = _(array).take(42).value(); + result = _(list).take().value(); + result = _(list).take(42).value(); +} + // _.takeRight { let testTakeRightArray: TResult[]; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 23a76bfc7..bd44e7953 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -587,30 +587,6 @@ declare module _ { } interface LoDashStatic { - /** - * @see _.first - **/ - take(array: Array): T[]; - - /** - * @see _.first - **/ - take(array: List): T[]; - - /** - * @see _.first - **/ - take( - array: Array, - n: number): T[]; - - /** - * @see _.first - **/ - take( - array: List, - n: number): T[]; - /** * Takes the first items from an array or list based on a predicate * @param array The array or list of items on which the result set will be based @@ -645,17 +621,6 @@ declare module _ { } interface LoDashArrayWrapper { - /** - * @see _.first - **/ - take(): LoDashArrayWrapper; - - /** - * @see _.first - * @param n The number of elements to return. - **/ - take(n: number): LoDashArrayWrapper; - /** * Takes the first items based on a predicate * @param predicate The function called per element. @@ -1284,6 +1249,35 @@ declare module _ { whereValue: W): number; } + //_.take + interface LoDashStatic { + /** + * Creates a slice of array with n elements taken from the beginning. + * + * @param array The array to query. + * @param n The number of elements to take. + * @return Returns the slice of array. + */ + take( + array: List, + n?: number + ): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.take + */ + take(n?: number): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.take + */ + take(n?: number): LoDashArrayWrapper; + } + //_.takeRight interface LoDashStatic { /**