]> gerrit.simantics Code Review - simantics/district.git/blob - flatten.js
e8b40444a9469287160113beb8d5ba2df4655d47
[simantics/district.git] / flatten.js
1 'use strict';
2
3 var isPlainObject = require('./is-plain-object')
4   , forEach       = require('./for-each')
5
6   , process;
7
8 process = function self(value, key) {
9         if (isPlainObject(value)) forEach(value, self, this);
10         else this[key] = value;
11 };
12
13 module.exports = function (obj) {
14         var flattened = {};
15         forEach(obj, process, flattened);
16         return flattened;
17 };