@firestitch/common 12.1.0 → 12.2.2

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('lodash-es'), require('rxjs'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('@firestitch/common', ['exports', '@angular/core', '@angular/common', 'lodash-es', 'rxjs', 'rxjs/operators'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.firestitch = global.firestitch || {}, global.firestitch.common = {}), global.ng.core, global.ng.common, global.lodashEs, global.rxjs, global.rxjs.operators));
5
- })(this, (function (exports, i0, common, lodashEs, rxjs, operators) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('rxjs'), require('rxjs/operators')) :
3
+ typeof define === 'function' && define.amd ? define('@firestitch/common', ['exports', '@angular/core', '@angular/common', 'rxjs', 'rxjs/operators'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.firestitch = global.firestitch || {}, global.firestitch.common = {}), global.ng.core, global.ng.common, global.rxjs, global.rxjs.operators));
5
+ })(this, (function (exports, i0, common, rxjs, operators) { 'use strict';
6
6
 
7
7
  function _interopNamespace(e) {
8
8
  if (e && e.__esModule) return e;
@@ -584,9 +584,9 @@
584
584
  value === null ||
585
585
  value === false ||
586
586
  value === '' ||
587
- !lodashEs.toString(value).length ||
588
- (lodashEs.isObject(value) &&
589
- (value.constructor.name === 'Object' && !Object.keys(value).length)) ||
587
+ String(value).length === 0 ||
588
+ (Array.isArray(value) && value.length === 0) ||
589
+ (value instanceof Object && (value.constructor.name === 'Object' && !Object.keys(value).length)) ||
590
590
  (!options.zero && (value === 0 || value === '0'));
591
591
  }
592
592
 
@@ -680,7 +680,7 @@
680
680
  if (precision === void 0) { precision = [2, 10]; }
681
681
  if (currencyCode === void 0) { currencyCode = 'USD'; }
682
682
  if (locale === void 0) { locale = 'en-US'; }
683
- var digitsInfo = lodashEs.isArray(precision) ? precision : [precision, precision];
683
+ var digitsInfo = Array.isArray(precision) ? precision : [precision, precision];
684
684
  return new common.CurrencyPipe(locale).transform(amount, currencyCode, 'symbol', "1." + digitsInfo[0] + "-" + digitsInfo[1]);
685
685
  }
686
686
 
@@ -1437,7 +1437,7 @@
1437
1437
  }
1438
1438
 
1439
1439
  function boolean(value) {
1440
- return lodashEs.toString(value).toLowerCase() !== 'false' && !!value;
1440
+ return String(value).toLowerCase() !== 'false' && !!value;
1441
1441
  }
1442
1442
 
1443
1443
  function debounce(func, wait, immediate) {
@@ -1496,12 +1496,12 @@
1496
1496
  var KEY_EQUALS = 61;
1497
1497
 
1498
1498
  function length(object) {
1499
- if (lodashEs.isObject(object)) {
1500
- return Object.keys(object).length;
1501
- }
1502
- if (lodashEs.isArray(object)) {
1499
+ if (Array.isArray(object)) {
1503
1500
  return object.length;
1504
1501
  }
1502
+ if (object instanceof Object) {
1503
+ return Object.keys(object).length;
1504
+ }
1505
1505
  return 0;
1506
1506
  }
1507
1507
 
@@ -1548,7 +1548,7 @@
1548
1548
  }
1549
1549
 
1550
1550
  function isNumeric(value) {
1551
- var str = lodashEs.toString(value);
1551
+ var str = String(value);
1552
1552
  return str.length && !!str.match(/^-?\d*\.?\d*$/);
1553
1553
  }
1554
1554
 
@@ -1767,6 +1767,33 @@
1767
1767
  return removeQueryParams(path);
1768
1768
  }
1769
1769
 
1770
+ function round(num, decimalPlaces) {
1771
+ if (decimalPlaces === void 0) { decimalPlaces = 0; }
1772
+ var p = Math.pow(10, decimalPlaces);
1773
+ return Math.round(num * p) / p;
1774
+ }
1775
+
1776
+ function clone(obj) {
1777
+ if (obj instanceof Date) {
1778
+ return new Date(obj);
1779
+ }
1780
+ else if (Array.isArray(obj)) {
1781
+ var arr = [];
1782
+ for (var i = 0; i < obj.length; i++) {
1783
+ arr[i] = clone(obj[i]);
1784
+ }
1785
+ return arr;
1786
+ }
1787
+ else if (typeof (obj) === 'object') {
1788
+ var cloned = {};
1789
+ for (var key in obj) {
1790
+ cloned[key] = clone(obj[key]);
1791
+ }
1792
+ return cloned;
1793
+ }
1794
+ return obj;
1795
+ }
1796
+
1770
1797
  function acronym(str, length) {
1771
1798
  if (length === void 0) { length = 2; }
1772
1799
  var splittedString = str
@@ -1891,6 +1918,7 @@
1891
1918
  exports.acronym = acronym;
1892
1919
  exports.boolean = boolean;
1893
1920
  exports.bytes = bytes;
1921
+ exports.clone = clone;
1894
1922
  exports.compare = compare;
1895
1923
  exports.currency = currency;
1896
1924
  exports.debounce = debounce;
@@ -1918,6 +1946,7 @@
1918
1946
  exports.remove = remove;
1919
1947
  exports.removeQueryParams = removeQueryParams;
1920
1948
  exports.resolve = resolve;
1949
+ exports.round = round;
1921
1950
  exports.rsort = rsort;
1922
1951
  exports.sort = sort;
1923
1952
  exports.stringify = stringify;