UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

38 lines (37 loc) 1.29 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.conformsTo = void 0; const baseConformsTo_1 = __importDefault(require("./.internal/baseConformsTo")); const keys_1 = __importDefault(require("./keys")); /** * 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. * * @since 5.12.0 * @category Lang * @param {Object} object The object to inspect. * @param {Object} source The object of property predicates to conform to. * @returns {boolean} Returns `true` if `object` conforms, else `false`. * @example * * ```js * const object = { 'a': 1, 'b': 2 } * * conformsTo(object, { 'b': function(n) { return n > 1 } }) * // => true * * conformsTo(object, { 'b': function(n) { return n > 2 } }) * // => false * ``` */ function conformsTo(object, source) { return source == null || (0, baseConformsTo_1.default)(object, source, (0, keys_1.default)(source)); } exports.conformsTo = conformsTo; exports.default = conformsTo;