@minto-ai/tools 1.0.49 → 1.0.50

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/dist/index.js CHANGED
@@ -13562,6 +13562,19 @@ function add2(augend, addend) {
13562
13562
  var sum = scaledAugend + scaledAddend;
13563
13563
  return sum / scalingFactor;
13564
13564
  }
13565
+ function calcAspectRatio(_ref) {
13566
+ var _ref2 = _slicedToArray(_ref, 2), width = _ref2[0], height = _ref2[1];
13567
+ if (width === 0 || height === 0) {
13568
+ return [0, 0];
13569
+ }
13570
+ var w = Math.abs(Math.round(width));
13571
+ var h = Math.abs(Math.round(height));
13572
+ function gcd(a, b) {
13573
+ return b === 0 ? a : gcd(b, a % b);
13574
+ }
13575
+ var divisor = gcd(w, h);
13576
+ return [w / divisor, h / divisor];
13577
+ }
13565
13578
  function divide2(dividend, divisor) {
13566
13579
  if (divisor === 0) {
13567
13580
  throw new Error("除数不能为零");
@@ -13680,6 +13693,7 @@ export {
13680
13693
  add2 as add,
13681
13694
  batchDownloadFile,
13682
13695
  beParsedAsNumber,
13696
+ calcAspectRatio,
13683
13697
  canBeParsedAsNumber,
13684
13698
  checkArrayEmpty,
13685
13699
  checkEmpty,
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 计算宽高最简整数比例
3
+ * @param size 尺寸数组
4
+ * @param size.0 宽度值
5
+ * @param size.1 高度值
6
+ * @returns [w, h] 最简整数比例
7
+ */
8
+ declare function calcAspectRatio([width, height]: [number, number]): [number, number];
9
+ export default calcAspectRatio;
@@ -1,6 +1,7 @@
1
1
  import { default as add } from './add';
2
+ import { default as calcAspectRatio } from './calc-aspect-ratio';
2
3
  import { default as divide } from './divide';
3
4
  import { default as getDecimalPlaces } from './get-decimal-places';
4
5
  import { default as multiply } from './multiply';
5
6
  import { default as subtract } from './subtract';
6
- export { add, divide, getDecimalPlaces, multiply, subtract };
7
+ export { add, calcAspectRatio, divide, getDecimalPlaces, multiply, subtract };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@minto-ai/tools",
3
3
  "type": "module",
4
- "version": "1.0.49",
4
+ "version": "1.0.50",
5
5
  "description": "明途公共工具库",
6
6
  "author": "hcc",
7
7
  "license": "ISC",