|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
640 bytes
|
| Line | |
|---|
| 1 | import { keysIn } from '../object/keysIn.mjs';
|
|---|
| 2 |
|
|---|
| 3 | function toPlainObject(value) {
|
|---|
| 4 | const plainObject = {};
|
|---|
| 5 | const valueKeys = keysIn(value);
|
|---|
| 6 | for (let i = 0; i < valueKeys.length; i++) {
|
|---|
| 7 | const key = valueKeys[i];
|
|---|
| 8 | const objValue = value[key];
|
|---|
| 9 | if (key === '__proto__') {
|
|---|
| 10 | Object.defineProperty(plainObject, key, {
|
|---|
| 11 | configurable: true,
|
|---|
| 12 | enumerable: true,
|
|---|
| 13 | value: objValue,
|
|---|
| 14 | writable: true,
|
|---|
| 15 | });
|
|---|
| 16 | }
|
|---|
| 17 | else {
|
|---|
| 18 | plainObject[key] = objValue;
|
|---|
| 19 | }
|
|---|
| 20 | }
|
|---|
| 21 | return plainObject;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | export { toPlainObject };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.