'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = clean;

var _foreach;

function _load_foreach() {
  return _foreach = _interopRequireDefault(require('./object/foreach'));
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * Cleans all object's properties that contains a falsy value 
 * and returns a new object without them.
 * @name clean
 * @param {object} obj object to clean
 * @returns {object}
 * @example new cleaned object
 * ```js
 *  clean({ foo: null, bar: 'foo' }) // => { bar: 'foo' }
 * ```
 */
function clean(obj) {
  var newObj = {};

  (0, (_foreach || _load_foreach()).default)(obj, function (val, key) {
    if (!val) return;
    newObj[key] = val;
  });

  return newObj;
}