MCPcopy
hub / github.com/reflux/refluxjs / clone

Function clone

src/defineReact.js:453–469  ·  view source on GitHub ↗
(frm, to)

Source from the content-addressed store, hash-verified

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
453function 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
471module.exports = defineReact;
472

Callers 1

defineReactFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected