import { forEach } from './foreach.js';
import { allKeys } from './object.js';
export function diffOnly(base, compare = {}, onlyKeys, evenIfEmpty = false) {
    const diff = {};
    let hasDiff = false;
    let compareValue;
    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;
}
export function diff(base, compare = {}, evenIfEmpty = false) {
    return diffOnly(base, compare, allKeys(compare), evenIfEmpty);
}
