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.

20 lines
513 B

2 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. Object.defineProperty(exports, "cloneDeep", {
  6. enumerable: true,
  7. get: ()=>cloneDeep
  8. });
  9. function cloneDeep(value) {
  10. if (Array.isArray(value)) {
  11. return value.map((child)=>cloneDeep(child));
  12. }
  13. if (typeof value === "object" && value !== null) {
  14. return Object.fromEntries(Object.entries(value).map(([k, v])=>[
  15. k,
  16. cloneDeep(v)
  17. ]));
  18. }
  19. return value;
  20. }