From 9ab4d2254ed373bf174c13c1a4abd5690f31027a Mon Sep 17 00:00:00 2001 From: DomiR Date: Fri, 15 Jan 2016 01:59:49 +0100 Subject: [PATCH] (feature) Add _.isObjectLike --- lodash/lodash-tests.ts | 20 ++++++++++++++++++++ lodash/lodash.d.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d97800833..7b2a10356 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -6245,6 +6245,26 @@ module TestIsObject { } } +// _.isObjectLike +module TestIsObjectLike { + { + let result: boolean; + + result = _.isObjectLike(any); + result = _(1).isObjectLike(); + result = _([]).isObjectLike(); + result = _({}).isObjectLike(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(1).chain().isObjectLike(); + result = _([]).chain().isObjectLike(); + result = _({}).chain().isObjectLike(); + } +} + // _.isPlainObject module TestIsPlainObject { { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 4c6a30c23..aa21e03cd 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -10087,6 +10087,48 @@ declare module _ { isObject(): LoDashExplicitWrapper; } + //_.isObjectLike + interface LoDashStatic { + /** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ + isObjectLike(value?: any): boolean; + } + + interface LoDashImplicitWrapperBase { + /** + * see _.isObjectLike + */ + isObjectLike(): boolean; + } + + interface LoDashExplicitWrapperBase { + /** + * see _.isObjectLike + */ + isObjectLike(): LoDashExplicitWrapper; + } + //_.isPlainObject interface LoDashStatic { /**