[79a0317] | 1 | "use strict";
|
---|
| 2 | var __read = (this && this.__read) || function (o, n) {
|
---|
| 3 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
---|
| 4 | if (!m) return o;
|
---|
| 5 | var i = m.call(o), r, ar = [], e;
|
---|
| 6 | try {
|
---|
| 7 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
---|
| 8 | }
|
---|
| 9 | catch (error) { e = { error: error }; }
|
---|
| 10 | finally {
|
---|
| 11 | try {
|
---|
| 12 | if (r && !r.done && (m = i["return"])) m.call(i);
|
---|
| 13 | }
|
---|
| 14 | finally { if (e) throw e.error; }
|
---|
| 15 | }
|
---|
| 16 | return ar;
|
---|
| 17 | };
|
---|
| 18 | var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
---|
| 19 | if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
---|
| 20 | if (ar || !(i in from)) {
|
---|
| 21 | if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
---|
| 22 | ar[i] = from[i];
|
---|
| 23 | }
|
---|
| 24 | }
|
---|
| 25 | return to.concat(ar || Array.prototype.slice.call(from));
|
---|
| 26 | };
|
---|
| 27 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
---|
| 28 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
---|
| 29 | };
|
---|
| 30 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 31 | var clone_deep_1 = __importDefault(require("clone-deep"));
|
---|
| 32 | var merge_with_1 = __importDefault(require("./merge-with"));
|
---|
| 33 | var utils_1 = require("./utils");
|
---|
| 34 | var isArray = Array.isArray;
|
---|
| 35 | function joinArrays(_a) {
|
---|
| 36 | var _b = _a === void 0 ? {} : _a, customizeArray = _b.customizeArray, customizeObject = _b.customizeObject, key = _b.key;
|
---|
| 37 | return function _joinArrays(a, b, k) {
|
---|
| 38 | var newKey = key ? "".concat(key, ".").concat(k) : k;
|
---|
| 39 | if ((0, utils_1.isFunction)(a) && (0, utils_1.isFunction)(b)) {
|
---|
| 40 | return function () {
|
---|
| 41 | var args = [];
|
---|
| 42 | for (var _i = 0; _i < arguments.length; _i++) {
|
---|
| 43 | args[_i] = arguments[_i];
|
---|
| 44 | }
|
---|
| 45 | return _joinArrays(a.apply(void 0, __spreadArray([], __read(args), false)), b.apply(void 0, __spreadArray([], __read(args), false)), k);
|
---|
| 46 | };
|
---|
| 47 | }
|
---|
| 48 | if (isArray(a) && isArray(b)) {
|
---|
| 49 | var customResult = customizeArray && customizeArray(a, b, newKey);
|
---|
| 50 | return customResult || __spreadArray(__spreadArray([], __read(a), false), __read(b), false);
|
---|
| 51 | }
|
---|
| 52 | if ((0, utils_1.isRegex)(b)) {
|
---|
| 53 | return b;
|
---|
| 54 | }
|
---|
| 55 | if ((0, utils_1.isPlainObject)(a) && (0, utils_1.isPlainObject)(b)) {
|
---|
| 56 | var customResult = customizeObject && customizeObject(a, b, newKey);
|
---|
| 57 | return (customResult ||
|
---|
| 58 | (0, merge_with_1.default)([a, b], joinArrays({
|
---|
| 59 | customizeArray: customizeArray,
|
---|
| 60 | customizeObject: customizeObject,
|
---|
| 61 | key: newKey,
|
---|
| 62 | })));
|
---|
| 63 | }
|
---|
| 64 | if ((0, utils_1.isPlainObject)(b)) {
|
---|
| 65 | return (0, clone_deep_1.default)(b);
|
---|
| 66 | // The behavior of structuredClone differs from cloneDeep
|
---|
| 67 | // so it cannot work as a replacement for all cases although
|
---|
| 68 | // tests pass with it.
|
---|
| 69 | // return structuredClone(b);
|
---|
| 70 | }
|
---|
| 71 | if (isArray(b)) {
|
---|
| 72 | return __spreadArray([], __read(b), false);
|
---|
| 73 | }
|
---|
| 74 | return b;
|
---|
| 75 | };
|
---|
| 76 | }
|
---|
| 77 | exports.default = joinArrays;
|
---|
| 78 | //# sourceMappingURL=join-arrays.js.map |
---|