@newdash/newdash
Version:
javascript/typescript utility library
30 lines (29 loc) • 909 B
TypeScript
/**
* 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`.
*
* **Note:** The created function is equivalent to `conformsTo` with
* `source` partially applied.
*
* @since 5.12.0
* @category Util
* @param {Object} source The object of property predicates to conform to.
* @returns {Function} Returns the new spec function.
* @example
*
* ```js
* const objects = [
* { 'a': 2, 'b': 1 },
* { 'a': 1, 'b': 2 }
* ]
*
* filter(objects, conforms({ 'b': function(n) { return n > 1 } }))
* // => [{ 'a': 1, 'b': 2 }]
* ```
*/
export declare function conforms<T extends Record<string, any>>(source: {
[key in keyof T]?: (value: any) => boolean;
}): (obj: T) => boolean;
export declare function conforms(source: any): any;
export default conforms;