UNPKG

d2-ui

Version:
32 lines (29 loc) 833 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = objectApplyIf; /** * Applies properties from "config" if they are undefined in "object. * * @param {Object} object The object to receive properties * @param {Object} config The object to pass properties * @returns {Object} The object that may have received properties * * @example * let object = {id: 1} * const config = {id: 2, name: 'Name'} * objectApplyIf(object, config); // returns: {id: 1, name: 'Name'} */ function objectApplyIf(object, config) { var property; if (object) { for (property in config) { if (object[property] === undefined) { object[property] = config[property]; } } } return object; } //# sourceMappingURL=objectApplyIf.js.map