clone.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createClone = void 0;
  6. var _object = require("../../utils/object.js");
  7. var _factory = require("../../utils/factory.js");
  8. var name = 'clone';
  9. var dependencies = ['typed'];
  10. var createClone = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
  11. var typed = _ref.typed;
  12. /**
  13. * Clone an object. Will make a deep copy of the data.
  14. *
  15. * Syntax:
  16. *
  17. * math.clone(x)
  18. *
  19. * Examples:
  20. *
  21. * math.clone(3.5) // returns number 3.5
  22. * math.clone(math.complex('2-4i')) // returns Complex 2 - 4i
  23. * math.clone(math.unit(45, 'deg')) // returns Unit 45 deg
  24. * math.clone([[1, 2], [3, 4]]) // returns Array [[1, 2], [3, 4]]
  25. * math.clone("hello world") // returns string "hello world"
  26. *
  27. * @param {*} x Object to be cloned
  28. * @return {*} A clone of object x
  29. */
  30. return typed(name, {
  31. any: _object.clone
  32. });
  33. });
  34. exports.createClone = createClone;