1 | const {isFunction} = require('lodash');
|
2 | const hideSensitive = require('./hide-sensitive');
|
3 |
|
4 | function extractErrors(err) {
|
5 | return err && isFunction(err[Symbol.iterator]) ? [...err] : [err];
|
6 | }
|
7 |
|
8 | function hideSensitiveValues(env, objs) {
|
9 | const hideFunction = hideSensitive(env);
|
10 | return objs.map(obj => {
|
11 | Object.getOwnPropertyNames(obj).forEach(prop => {
|
12 | if (obj[prop]) {
|
13 | obj[prop] = hideFunction(obj[prop]);
|
14 | }
|
15 | });
|
16 | return obj;
|
17 | });
|
18 | }
|
19 |
|
20 | module.exports = {extractErrors, hideSensitiveValues};
|