| 451 | // this is utilized by some of the global state functionality in order to get a clone that will |
| 452 | // not continue to be modified as the GlobalState mutates |
| 453 | function clone(frm, to) { |
| 454 | if (frm === null || typeof frm !== "object") { |
| 455 | return frm; |
| 456 | } |
| 457 | if (frm.constructor !== Object && frm.constructor !== Array) { |
| 458 | return frm; |
| 459 | } |
| 460 | if (frm.constructor === Date || frm.constructor === RegExp || frm.constructor === Function || |
| 461 | frm.constructor === String || frm.constructor === Number || frm.constructor === Boolean) { |
| 462 | return new frm.constructor(frm); |
| 463 | } |
| 464 | to = to || new frm.constructor(); |
| 465 | for (var name in frm) { |
| 466 | to[name] = typeof to[name] === "undefined" ? clone(frm[name], null) : to[name]; |
| 467 | } |
| 468 | return to; |
| 469 | } |
| 470 | |
| 471 | module.exports = defineReact; |
| 472 | |