From 30e24ce7974cb44e47f4cefe3ea211a1968d8a98 Mon Sep 17 00:00:00 2001 From: DomiR Date: Fri, 15 Jan 2016 01:50:14 +0100 Subject: [PATCH] (feature) Add _.isInteger --- lodash/lodash-tests.ts | 23 +++++++++++++++++-- lodash/lodash.d.ts | 50 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 29fdbcbd31..0ccd4dae89 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5916,8 +5916,6 @@ module TestIsEqual { { let result: _.LoDashExplicitWrapper; - - result = _(any).chain().isEqual(any); } } @@ -6036,6 +6034,27 @@ module TestIsFunction { } } +// _.isInteger +module TestIsInteger { + { + let result: boolean; + + result = _.isInteger(any); + + result = _(1).isInteger(); + result = _([]).isInteger(); + result = _({}).isInteger(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(1).chain().isInteger(); + result = _([]).chain().isInteger(); + result = _({}).chain().isInteger(); + } +} + // _.isMatch var testIsMatchCustiomizerFn: (value: any, other: any, indexOrKey: number|string) => boolean; result = _.isMatch({}, {}); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 2c2a50b82d..a8ea000a62 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -82,9 +82,9 @@ added 18 lang methods: - [x] _.cloneDeepWith - [x] _.cloneWith - [ ] _.eq -- [ ] _.isArrayLike -- [ ] _.isArrayLikeObject -- [ ] _.isEqualWith +- [x] _.isArrayLike +- [x] _.isArrayLikeObject +- [x] _.isEqualWith - [ ] _.isInteger - [ ] _.isLength - [ ] _.isMatchWith @@ -9554,7 +9554,6 @@ declare module _ { } //_.isEqual - // TODO tests interface LoDashStatic { /** * Performs a deep comparison between two values to determine if they are @@ -9749,6 +9748,49 @@ declare module _ { isFunction(): LoDashExplicitWrapper; } + //_.isInteger + interface LoDashStatic { + /** + * Checks if `value` is an integer. + * + * **Note:** This method is based on [`Number.isInteger`](https://mdn.io/Number/isInteger). + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an integer, else `false`. + * @example + * + * _.isInteger(3); + * // => true + * + * _.isInteger(Number.MIN_VALUE); + * // => false + * + * _.isInteger(Infinity); + * // => false + * + * _.isInteger('3'); + * // => false + */ + isInteger(value?: any): boolean; + } + + interface LoDashImplicitWrapperBase { + /** + * @see _.isInteger + */ + isInteger(): boolean; + } + + interface LoDashExplicitWrapperBase { + /** + * @see _.isInteger + */ + isInteger(): LoDashExplicitWrapper; + } + //_.isMatch interface isMatchCustomizer { (value: any, other: any, indexOrKey?: number|string): boolean;