@newdash/newdash
Version:
javascript/typescript utility library
26 lines (25 loc) • 983 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const baseAssignValue_1 = __importDefault(require("./baseAssignValue"));
const eq_1 = __importDefault(require("../eq"));
/** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* Assigns `value` to `key` of `object` if the existing value is not equivalent.
*
* @private
* @param object The object to modify.
* @param key The key of the property to assign.
* @param value The value to assign.
*/
function assignValue(object, key, value) {
var objValue = object[key];
if (!(hasOwnProperty.call(object, key) && (0, eq_1.default)(objValue, value)) ||
(value === undefined && !(key in object))) {
(0, baseAssignValue_1.default)(object, key, value);
}
}
exports.default = assignValue;