UNPKG

amos-tool

Version:

amos ui tool

22 lines (20 loc) 1.11 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), arrayToObject = require("./_tools").arrayToObject, has = Object.prototype.hasOwnProperty, merge = function e(r, t, a) { if (!t) return r; if ("object" !== (0, _typeof2.default)(t)) { if (Array.isArray(r)) r.push(t); else { if ("object" !== (0, _typeof2.default)(r)) return [ r, t ]; (a.plainObjects || a.allowPrototypes || !has.call(Object.prototype, t)) && (r[t] = !0); } return r; } if ("object" !== (0, _typeof2.default)(r)) return [ r ].concat(t); var o = r; return Array.isArray(r) && !Array.isArray(t) && (o = arrayToObject(r, a)), Array.isArray(r) && Array.isArray(t) ? (t.forEach((function(t, o) { has.call(r, o) ? r[o] && "object" === (0, _typeof2.default)(r[o]) ? r[o] = e(r[o], t, a) : r.push(t) : r[o] = t; })), r) : Object.keys(t).reduce((function(r, o) { var u = t[o]; return has.call(r, o) ? r[o] = e(r[o], u, a) : r[o] = u, r; }), o); }; module.exports = merge;