"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.diff = exports.diffOnly = void 0;
const foreach_js_1 = require("./foreach.js");
const object_js_1 = require("./object.js");
function diffOnly(base, compare = {}, onlyKeys, evenIfEmpty = false) {
    const diff = {};
    let hasDiff = false;
    let compareValue;
    (0, foreach_js_1.forEach)(base, (key, value) => {
        compareValue = compare[key];
        if ((evenIfEmpty || (compareValue !== null && compareValue !== undefined)) && compareValue !== value) {
            hasDiff = true;
            diff[key] = compareValue;
        }
    }, onlyKeys);
    return hasDiff ? diff : null;
}
exports.diffOnly = diffOnly;
function diff(base, compare = {}, evenIfEmpty = false) {
    return diffOnly(base, compare, (0, object_js_1.allKeys)(compare), evenIfEmpty);
}
exports.diff = diff;
