util-helpers 4.19.3 → 4.20.0

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 CHANGED
@@ -1,10 +1,8 @@
1
1
  # util-helpers
2
2
 
3
- [![npm][npm]][npm-url] [![Build and Deploy Docs](https://github.com/doly-dev/util-helpers/actions/workflows/ci.yml/badge.svg)](https://github.com/doly-dev/util-helpers/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/doly-dev/util-helpers/branch/master/graph/badge.svg?token=nhm6Zrmmyq)](https://codecov.io/gh/doly-dev/util-helpers) ![npm](https://img.shields.io/npm/dt/util-helpers) ![GitHub](https://img.shields.io/github/license/doly-dev/util-helpers.svg)
4
-
5
- [util-helpers](https://doly-dev.github.io/util-helpers/index.html) 是一个基于业务场景的工具方法库。
3
+ 一个基于业务场景的工具方法库。[点击查看在线文档](https://doly-dev.github.io/util-helpers/index.html)
6
4
 
7
- [点击查看在线文档](https://doly-dev.github.io/util-helpers/index.html)
5
+ [![npm][npm]][npm-url] [![Build and Deploy Docs](https://github.com/doly-dev/util-helpers/actions/workflows/ci.yml/badge.svg)](https://github.com/doly-dev/util-helpers/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/doly-dev/util-helpers/branch/master/graph/badge.svg?token=nhm6Zrmmyq)](https://codecov.io/gh/doly-dev/util-helpers) ![npm](https://img.shields.io/npm/dt/util-helpers) ![GitHub](https://img.shields.io/github/license/doly-dev/util-helpers.svg)
8
6
 
9
7
  ## 使用
10
8
 
@@ -49,6 +47,8 @@ formatBankCard('6228480402564890018', { spaceMark: '-' }); // 6228-4804-0256-489
49
47
  - [times](https://doly-dev.github.io/util-helpers/module-Math.html#.times) - 乘
50
48
  - [divide](https://doly-dev.github.io/util-helpers/module-Math.html#.divide) - 除
51
49
  - [round](https://doly-dev.github.io/util-helpers/module-Math.html#.round) - 四舍五入
50
+ - [gcd](https://doly-dev.github.io/util-helpers/module-Math.html#.gcd) - 最大公约数
51
+ - [lcm](https://doly-dev.github.io/util-helpers/module-Math.html#.lcm) - 最小公倍数
52
52
  - 数据处理
53
53
  - [bytesToSize](https://doly-dev.github.io/util-helpers/module-Processor.html#.bytesToSize) - 字节转换为存储单位
54
54
  - [dataURLToBlob](https://doly-dev.github.io/util-helpers/module-Processor.html#.dataURLToBlob) - 将 DataURL 转为 Blob 对象
@@ -96,7 +96,11 @@ formatBankCard('6228480402564890018', { spaceMark: '-' }); // 6228-4804-0256-489
96
96
  - 其他
97
97
  - [ajax](https://doly-dev.github.io/util-helpers/module-Other.html#.ajax) - 请求
98
98
  - [calculateCursorPosition](https://doly-dev.github.io/util-helpers/module-Other.html#.calculateCursorPosition) - 计算光标位置
99
+ - [compressImage](https://doly-dev.github.io/util-helpers/module-Other.html#.compressImage) - 压缩图片
99
100
  - [download](https://doly-dev.github.io/util-helpers/module-Other.html#.download) - 下载
101
+ - [getImageInfo](https://doly-dev.github.io/util-helpers/module-Other.html#.getImageInfo) - 获取图片信息
102
+ - [loadImage](https://doly-dev.github.io/util-helpers/module-Other.html#.loadImage) - 加载图片
103
+ - [loadImageWithBlob](https://doly-dev.github.io/util-helpers/module-Other.html#.loadImageWithBlob) - 加载图片和 blob 对象
100
104
  - [loadScript](https://doly-dev.github.io/util-helpers/module-Other.html#.loadScript) - 加载 js 文件
101
105
  - [randomString](https://doly-dev.github.io/util-helpers/module-Other.html#.randomString) - 随机字符串
102
106
  - [strlen](https://doly-dev.github.io/util-helpers/module-Other.html#.strlen) - 字符长度
@@ -17,6 +17,10 @@
17
17
  var hasOwnProperty = objectProto.hasOwnProperty;
18
18
  var functionToString = Function.prototype.toString;
19
19
  functionToString.call(Object);
20
+ var symbolProto = Symbol ? Symbol.prototype : undefined;
21
+ symbolProto ? symbolProto.valueOf : undefined;
22
+ symbolProto ? symbolProto.toString : undefined;
23
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
20
24
  var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
21
25
  var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
22
26
  var blobExisted = typeof Blob !== 'undefined';
@@ -35,6 +39,17 @@
35
39
  }
36
40
  return '';
37
41
  }
42
+ function wrapTags(tags) {
43
+ return tags.map(function (item) { return '[object ' + item + ']'; });
44
+ }
45
+ var numberTag = '[object Number]';
46
+ var stringTag = '[object String]';
47
+ var symbolTag = '[object Symbol]';
48
+ var argumentsTag = '[object Arguments]';
49
+ wrapTags(['Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'BigInt64Array', 'BigUint64Array']);
50
+ wrapTags(['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy']);
51
+ var blobTag = '[object Blob]';
52
+ var fileTag = '[object Blob]';
38
53
  var objectTag = '[object Object]';
39
54
  var dataViewTag = '[object DataView]';
40
55
  var mapTag = '[object Map]';
@@ -59,11 +74,11 @@
59
74
  }
60
75
 
61
76
  function getRawTag(value) {
62
- var isOwn = hasOwnProperty.call(value, Symbol.toStringTag);
63
- var tag = value[Symbol.toStringTag];
77
+ var isOwn = hasOwnProperty.call(value, symToStringTag);
78
+ var tag = value[symToStringTag];
64
79
  var unmasked = false;
65
80
  try {
66
- value[Symbol.toStringTag] = undefined;
81
+ value[symToStringTag] = undefined;
67
82
  unmasked = true;
68
83
  }
69
84
  catch (e) {
@@ -71,18 +86,16 @@
71
86
  var result = objectToString.call(value);
72
87
  if (unmasked) {
73
88
  if (isOwn) {
74
- value[Symbol.toStringTag] = tag;
89
+ value[symToStringTag] = tag;
75
90
  }
76
91
  else {
77
- delete value[Symbol.toStringTag];
92
+ delete value[symToStringTag];
78
93
  }
79
94
  }
80
95
  return result;
81
96
  }
82
97
  function _getTag(value) {
83
- return Symbol && Symbol.toStringTag && Symbol.toStringTag in Object(value)
84
- ? getRawTag(value)
85
- : objectToString.call(value);
98
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString.call(value);
86
99
  }
87
100
  var getTag = _getTag;
88
101
  if ((dataViewExisted && objectToString.call(new DataView(new ArrayBuffer(1))) !== dataViewTag) ||
@@ -113,20 +126,16 @@
113
126
  }
114
127
  var getTag$1 = getTag;
115
128
 
116
- function isType(value, type) {
117
- var nativeTypeString = getTag$1(value);
118
- if (typeof type === 'string') {
119
- return nativeTypeString === '[object ' + type + ']';
120
- }
121
- return type.some(function (item) { return nativeTypeString === '[object ' + item + ']'; });
129
+ function checkType(value, tag) {
130
+ return getTag$1(value) === tag;
122
131
  }
123
-
124
- function isObjectLike(value) {
125
- return value != null && typeof value === 'object';
132
+ function checkTypes(value, tags) {
133
+ var tag = getTag$1(value);
134
+ return tags.some(function (item) { return tag === item; });
126
135
  }
127
136
 
128
137
  function isSymbol(value) {
129
- return typeof value === 'symbol' || (isObjectLike(value) && isType(value, 'Symbol'));
138
+ return typeof value === 'symbol' || checkType(value, symbolTag);
130
139
  }
131
140
 
132
141
  var reIsBinary = /^0b[01]+$/i;
@@ -163,14 +172,9 @@
163
172
  return remainder ? result - remainder : result;
164
173
  }
165
174
 
166
- var argType = 'Arguments';
167
- isType((function () { return arguments; })(), argType);
175
+ checkType((function () { return arguments; })(), argumentsTag);
168
176
  var numberIsFinite = Number.isFinite;
169
177
 
170
- function isFinite$1(value) {
171
- return numberIsFinite ? numberIsFinite(value) : typeof value === 'number' && root.isFinite(value);
172
- }
173
-
174
178
  function baseToString(value) {
175
179
  if (typeof value === 'string') {
176
180
  return value;
@@ -188,30 +192,16 @@
188
192
  return value == null ? '' : baseToString(value);
189
193
  }
190
194
 
191
- function decimalAdjust(type, value, precision) {
192
- if (precision === void 0) { precision = 0; }
193
- var func = Math[type];
194
- value = toNumber(value);
195
- precision = Math.min(toInteger(precision), 292);
196
- if (precision === 0 || !isFinite$1(value)) {
197
- return func(value);
198
- }
199
- var pair = toString(value).split('e');
200
- value = func(+(pair[0] + 'e' + (pair[1] ? +pair[1] + precision : precision)));
201
- pair = toString(value).split('e');
202
- return +(pair[0] + 'e' + (pair[1] ? +pair[1] - precision : -precision));
203
- }
204
-
205
- function round(number, precision) {
206
- return decimalAdjust('round', number, precision);
195
+ function isBlob(value) {
196
+ return (blobExisted && value instanceof Blob) || checkTypes(value, [blobTag, fileTag]);
207
197
  }
208
198
 
209
- function isBlob(value) {
210
- return (blobExisted && value instanceof Blob) || isType(value, ['Blob', 'File']);
199
+ function isFinite$1(value) {
200
+ return numberIsFinite ? numberIsFinite(value) : typeof value === 'number' && root.isFinite(value);
211
201
  }
212
202
 
213
203
  function isNumber(value) {
214
- return typeof value === 'number' || (isObjectLike(value) && isType(value, 'Number'));
204
+ return typeof value === 'number' || checkType(value, numberTag);
215
205
  }
216
206
 
217
207
  function isNaN$1(value) {
@@ -223,7 +213,25 @@
223
213
  }
224
214
 
225
215
  function isString(value) {
226
- return typeof value === 'string' || (isObjectLike(value) && isType(value, 'String'));
216
+ return typeof value === 'string' || checkType(value, stringTag);
217
+ }
218
+
219
+ function decimalAdjust(type, value, precision) {
220
+ if (precision === void 0) { precision = 0; }
221
+ var func = Math[type];
222
+ value = toNumber(value);
223
+ precision = Math.min(toInteger(precision), 292);
224
+ if (precision === 0 || !isFinite$1(value)) {
225
+ return func(value);
226
+ }
227
+ var pair = toString(value).split('e');
228
+ value = func(+(pair[0] + 'e' + (pair[1] ? +pair[1] + precision : precision)));
229
+ pair = toString(value).split('e');
230
+ return +(pair[0] + 'e' + (pair[1] ? +pair[1] - precision : -precision));
231
+ }
232
+
233
+ function round(number, precision) {
234
+ return decimalAdjust('round', number, precision);
227
235
  }
228
236
 
229
237
  function sleep(ms) {
@@ -893,6 +901,7 @@
893
901
  return decimal + ret;
894
902
  }
895
903
  var formatMoney = function (num, options) {
904
+ if (num === void 0) { num = ''; }
896
905
  if (options === void 0) { options = {}; }
897
906
  var _a = options.precision, precision = _a === void 0 ? 2 : _a, symbol = options.symbol, _b = options.thousand, thousand = _b === void 0 ? ',' : _b, _c = options.decimal, decimal = _c === void 0 ? '.' : _c;
898
907
  if (!checkNumber(num)) {
@@ -928,6 +937,7 @@
928
937
  }
929
938
 
930
939
  function replaceChar(str, options) {
940
+ if (str === void 0) { str = ''; }
931
941
  if (options === void 0) { options = {}; }
932
942
  var _a = options.char, char = _a === void 0 ? '*' : _a, exclude = options.exclude;
933
943
  var _b = options.start, start = _b === void 0 ? 3 : _b, _c = options.end, end = _c === void 0 ? -4 : _c, repeat = options.repeat;
@@ -1323,6 +1333,58 @@
1323
1333
  return round(num, precision);
1324
1334
  }
1325
1335
 
1336
+ function gcd() {
1337
+ var nums = [];
1338
+ for (var _i = 0; _i < arguments.length; _i++) {
1339
+ nums[_i] = arguments[_i];
1340
+ }
1341
+ var num1 = nums[0];
1342
+ var num2 = nums[1] === void 0 ? 0 : nums[1];
1343
+ var rest = nums.slice(2);
1344
+ if (rest.length > 0) {
1345
+ return gcd.apply(void 0, [gcd(num1, num2)].concat(rest));
1346
+ }
1347
+ num1 = Math.abs(round(num1));
1348
+ num2 = Math.abs(round(num2));
1349
+ if (isNaN$1(num1) || isNaN$1(num2)) {
1350
+ return Number.NaN;
1351
+ }
1352
+ if (num1 === 0 && num2 === 0) {
1353
+ return 0;
1354
+ }
1355
+ if (num1 === 0) {
1356
+ return num2;
1357
+ }
1358
+ if (num2 === 0) {
1359
+ return num1;
1360
+ }
1361
+ var temp = num2;
1362
+ if (num1 < num2) {
1363
+ temp = num1;
1364
+ num1 = num2;
1365
+ num2 = temp;
1366
+ }
1367
+ while (temp) {
1368
+ temp = num1 % num2;
1369
+ num1 = num2;
1370
+ num2 = temp;
1371
+ }
1372
+ return toNumber(num1);
1373
+ }
1374
+
1375
+ function lcm() {
1376
+ var nums = [];
1377
+ for (var _i = 0; _i < arguments.length; _i++) {
1378
+ nums[_i] = arguments[_i];
1379
+ }
1380
+ var args = nums.map(function (item) { return Math.abs(round(item)); });
1381
+ if (args.length === 1) {
1382
+ args = args.concat([1]);
1383
+ }
1384
+ var product = args.indexOf(0) > -1 ? 0 : times.apply(void 0, __spreadArray([], __read(args), false));
1385
+ return divide(product, gcd.apply(void 0, __spreadArray([], __read(args), false)));
1386
+ }
1387
+
1326
1388
  function ajax(url, options) {
1327
1389
  var _a = options || {}, _b = _a.method, method = _b === void 0 ? 'get' : _b, _c = _a.data, data = _c === void 0 ? null : _c, timeout = _a.timeout, headers = _a.headers, _d = _a.withCredentials, withCredentials = _d === void 0 ? false : _d, _e = _a.async, async = _e === void 0 ? true : _e, _f = _a.user, user = _f === void 0 ? null : _f, _g = _a.password, password = _g === void 0 ? null : _g, responseType = _a.responseType, onReadyStateChange = _a.onReadyStateChange, onLoadStart = _a.onLoadStart, onProgress = _a.onProgress, onAbort = _a.onAbort, onTimeout = _a.onTimeout, onError = _a.onError, onLoad = _a.onLoad, onLoadEnd = _a.onLoadEnd;
1328
1390
  return new Promise(function (resolve, reject) {
@@ -1405,6 +1467,117 @@
1405
1467
  return pos;
1406
1468
  }
1407
1469
 
1470
+ var SuccessResponseStatus = [200, 304];
1471
+ function getBlob(img) {
1472
+ return new Promise(function (resolve, reject) {
1473
+ if (isBlob(img)) {
1474
+ resolve(img);
1475
+ }
1476
+ else {
1477
+ ajax(img, { responseType: 'blob' })
1478
+ .then(function (ev) {
1479
+ var responseStatus = ev.target.status;
1480
+ if (SuccessResponseStatus.indexOf(responseStatus) !== -1) {
1481
+ resolve(ev.target.response);
1482
+ }
1483
+ else {
1484
+ reject(new Error("[loadImageWithBlob] The image does not support get requests, responseStatus ".concat(responseStatus, ", '").concat(img, "'.")));
1485
+ }
1486
+ })
1487
+ .catch(reject);
1488
+ }
1489
+ });
1490
+ }
1491
+ var cacheImage$2;
1492
+ var cacheResult$2;
1493
+ function loadImageWithBlob(img, useCache) {
1494
+ if (useCache === void 0) { useCache = true; }
1495
+ return new Promise(function (resolve, reject) {
1496
+ if (useCache && cacheImage$2 === img && cacheResult$2) {
1497
+ resolve(cacheResult$2);
1498
+ }
1499
+ else {
1500
+ getBlob(img)
1501
+ .then(function (blob) {
1502
+ var url = URL.createObjectURL(blob);
1503
+ var image = new Image();
1504
+ image.onload = function () {
1505
+ URL.revokeObjectURL(url);
1506
+ var result = { blob: blob, image: image };
1507
+ if (useCache) {
1508
+ cacheImage$2 = img;
1509
+ cacheResult$2 = result;
1510
+ }
1511
+ resolve(result);
1512
+ };
1513
+ image.onerror = function (err) {
1514
+ URL.revokeObjectURL(url);
1515
+ console.error("[loadImageWithBlob] The image load failed, '".concat(img, "'."));
1516
+ reject(err);
1517
+ };
1518
+ image.src = url;
1519
+ })
1520
+ .catch(reject);
1521
+ }
1522
+ });
1523
+ }
1524
+
1525
+ function canvasToBlob(canvas, type, quality) {
1526
+ return new Promise(function (resolve) {
1527
+ canvas.toBlob(function (blob) {
1528
+ resolve(blob);
1529
+ }, type, quality);
1530
+ });
1531
+ }
1532
+ function compressImage(img, options) {
1533
+ if (options === void 0) { options = {}; }
1534
+ return new Promise(function (resolve, reject) {
1535
+ var width = options.width, height = options.height, rotate = options.rotate, _a = options.offset, offset = _a === void 0 ? [0, 0] : _a, _b = options.cacheImage, cacheImage = _b === void 0 ? true : _b, _c = options.background, background = _c === void 0 ? '#fff' : _c, canvasWidth = options.canvasWidth, canvasHeight = options.canvasHeight, _d = options.format, format = _d === void 0 ? 'blob' : _d, _e = options.type, type = _e === void 0 ? 'image/jpeg' : _e, _f = options.quality, quality = _f === void 0 ? 0.8 : _f, beforeCompress = options.beforeCompress, beforeDraw = options.beforeDraw, afterDraw = options.afterDraw;
1536
+ loadImageWithBlob(img, cacheImage)
1537
+ .then(function (_a) {
1538
+ var image = _a.image, blob = _a.blob;
1539
+ var numWidth = toNumber(width);
1540
+ var numHeight = toNumber(height);
1541
+ var numQuality = toNumber(quality);
1542
+ if (numWidth) {
1543
+ image.width = numWidth;
1544
+ }
1545
+ if (numHeight) {
1546
+ image.height = numHeight;
1547
+ }
1548
+ beforeCompress === null || beforeCompress === void 0 ? void 0 : beforeCompress({ image: image, blob: blob }, options);
1549
+ var canvas = document.createElement('canvas');
1550
+ var ctx = canvas.getContext('2d');
1551
+ var info = { image: image, blob: blob, canvas: canvas, context: ctx };
1552
+ var numCanvasWidth = toNumber(typeof canvasWidth === 'function' ? canvasWidth(info, options) : canvasWidth);
1553
+ var numCanvasHeight = toNumber(typeof canvasHeight === 'function' ? canvasHeight(info, options) : canvasHeight);
1554
+ canvas.width = numCanvasWidth || image.width;
1555
+ canvas.height = numCanvasHeight || image.height;
1556
+ if (background && background !== 'none') {
1557
+ ctx.fillStyle = background;
1558
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
1559
+ }
1560
+ var internalOffset = [0, 0];
1561
+ if (rotate !== undefined) {
1562
+ ctx.translate(image.width / 2, image.height / 2);
1563
+ internalOffset = [-image.width / 2, -image.height / 2];
1564
+ ctx.rotate((rotate * Math.PI) / 180);
1565
+ }
1566
+ var outOffset = typeof offset === 'function' ? offset(info, options) : offset;
1567
+ beforeDraw === null || beforeDraw === void 0 ? void 0 : beforeDraw(info, options);
1568
+ ctx.drawImage(image, internalOffset[0] + toNumber(outOffset[0]), internalOffset[1] + toNumber(outOffset[1]), image.width, image.height);
1569
+ afterDraw === null || afterDraw === void 0 ? void 0 : afterDraw(info, options);
1570
+ if (format === 'blob') {
1571
+ canvasToBlob(canvas, type, numQuality).then(resolve).catch(reject);
1572
+ }
1573
+ else {
1574
+ resolve(canvas.toDataURL(type, numQuality));
1575
+ }
1576
+ })
1577
+ .catch(reject);
1578
+ });
1579
+ }
1580
+
1408
1581
  function saver(blobUrl, fileName) {
1409
1582
  if (fileName === void 0) { fileName = ''; }
1410
1583
  var anchor = document.createElement('a');
@@ -1487,6 +1660,81 @@
1487
1660
  });
1488
1661
  }
1489
1662
 
1663
+ function calcContrast(w, h) {
1664
+ var n = gcd(w, h);
1665
+ return "".concat(divide(round(w), n), ":").concat(divide(round(h), n));
1666
+ }
1667
+ var cacheImage$1;
1668
+ var cacheResult$1;
1669
+ function getImageInfo(img, useCache) {
1670
+ if (useCache === void 0) { useCache = true; }
1671
+ return new Promise(function (resolve, reject) {
1672
+ if (useCache && cacheImage$1 === img && cacheResult$1) {
1673
+ resolve(cacheResult$1);
1674
+ }
1675
+ else {
1676
+ loadImageWithBlob(img, false)
1677
+ .then(function (_a) {
1678
+ var image = _a.image, blob = _a.blob;
1679
+ var width = image.width, height = image.height;
1680
+ var result = {
1681
+ width: width,
1682
+ height: height,
1683
+ contrast: calcContrast(width, height),
1684
+ measure: "".concat(width, " \u00D7 ").concat(height, " px"),
1685
+ size: bytesToSize(blob.size),
1686
+ bytes: blob.size,
1687
+ image: image,
1688
+ blob: blob
1689
+ };
1690
+ if (useCache) {
1691
+ cacheImage$1 = img;
1692
+ cacheResult$1 = result;
1693
+ }
1694
+ resolve(result);
1695
+ })
1696
+ .catch(reject);
1697
+ }
1698
+ });
1699
+ }
1700
+
1701
+ var cacheImage;
1702
+ var cacheResult;
1703
+ function loadImage(img, useCache) {
1704
+ if (useCache === void 0) { useCache = true; }
1705
+ return new Promise(function (resolve, reject) {
1706
+ if (useCache && cacheImage === img && cacheResult) {
1707
+ resolve(cacheResult);
1708
+ }
1709
+ else {
1710
+ var imgIsBlob_1 = isBlob(img);
1711
+ var url_1 = imgIsBlob_1 ? URL.createObjectURL(img) : img;
1712
+ var image_1 = new Image();
1713
+ if (!imgIsBlob_1) {
1714
+ image_1.crossOrigin = 'anonymous';
1715
+ }
1716
+ image_1.onload = function () {
1717
+ if (imgIsBlob_1) {
1718
+ URL.revokeObjectURL(url_1);
1719
+ }
1720
+ if (useCache) {
1721
+ cacheImage = img;
1722
+ cacheResult = image_1;
1723
+ }
1724
+ resolve(image_1);
1725
+ };
1726
+ image_1.onerror = function (err) {
1727
+ if (imgIsBlob_1) {
1728
+ URL.revokeObjectURL(url_1);
1729
+ }
1730
+ console.error("[loadImage] The image load failed, '".concat(img, "'."));
1731
+ reject(err);
1732
+ };
1733
+ image_1.src = url_1;
1734
+ }
1735
+ });
1736
+ }
1737
+
1490
1738
  function loadScript(src, options) {
1491
1739
  return new Promise(function (resolve, reject) {
1492
1740
  var head = document.head;
@@ -1820,15 +2068,16 @@
1820
2068
  return internalFindTreeSelect(tree, predicate, childrenField);
1821
2069
  }
1822
2070
 
1823
- var VERSION = "4.19.3";
2071
+ var VERSION = "4.20.0";
1824
2072
 
1825
- var version = "4.19.3";
2073
+ var version = "4.20.0";
1826
2074
 
1827
2075
  exports.VERSION = VERSION;
1828
2076
  exports.ajax = ajax;
1829
2077
  exports.blobToDataURL = blobToDataURL;
1830
2078
  exports.bytesToSize = bytesToSize;
1831
2079
  exports.calculateCursorPosition = calculateCursorPosition;
2080
+ exports.compressImage = compressImage;
1832
2081
  exports.dataURLToBlob = dataURLToBlob;
1833
2082
  exports.divide = divide;
1834
2083
  exports.download = download;
@@ -1840,6 +2089,8 @@
1840
2089
  exports.formatBankCard = formatBankCard;
1841
2090
  exports.formatMobile = formatMobile;
1842
2091
  exports.formatMoney = formatMoney;
2092
+ exports.gcd = gcd;
2093
+ exports.getImageInfo = getImageInfo;
1843
2094
  exports.isBankCard = isBankCard;
1844
2095
  exports.isBusinessLicense = isBusinessLicense;
1845
2096
  exports.isChinese = isChinese;
@@ -1862,7 +2113,10 @@
1862
2113
  exports.isValidNumber = isValidNumber;
1863
2114
  exports.isVehicle = isVehicle;
1864
2115
  exports.isWX = isWX;
2116
+ exports.lcm = lcm;
1865
2117
  exports.listToTree = listToTree;
2118
+ exports.loadImage = loadImage;
2119
+ exports.loadImageWithBlob = loadImageWithBlob;
1866
2120
  exports.loadScript = loadScript;
1867
2121
  exports.minus = minus;
1868
2122
  exports.normalizeString = normalizeString;