main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
465 bytes
|
Rev | Line | |
---|
[d565449] | 1 | var List = require('../common/List');
|
---|
| 2 |
|
---|
| 3 | module.exports = function clone(node) {
|
---|
| 4 | var result = {};
|
---|
| 5 |
|
---|
| 6 | for (var key in node) {
|
---|
| 7 | var value = node[key];
|
---|
| 8 |
|
---|
| 9 | if (value) {
|
---|
| 10 | if (Array.isArray(value) || value instanceof List) {
|
---|
| 11 | value = value.map(clone);
|
---|
| 12 | } else if (value.constructor === Object) {
|
---|
| 13 | value = clone(value);
|
---|
| 14 | }
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | result[key] = value;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | return result;
|
---|
| 21 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.