You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
465 B

4 years ago
  1. var List = require('../common/List');
  2. module.exports = function clone(node) {
  3. var result = {};
  4. for (var key in node) {
  5. var value = node[key];
  6. if (value) {
  7. if (Array.isArray(value) || value instanceof List) {
  8. value = value.map(clone);
  9. } else if (value.constructor === Object) {
  10. value = clone(value);
  11. }
  12. }
  13. result[key] = value;
  14. }
  15. return result;
  16. };