1
0

flatten.js 355 B

1234567891011121314151617
  1. 'use strict';
  2. var isPlainObject = require('./is-plain-object')
  3. , forEach = require('./for-each')
  4. , process;
  5. process = function self(value, key) {
  6. if (isPlainObject(value)) forEach(value, self, this);
  7. else this[key] = value;
  8. };
  9. module.exports = function (obj) {
  10. var flattened = {};
  11. forEach(obj, process, flattened);
  12. return flattened;
  13. };