util-helpers 4.20.8 → 4.21.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 +1 -0
- package/dist/util-helpers.js +11 -9
- package/dist/util-helpers.js.map +1 -1
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/VERSION.js +1 -1
- package/esm/getFileBlob.js +32 -0
- package/esm/index.js +2 -1
- package/esm/loadImageWithBlob.js +2 -30
- package/lib/VERSION.js +1 -1
- package/lib/getFileBlob.js +34 -0
- package/lib/index.js +3 -1
- package/lib/loadImageWithBlob.js +2 -30
- package/package.json +1 -1
- package/types/getFileBlob.d.ts +22 -0
- package/types/index.d.ts +1 -0
- package/types/loadImageWithBlob.d.ts +2 -2
package/README.md
CHANGED
|
@@ -100,6 +100,7 @@ formatBankCard('6228480402564890018', { spaceMark: '-' }); // 6228-4804-0256-489
|
|
|
100
100
|
- [calculateCursorPosition](https://doly-dev.github.io/util-helpers/module-Other.html#.calculateCursorPosition) - 计算光标位置
|
|
101
101
|
- [compressImage](https://doly-dev.github.io/util-helpers/module-Other.html#.compressImage) - 压缩图片
|
|
102
102
|
- [download](https://doly-dev.github.io/util-helpers/module-Other.html#.download) - 下载
|
|
103
|
+
- [getFileBlob](https://doly-dev.github.io/util-helpers/module-Other.html#.getFileBlob) - 获取文件 Blob
|
|
103
104
|
- [getImageInfo](https://doly-dev.github.io/util-helpers/module-Other.html#.getImageInfo) - 获取图片信息
|
|
104
105
|
- [loadImage](https://doly-dev.github.io/util-helpers/module-Other.html#.loadImage) - 加载图片
|
|
105
106
|
- [loadImageWithBlob](https://doly-dev.github.io/util-helpers/module-Other.html#.loadImageWithBlob) - 加载图片和 blob 对象
|
package/dist/util-helpers.js
CHANGED
|
@@ -1385,31 +1385,32 @@
|
|
|
1385
1385
|
}
|
|
1386
1386
|
|
|
1387
1387
|
var SuccessResponseStatus = [200, 304];
|
|
1388
|
-
function
|
|
1388
|
+
function getFileBlob(file, ajaxOptions) {
|
|
1389
1389
|
return new Promise(function (resolve, reject) {
|
|
1390
|
-
if (isBlob(
|
|
1391
|
-
resolve(
|
|
1390
|
+
if (isBlob(file)) {
|
|
1391
|
+
resolve(file);
|
|
1392
1392
|
}
|
|
1393
1393
|
else {
|
|
1394
|
-
ajax(
|
|
1394
|
+
ajax(file, __assign({ responseType: 'blob' }, ajaxOptions))
|
|
1395
1395
|
.then(function (ev) {
|
|
1396
1396
|
var responseStatus = ev.target.status;
|
|
1397
1397
|
if (SuccessResponseStatus.indexOf(responseStatus) !== -1) {
|
|
1398
1398
|
resolve(ev.target.response);
|
|
1399
1399
|
}
|
|
1400
1400
|
else {
|
|
1401
|
-
var err = new Error("
|
|
1401
|
+
var err = new Error("The file does not support get requests, responseStatus ".concat(responseStatus, ", '").concat(file, "'."));
|
|
1402
1402
|
console.error(err);
|
|
1403
1403
|
reject(err);
|
|
1404
1404
|
}
|
|
1405
1405
|
})
|
|
1406
1406
|
.catch(function (err) {
|
|
1407
|
-
console.error(new Error("
|
|
1407
|
+
console.error(new Error("Failed to request file. ".concat(err)));
|
|
1408
1408
|
reject(err);
|
|
1409
1409
|
});
|
|
1410
1410
|
}
|
|
1411
1411
|
});
|
|
1412
1412
|
}
|
|
1413
|
+
|
|
1413
1414
|
var cacheImage$2;
|
|
1414
1415
|
var cacheResult$2;
|
|
1415
1416
|
function loadImageWithBlob(img, useCache, ajaxOptions) {
|
|
@@ -1419,7 +1420,7 @@
|
|
|
1419
1420
|
resolve(cacheResult$2);
|
|
1420
1421
|
}
|
|
1421
1422
|
else {
|
|
1422
|
-
|
|
1423
|
+
getFileBlob(img, ajaxOptions)
|
|
1423
1424
|
.then(function (blob) {
|
|
1424
1425
|
var url = createObjectURL(blob);
|
|
1425
1426
|
var image = new Image();
|
|
@@ -1990,9 +1991,9 @@
|
|
|
1990
1991
|
return internalFindTreeSelect(tree, predicate, childrenField);
|
|
1991
1992
|
}
|
|
1992
1993
|
|
|
1993
|
-
var VERSION = "4.
|
|
1994
|
+
var VERSION = "4.21.0";
|
|
1994
1995
|
|
|
1995
|
-
var version = "4.
|
|
1996
|
+
var version = "4.21.0";
|
|
1996
1997
|
|
|
1997
1998
|
exports.VERSION = VERSION;
|
|
1998
1999
|
exports.ajax = ajax;
|
|
@@ -2012,6 +2013,7 @@
|
|
|
2012
2013
|
exports.formatMobile = formatMobile;
|
|
2013
2014
|
exports.formatMoney = formatMoney;
|
|
2014
2015
|
exports.gcd = gcd;
|
|
2016
|
+
exports.getFileBlob = getFileBlob;
|
|
2015
2017
|
exports.getImageInfo = getImageInfo;
|
|
2016
2018
|
exports.isBankCard = isBankCard;
|
|
2017
2019
|
exports.isBusinessLicense = isBusinessLicense;
|