clone.js (891B)
1 import { clone as objectClone } from '../../utils/object.js'; 2 import { factory } from '../../utils/factory.js'; 3 var name = 'clone'; 4 var dependencies = ['typed']; 5 export var createClone = /* #__PURE__ */factory(name, dependencies, _ref => { 6 var { 7 typed 8 } = _ref; 9 10 /** 11 * Clone an object. Will make a deep copy of the data. 12 * 13 * Syntax: 14 * 15 * math.clone(x) 16 * 17 * Examples: 18 * 19 * math.clone(3.5) // returns number 3.5 20 * math.clone(math.complex('2-4i') // returns Complex 2 - 4i 21 * math.clone(math.unit(45, 'deg')) // returns Unit 45 deg 22 * math.clone([[1, 2], [3, 4]]) // returns Array [[1, 2], [3, 4]] 23 * math.clone("hello world") // returns string "hello world" 24 * 25 * @param {*} x Object to be cloned 26 * @return {*} A clone of object x 27 */ 28 return typed(name, { 29 any: objectClone 30 }); 31 });