@nxtedition/lib 26.0.17 → 26.0.19

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.
Files changed (2) hide show
  1. package/errors.js +6 -7
  2. package/package.json +1 -1
package/errors.js CHANGED
@@ -23,17 +23,17 @@ export function parseError(error) {
23
23
 
24
24
  if (Array.isArray(error)) {
25
25
  const errors = error.map(parseError).filter(Boolean)
26
- return errors.length === 0 ? null : errors.length === 1 ? errors[0] : new AggregateError()
26
+ return errors.length === 0 ? null : errors.length === 1 ? errors[0] : new AggregateError(errors)
27
27
  }
28
28
 
29
29
  if (
30
30
  fp.isEmpty(error.message) &&
31
31
  fp.isEmpty(error.cause) &&
32
32
  fp.isEmpty(error) &&
33
- Array.isArray(errors) &&
34
- errors.length === 1
33
+ Array.isArray(error) &&
34
+ error.length === 1
35
35
  ) {
36
- error = errors[0]
36
+ error = error[0]
37
37
  }
38
38
 
39
39
  const { msg, message = msg, errors, cause, data, ...properties } = error
@@ -69,9 +69,8 @@ function _serializeError(error, { depth }) {
69
69
  }
70
70
 
71
71
  if (Array.isArray(error)) {
72
- return error.length === 0
73
- ? null
74
- : error.flatMap((x) => _serializeError(x, { depth })).filter(Boolean)
72
+ const errors = error.flatMap((x) => _serializeError(x, { depth })).filter(Boolean)
73
+ return errors.length === 0 ? null : errors
75
74
  }
76
75
 
77
76
  if (Object.prototype.hasOwnProperty.call(error, kSeen)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "26.0.17",
3
+ "version": "26.0.19",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",