si-funciona 2.3.0 → 2.3.1
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/README.md +1 -1
- package/browser/siFunciona.js +4 -2
- package/browser/siFunciona.min.js +1 -1
- package/dist/helpers/numbers/greatestCommonDivisor.d.ts +1 -1
- package/dist/helpers/numbers/greatestCommonDivisor.js +1 -1
- package/dist/helpers/numbers/simplestRatio.js +3 -1
- package/dist/helpers/numbers/simplestRatio.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'core-js/stable';
|
|
2
2
|
/**
|
|
3
|
-
* Return the highest number
|
|
3
|
+
* Return the highest number that can be divided into both numbers.
|
|
4
4
|
* @memberOf module:numberHelpers
|
|
5
5
|
* @param {number} num1 - First number to assess
|
|
6
6
|
* @param {number} num2 - Second number to compare for common divisor
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
6
6
|
exports.default = void 0
|
|
7
7
|
require('core-js/stable')
|
|
8
8
|
/**
|
|
9
|
-
* Return the highest number
|
|
9
|
+
* Return the highest number that can be divided into both numbers.
|
|
10
10
|
* @memberOf module:numberHelpers
|
|
11
11
|
* @param {number} num1 - First number to assess
|
|
12
12
|
* @param {number} num2 - Second number to compare for common divisor
|
|
@@ -20,7 +20,9 @@ const simplestRatio = function () {
|
|
|
20
20
|
if (numbers.length === 0) {
|
|
21
21
|
return []
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
let commonDivisor = numbers.reduce((num1, num2) => (0, _greatestCommonDivisor.default)(num1, num2), 0)
|
|
24
|
+
// Set to positive so that when we divide the numbers they retain their +/-
|
|
25
|
+
commonDivisor = Math.abs(commonDivisor)
|
|
24
26
|
return numbers.map(num => num / commonDivisor)
|
|
25
27
|
}
|
|
26
28
|
var _default = exports.default = simplestRatio
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0,require("core-js/stable");var _greatestCommonDivisor=_interopRequireDefault(require("./greatestCommonDivisor"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const simplestRatio=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(0===t.length)return[];
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0,require("core-js/stable");var _greatestCommonDivisor=_interopRequireDefault(require("./greatestCommonDivisor"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const simplestRatio=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(0===t.length)return[];let o=t.reduce(((e,t)=>(0,_greatestCommonDivisor.default)(e,t)),0);return o=Math.abs(o),t.map((e=>e/o))};var _default=exports.default=simplestRatio;
|