UNPKG

524 BJavaScriptView Raw
1const {isFunction} = require('lodash');
2const hideSensitive = require('./hide-sensitive');
3
4function extractErrors(err) {
5 return err && isFunction(err[Symbol.iterator]) ? [...err] : [err];
6}
7
8function 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
20module.exports = {extractErrors, hideSensitiveValues};