diff --git a/lodash/index.d.ts b/lodash/index.d.ts index 0cda5ae3d5..00de563bbb 100644 --- a/lodash/index.d.ts +++ b/lodash/index.d.ts @@ -69,7 +69,7 @@ added 23 array methods: - [x] _.xorBy - [x] _.xorWith -added 18 lang methods: +added 20 lang methods: - [x] _.cloneDeepWith - [x] _.cloneWith - [x] _.eq @@ -88,6 +88,8 @@ added 18 lang methods: - [x] _.toNumber - [x] _.toSafeInteger - [x] _.toString +- [X] _.conforms +- [X] _.conformsTo added 13 object methods: - [x] _.assignIn @@ -226,7 +228,6 @@ Methods: - [ ] _.split - [ ] _.cond -- [ ] _.conforms - [ ] _.nthArg - [ ] _.over - [ ] _.overEvery @@ -11436,6 +11437,33 @@ declare namespace _ { ): LoDashExplicitObjectWrapper; } + /** + * An object containing predicate functions for each property of T + */ + type ConformsPredicateObject = { + [P in keyof T]: (val: T[P]) => boolean; + }; + + //_.conforms + interface LoDashStatic { + /** + * Creates a function that invokes the predicate properties of `source` with the corresponding + * property values of a given object, returning true if all predicates return truthy, else false. + */ + conforms(source: ConformsPredicateObject): (Target: T) => boolean; + } + + //_.conformsTo + interface LoDashStatic { + /** + * Checks if object conforms to source by invoking the predicate properties of source with the + * corresponding property values of object. + * + * Note: This method is equivalent to _.conforms when source is partially applied. + */ + conformsTo(object: T, source: ConformsPredicateObject): boolean; + } + //_.eq interface LoDashStatic { /** diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 7268f1a8c2..7d4105df70 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -6488,6 +6488,18 @@ namespace TestCloneWith { } } +// _.conforms +namespace TestConforms { + let result: boolean = _.conforms({foo: (v: string) => false})({foo: "foo"}); + let result2: boolean = _.conforms({})({foo: "foo"}); +} + +// _.conformsTo +namespace TestConformsTo { + let result: boolean = _.conformsTo({foo: "foo"}, {foo: (v: string) => false}); + let result2: boolean = _.conformsTo({}, {foo: (v: string) => false}); +} + // _.eq namespace TestEq { let customizer: (value: any, other: any, indexOrKey?: number|string) => boolean;