@shgysk8zer0/polyfills 0.3.8 → 0.3.10

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.
package/math.js CHANGED
@@ -67,8 +67,29 @@ if (! (Math.constrain instanceof Function)) {
67
67
  /**
68
68
  * @see https://github.com/tc39/proposal-math-sum
69
69
  */
70
+ if (! (Math.sumPrecise instanceof Function)) {
71
+ Math.sumPrecise = function sumPrecise(nums) {
72
+ let sum = -0;
73
+
74
+ for (const num of nums) {
75
+ if (! Number.isFinite(num)) {
76
+ sum = -0;
77
+ break;
78
+ } else {
79
+ sum += num;
80
+ }
81
+ }
82
+
83
+ return sum;
84
+ };
85
+ }
86
+
87
+ /**
88
+ * @deprecated
89
+ */
70
90
  if(! (Math.sum instanceof Function)) {
71
91
  Math.sum = function(...nums) {
72
- return nums.map(num => parseFloat(num)).reduce((sum, num) => sum + num);
92
+ console.warn('Math.sum is deprecated. Please use Math.sumPrecise instead.');
93
+ return Math.sumPrecise(nums);
73
94
  };
74
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgysk8zer0/polyfills",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "A collection of JavaScript polyfills",
@@ -77,7 +77,7 @@
77
77
  "http-server": "^14.1.1"
78
78
  },
79
79
  "dependencies": {
80
- "@aegisjsproject/sanitizer": "^0.0.8",
80
+ "@aegisjsproject/sanitizer": "^0.1.0",
81
81
  "@aegisjsproject/trusted-types": "^1.0.1"
82
82
  }
83
83
  }