simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

clone.js (1038B)


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