From ee4d7e5e9cc0fa1642f31b1135333869a83b2b4d Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sun, 9 Aug 2015 20:21:01 +0500 Subject: [PATCH] lodash: added _.isMatch() method --- lodash/lodash-tests.ts | 9 +++++++++ lodash/lodash.d.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d36b5dfc4..f6048025e 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1060,6 +1060,15 @@ result = _(1).gte(2); result = _([]).gte(2); result = _({}).gte(2); +// _.isMatch +var testIsMatchCustiomizerFn: (value: any, other: any, indexOrKey: number|string) => boolean; +result = _.isMatch({}, {}); +result = _.isMatch({}, {}, testIsMatchCustiomizerFn); +result = _.isMatch({}, {}, testIsMatchCustiomizerFn, {}); +result = _({}).isMatch({}); +result = _({}).isMatch({}, testIsMatchCustiomizerFn); +result = _({}).isMatch({}, testIsMatchCustiomizerFn, {}); + // _.lt result = _.lt(1, 2); result = _(1).lt(2); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 7c4111746..7ea01692e 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -5861,6 +5861,33 @@ declare module _ { gte(other: any): boolean; } + //_.isMatch + interface isMatchCustomizer { + (value: any, other: any, indexOrKey?: number|string): boolean; + } + + interface LoDashStatic { + /** + * Performs a deep comparison between object and source to determine if object contains equivalent property + * values. If customizer is provided it’s invoked to compare values. If customizer returns undefined + * comparisons are handled by the method instead. The customizer is bound to thisArg and invoked with three + * arguments: (value, other, index|key). + * @param object The object to inspect. + * @param source The object of property values to match. + * @param customizer The function to customize value comparisons. + * @param thisArg The this binding of customizer. + * @return Returns true if object is a match, else false. + */ + isMatch(object: Object, source: Object, customizer?: isMatchCustomizer, thisArg?: any): boolean; + } + + interface LoDashObjectWrapper { + /** + * @see _.isMatch + */ + isMatch(source: Object, customizer?: isMatchCustomizer, thisArg?: any): boolean; + } + //_.lt interface LoDashStatic { /**