@oscarpalmer/atoms 0.92.0 → 0.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,8 +16,8 @@ function merge(values, options) {
16
16
  if (actual.length === 1) {
17
17
  return actual[0];
18
18
  }
19
- const result = actual.every(Array.isArray) ? [] : {};
20
- const isArray = Array.isArray(result);
19
+ const isArray = actual.every(Array.isArray);
20
+ const result = isArray ? [] : {};
21
21
  const { length } = actual;
22
22
  for (let outerIndex = 0; outerIndex < length; outerIndex += 1) {
23
23
  const item = actual[outerIndex];
@@ -30,8 +30,8 @@ function merge(values, options) {
30
30
  if (isArray && skipNullable && next == null) {
31
31
  continue;
32
32
  }
33
- if (is.isArrayOrPlainObject(next)) {
34
- result[key] = is.isArrayOrPlainObject(previous) ? merge([previous, next]) : merge([next]);
33
+ if (is.isArrayOrPlainObject(next) && is.isArrayOrPlainObject(previous)) {
34
+ result[key] = merge([previous, next], { skipNullable });
35
35
  } else {
36
36
  result[key] = next;
37
37
  }
@@ -12,8 +12,8 @@ function merge(values, options) {
12
12
  if (actual.length === 1) {
13
13
  return actual[0];
14
14
  }
15
- const result = actual.every(Array.isArray) ? [] : {};
16
- const isArray = Array.isArray(result);
15
+ const isArray = actual.every(Array.isArray);
16
+ const result = isArray ? [] : {};
17
17
  const { length } = actual;
18
18
  for (let outerIndex = 0; outerIndex < length; outerIndex += 1) {
19
19
  const item = actual[outerIndex];
@@ -26,8 +26,8 @@ function merge(values, options) {
26
26
  if (isArray && skipNullable && next == null) {
27
27
  continue;
28
28
  }
29
- if (isArrayOrPlainObject(next)) {
30
- result[key] = isArrayOrPlainObject(previous) ? merge([previous, next]) : merge([next]);
29
+ if (isArrayOrPlainObject(next) && isArrayOrPlainObject(previous)) {
30
+ result[key] = merge([previous, next], { skipNullable });
31
31
  } else {
32
32
  result[key] = next;
33
33
  }
package/package.json CHANGED
@@ -208,5 +208,5 @@
208
208
  },
209
209
  "type": "module",
210
210
  "types": "./types/index.d.cts",
211
- "version": "0.92.0"
211
+ "version": "0.94.0"
212
212
  }
@@ -32,8 +32,8 @@ export function merge<Model extends ArrayOrPlainObject>(
32
32
  return actual[0];
33
33
  }
34
34
 
35
- const result = (actual.every(Array.isArray) ? [] : {}) as PlainObject;
36
- const isArray = Array.isArray(result);
35
+ const isArray = actual.every(Array.isArray);
36
+ const result = (isArray ? [] : {}) as PlainObject;
37
37
  const {length} = actual;
38
38
 
39
39
  for (let outerIndex = 0; outerIndex < length; outerIndex += 1) {
@@ -50,10 +50,8 @@ export function merge<Model extends ArrayOrPlainObject>(
50
50
  continue;
51
51
  }
52
52
 
53
- if (isArrayOrPlainObject(next)) {
54
- result[key] = isArrayOrPlainObject(previous)
55
- ? merge([previous, next])
56
- : merge([next]);
53
+ if (isArrayOrPlainObject(next) && isArrayOrPlainObject(previous)) {
54
+ result[key] = merge([previous, next], {skipNullable});
57
55
  } else {
58
56
  result[key] = next;
59
57
  }