# All files / lib converters.js

83.33% Statements 10/12
70% Branches 7/10
75% Functions 3/4
81.82% Lines 9/11

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26

    1x

    1x

    48x

    28x

    28x
    36x
    36x

    48x
    48x
     'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.convertValues = convertValues;
    // Convert object or array values
    function convertValues(obj, detect, convert) {
      if (!isObjectOrArray(obj)) return obj;

      Iif (Array.isArray(obj)) {
        return obj.map(function (value, i) {
          return detect(value) ? convert(value) : convertValues(value, detect, convert);
        });
      }

      return Object.keys(obj).reduce(function (clone, key) {
        clone[key] = detect(obj[key]) ? convert(obj[key]) : convertValues(obj[key], detect, convert);
        return clone;
      }, {});
    }

    function isObjectOrArray(obj) {
      var type = Object.prototype.toString.call(obj);
      return type === '[object Object]' || type === '[object Array]';
    }