@esfaenza/extensions 11.2.27 → 11.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1794,6 +1794,48 @@
1794
1794
  return "string";
1795
1795
  }
1796
1796
  };
1797
+ /**
1798
+ * Effettua la clonazione profonda di un oggetto in maniera molto più performante che JSON.parse(JSON.stringify()).
1799
+ *
1800
+ * Usare solo per oggetti puri e quantomeno semplici per evitare complicazioni derivanti dalle semplificazioni che questo metodo assume
1801
+ *
1802
+ * @param {any} source Oggetto da clonare
1803
+ *
1804
+ * @return {any} Clone dell'oggetto passato
1805
+ */
1806
+ UtilityService.prototype.deepClone = function (source) {
1807
+ // Valori semplici
1808
+ if (source == null || typeof source !== 'object')
1809
+ return source;
1810
+ // Pseudo Struct
1811
+ switch (toString.call(source)) {
1812
+ case '[object Boolean]':
1813
+ case '[object Number]':
1814
+ case '[object String]':
1815
+ case '[object Date]':
1816
+ return new source.constructor(source.valueOf());
1817
+ default: break;
1818
+ }
1819
+ // Oggetti Complessi
1820
+ return this.recursiveStep(source, Array.isArray(source) || source instanceof Array ? [] : Object.create(Object.getPrototypeOf(source)));
1821
+ };
1822
+ /**
1823
+ * @ignore
1824
+ * Step ricorsivo per la clonatura degli oggetti. Vedere **deepClone**
1825
+ */
1826
+ UtilityService.prototype.recursiveStep = function (source, destination) {
1827
+ if (Array.isArray(source) || source instanceof Array) {
1828
+ for (var i = 0, ii = source.length; i < ii; i++)
1829
+ destination.push(this.deepClone(source[i]));
1830
+ }
1831
+ else if (source && typeof source.hasOwnProperty === 'function') {
1832
+ for (var key in source) {
1833
+ if (source.hasOwnProperty(key))
1834
+ destination[key] = this.deepClone(source[key]);
1835
+ }
1836
+ }
1837
+ return destination;
1838
+ };
1797
1839
  return UtilityService;
1798
1840
  }());
1799
1841
  UtilityService.decorators = [