From 2fff06cb701e5528e7c59989779b81e48eb6b364 Mon Sep 17 00:00:00 2001 From: DomiR Date: Fri, 15 Jan 2016 01:52:15 +0100 Subject: [PATCH] (feature) Add _.isLength --- lodash/lodash-tests.ts | 21 +++++++++++++++++++++ lodash/lodash.d.ts | 43 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 0ccd4dae89..ed32391341 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -6055,6 +6055,27 @@ module TestIsInteger { } } +// _.isLength +module TestIsLength { + { + let result: boolean; + + result = _.isLength(any); + + result = _(1).isLength(); + result = _([]).isLength(); + result = _({}).isLength(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(1).chain().isLength(); + result = _([]).chain().isLength(); + result = _({}).chain().isLength(); + } +} + // _.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 a8ea000a62..a5c8ff5db6 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9791,6 +9791,49 @@ declare module _ { isInteger(): LoDashExplicitWrapper; } + //_.isLength + interface LoDashStatic { + /** + * Checks if `value` is a valid array-like length. + * + * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ + isLength(value?: any): boolean; + } + + interface LoDashImplicitWrapperBase { + /** + * @see _.isLength + */ + isLength(): boolean; + } + + interface LoDashExplicitWrapperBase { + /** + * @see _.isLength + */ + isLength(): LoDashExplicitWrapper; + } + //_.isMatch interface isMatchCustomizer { (value: any, other: any, indexOrKey?: number|string): boolean;