Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
var baseCopy = require('../internal/baseCopy'),
2
keysIn = require('../object/keysIn');
3
4
/**
5
* Converts `value` to a plain object flattening inherited enumerable
6
* properties of `value` to own properties of the plain object.
7
*
8
* @static
9
* @memberOf _
10
* @category Lang
11
* @param {*} value The value to convert.
12
* @returns {Object} Returns the converted plain object.
13
* @example
14
*
15
* function Foo() {
16
* this.b = 2;
17
* }
18
*
19
* Foo.prototype.c = 3;
20
*
21
* _.assign({ 'a': 1 }, new Foo);
22
* // => { 'a': 1, 'b': 2 }
23
*
24
* _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
25
* // => { 'a': 1, 'b': 2, 'c': 3 }
26
*/
27
function toPlainObject(value) {
28
return baseCopy(value, keysIn(value));
29
}
30
31
module.exports = toPlainObject;
32
33