From 4f38ac3bc6649ce32dbd17d2c46bff46ffa2dbb4 Mon Sep 17 00:00:00 2001 From: DomiR Date: Fri, 15 Jan 2016 15:54:38 +0100 Subject: [PATCH] (feature) Add _.rangeRight --- lodash/lodash-tests.ts | 27 ++++++++++++++++ lodash/lodash.d.ts | 73 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 0a356d90e..af33b66ac 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -9917,6 +9917,33 @@ module TestRange { } } +// _.rangeRight +module TestRangeRight { + { + let result: number[]; + + result = _.rangeRight(10); + result = _.rangeRight(1, 11); + result = _.rangeRight(0, 30, 5); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(10).rangeRight(); + result = _(1).rangeRight(11); + result = _(0).rangeRight(30, 5); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(10).chain().rangeRight(); + result = _(1).chain().rangeRight(11); + result = _(0).chain().rangeRight(30, 5); + } +} + // _.runInContext { let result: typeof _; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 097290c78..d9e957f9a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -131,7 +131,7 @@ added 8 utility methods: - [ ] _.overEvery - [ ] _.overSome - [ ] _.rangeRight -- [ ] _.toPath +- [x] _.toPath added 4 math methods: - [x] _.maxBy @@ -15756,6 +15756,77 @@ declare module _ { ): LoDashExplicitArrayWrapper; } + //_.rangeRight + interface LoDashStatic { + /** + * This method is like `_.range` except that it populates values in + * descending order. + * + * @static + * @memberOf _ + * @category Util + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @param {number} [step=1] The value to increment or decrement by. + * @returns {Array} Returns the new array of numbers. + * @example + * + * _.rangeRight(4); + * // => [3, 2, 1, 0] + * + * _.rangeRight(-4); + * // => [-3, -2, -1, 0] + * + * _.rangeRight(1, 5); + * // => [4, 3, 2, 1] + * + * _.rangeRight(0, 20, 5); + * // => [15, 10, 5, 0] + * + * _.rangeRight(0, -4, -1); + * // => [-3, -2, -1, 0] + * + * _.rangeRight(1, 4, 0); + * // => [1, 1, 1] + * + * _.rangeRight(0); + * // => [] + */ + rangeRight( + start: number, + end: number, + step?: number + ): number[]; + + /** + * @see _.rangeRight + */ + rangeRight( + end: number, + step?: number + ): number[]; + } + + interface LoDashImplicitWrapper { + /** + * @see _.rangeRight + */ + rangeRight( + end?: number, + step?: number + ): LoDashImplicitArrayWrapper; + } + + interface LoDashExplicitWrapper { + /** + * @see _.rangeRight + */ + rangeRight( + end?: number, + step?: number + ): LoDashExplicitArrayWrapper; + } + //_.runInContext interface LoDashStatic { /**