Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
744 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var copyObject = require('./_copyObject'),
|
---|
| 2 | keysIn = require('./keysIn');
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Converts `value` to a plain object flattening inherited enumerable string
|
---|
| 6 | * keyed properties of `value` to own properties of the plain object.
|
---|
| 7 | *
|
---|
| 8 | * @static
|
---|
| 9 | * @memberOf _
|
---|
| 10 | * @since 3.0.0
|
---|
| 11 | * @category Lang
|
---|
| 12 | * @param {*} value The value to convert.
|
---|
| 13 | * @returns {Object} Returns the converted plain object.
|
---|
| 14 | * @example
|
---|
| 15 | *
|
---|
| 16 | * function Foo() {
|
---|
| 17 | * this.b = 2;
|
---|
| 18 | * }
|
---|
| 19 | *
|
---|
| 20 | * Foo.prototype.c = 3;
|
---|
| 21 | *
|
---|
| 22 | * _.assign({ 'a': 1 }, new Foo);
|
---|
| 23 | * // => { 'a': 1, 'b': 2 }
|
---|
| 24 | *
|
---|
| 25 | * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
|
---|
| 26 | * // => { 'a': 1, 'b': 2, 'c': 3 }
|
---|
| 27 | */
|
---|
| 28 | function toPlainObject(value) {
|
---|
| 29 | return copyObject(value, keysIn(value));
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | module.exports = toPlainObject;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.