mirror of
https://github.com/nodejs/node.git
synced 2025-05-18 19:31:09 +00:00

PR-URL: https://github.com/nodejs/io.js/pull/2286 Reviewed-By: Roman Reiss <me@silverwind.io>
18 lines
355 B
JavaScript
18 lines
355 B
JavaScript
'use strict';
|
|
|
|
var isPlainObject = require('./is-plain-object')
|
|
, forEach = require('./for-each')
|
|
|
|
, process;
|
|
|
|
process = function self(value, key) {
|
|
if (isPlainObject(value)) forEach(value, self, this);
|
|
else this[key] = value;
|
|
};
|
|
|
|
module.exports = function (obj) {
|
|
var flattened = {};
|
|
forEach(obj, process, flattened);
|
|
return flattened;
|
|
};
|