@minto-ai/tools 1.0.49 → 1.0.51

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.
@@ -23,6 +23,7 @@ declare const FileSuffixEnum: {
23
23
  readonly TXT: "txt";
24
24
  readonly ZIP: "zip";
25
25
  readonly RAR: "rar";
26
+ readonly HTML: "html";
26
27
  };
27
28
  /**
28
29
  * 图片后缀类型枚举
package/dist/index.js CHANGED
@@ -13205,7 +13205,8 @@ var FileSuffixEnum = {
13205
13205
  WAV: "wav",
13206
13206
  TXT: "txt",
13207
13207
  ZIP: "zip",
13208
- RAR: "rar"
13208
+ RAR: "rar",
13209
+ HTML: "html"
13209
13210
  };
13210
13211
  var ImageFileSuffixEnum = {
13211
13212
  JPG: FileSuffixEnum.JPG,
@@ -13562,6 +13563,19 @@ function add2(augend, addend) {
13562
13563
  var sum = scaledAugend + scaledAddend;
13563
13564
  return sum / scalingFactor;
13564
13565
  }
13566
+ function calcAspectRatio(_ref) {
13567
+ var _ref2 = _slicedToArray(_ref, 2), width = _ref2[0], height = _ref2[1];
13568
+ if (width === 0 || height === 0) {
13569
+ return [0, 0];
13570
+ }
13571
+ var w = Math.abs(Math.round(width));
13572
+ var h = Math.abs(Math.round(height));
13573
+ function gcd(a, b) {
13574
+ return b === 0 ? a : gcd(b, a % b);
13575
+ }
13576
+ var divisor = gcd(w, h);
13577
+ return [w / divisor, h / divisor];
13578
+ }
13565
13579
  function divide2(dividend, divisor) {
13566
13580
  if (divisor === 0) {
13567
13581
  throw new Error("除数不能为零");
@@ -13680,6 +13694,7 @@ export {
13680
13694
  add2 as add,
13681
13695
  batchDownloadFile,
13682
13696
  beParsedAsNumber,
13697
+ calcAspectRatio,
13683
13698
  canBeParsedAsNumber,
13684
13699
  checkArrayEmpty,
13685
13700
  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.51",
5
5
  "description": "明途公共工具库",
6
6
  "author": "hcc",
7
7
  "license": "ISC",
@@ -18,8 +18,7 @@
18
18
  "dist"
19
19
  ],
20
20
  "scripts": {
21
- "build": "vite build",
22
- "up": "gulp --gulpfile ../../gulpfile.cjs --cwd ./"
21
+ "build": "vite build"
23
22
  },
24
23
  "dependencies": {
25
24
  "axios": "^1.7.9",