UNPKG

820 BJavaScriptView Raw
1'use strict'
2
3const object = require('../../utils/object')
4
5function factory (type, config, load, typed) {
6 /**
7 * Clone an object.
8 *
9 * Syntax:
10 *
11 * math.clone(x)
12 *
13 * Examples:
14 *
15 * math.clone(3.5) // returns number 3.5
16 * math.clone(math.complex('2-4i') // returns Complex 2 - 4i
17 * math.clone(math.unit(45, 'deg')) // returns Unit 45 deg
18 * math.clone([[1, 2], [3, 4]]) // returns Array [[1, 2], [3, 4]]
19 * math.clone("hello world") // returns string "hello world"
20 *
21 * @param {*} x Object to be cloned
22 * @return {*} A clone of object x
23 */
24 const clone = typed('clone', {
25 'any': object.clone
26 })
27
28 clone.toTex = undefined // use default template
29
30 return clone
31}
32
33exports.name = 'clone'
34exports.factory = factory