"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extend = exports.extendIfNoExists = exports.extendExcept = exports.extendOnly = void 0;
const foreach_1 = require("./foreach");
const object_1 = require("./object");
function extendOnly(to, from, onlyKeys) {
    (0, foreach_1.forEach)(from, (key, value) => {
        to[key] = value;
    }, onlyKeys);
}
exports.extendOnly = extendOnly;
function extendExcept(to, from, exceptKeys) {
    const onlyKeys = (0, object_1.extractKeys)(from, exceptKeys);
    return extendOnly(to, from, onlyKeys);
}
exports.extendExcept = extendExcept;
function extendIfNoExists(to, from, onlyKeys) {
    (0, foreach_1.forEach)(from, (key, value) => {
        if (!to.hasOwnProperty(key)) {
            to[key] = value;
        }
    }, onlyKeys);
}
exports.extendIfNoExists = extendIfNoExists;
function extend(to, ...froms) {
    Object.assign(to, ...froms);
    return to;
}
exports.extend = extend;
