util-helpers 4.21.3 → 4.21.5

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.
Files changed (40) hide show
  1. package/README.md +33 -33
  2. package/dist/util-helpers.js +88 -57
  3. package/dist/util-helpers.js.map +1 -1
  4. package/dist/util-helpers.min.js +1 -1
  5. package/dist/util-helpers.min.js.map +1 -1
  6. package/esm/VERSION.js +1 -1
  7. package/esm/compressImage.js +4 -3
  8. package/esm/fileReader.js +4 -3
  9. package/esm/index.js +1 -1
  10. package/esm/isChinese.js +11 -6
  11. package/esm/node_modules/.pnpm/emitter-pro@1.2.1/node_modules/emitter-pro/dist/emitter-pro.esm.js +98 -0
  12. package/esm/safeDate.js +4 -3
  13. package/esm/utils/Cache.js +1 -1
  14. package/esm/utils/native.js +2 -1
  15. package/lib/VERSION.js +1 -1
  16. package/lib/compressImage.js +4 -3
  17. package/lib/fileReader.js +4 -3
  18. package/lib/index.js +1 -1
  19. package/lib/isChinese.js +11 -6
  20. package/lib/node_modules/.pnpm/emitter-pro@1.2.1/node_modules/emitter-pro/dist/emitter-pro.esm.js +100 -0
  21. package/lib/safeDate.js +4 -3
  22. package/lib/utils/Cache.js +1 -1
  23. package/lib/utils/native.js +1 -0
  24. package/package.json +16 -14
  25. package/types/ajax.d.ts +1 -1
  26. package/types/compressImage.d.ts +66 -4
  27. package/types/fileReader.d.ts +31 -2
  28. package/types/filterTree.d.ts +2 -2
  29. package/types/findTreeNode.d.ts +2 -2
  30. package/types/findTreeNodes.d.ts +2 -2
  31. package/types/findTreeSelect.d.ts +2 -2
  32. package/types/formatMobile.d.ts +1 -1
  33. package/types/isChinese.d.ts +1 -1
  34. package/types/listToTree.d.ts +3 -3
  35. package/types/safeDate.d.ts +29 -3
  36. package/types/transformFieldNames.d.ts +3 -3
  37. package/types/treeToList.d.ts +2 -2
  38. package/types/utils/native.d.ts +6 -0
  39. package/esm/node_modules/.pnpm/emitter-pro@1.0.3/node_modules/emitter-pro/dist/emitter-pro.esm.js +0 -72
  40. package/lib/node_modules/.pnpm/emitter-pro@1.0.3/node_modules/emitter-pro/dist/emitter-pro.esm.js +0 -74
package/README.md CHANGED
@@ -44,20 +44,32 @@ formatBankCard('6228480402564890018', { spaceMark: '-' }); // 6228-4804-0256-489
44
44
  > 数学计算,修正了浮点数计算问题,适用于金额计算。参考:[JS 浮点数计算测试](https://2zbuy.csb.app/)
45
45
 
46
46
  - 数学计算
47
- - [plus](https://doly-dev.github.io/util-helpers/module-Math.html#.plus) - 加
48
- - [minus](https://doly-dev.github.io/util-helpers/module-Math.html#.minus) - 减
49
- - [times](https://doly-dev.github.io/util-helpers/module-Math.html#.times) - 乘
50
47
  - [divide](https://doly-dev.github.io/util-helpers/module-Math.html#.divide) - 除
51
- - [round](https://doly-dev.github.io/util-helpers/module-Math.html#.round) - 四舍五入
52
48
  - [gcd](https://doly-dev.github.io/util-helpers/module-Math.html#.gcd) - 最大公约数
53
49
  - [lcm](https://doly-dev.github.io/util-helpers/module-Math.html#.lcm) - 最小公倍数
50
+ - [minus](https://doly-dev.github.io/util-helpers/module-Math.html#.minus) - 减
51
+ - [plus](https://doly-dev.github.io/util-helpers/module-Math.html#.plus) - 加
52
+ - [round](https://doly-dev.github.io/util-helpers/module-Math.html#.round) - 四舍五入
53
+ - [times](https://doly-dev.github.io/util-helpers/module-Math.html#.times) - 乘
54
+ - 其他
55
+ - [ajax](https://doly-dev.github.io/util-helpers/module-Other.html#.ajax) - 请求
56
+ - [calculateCursorPosition](https://doly-dev.github.io/util-helpers/module-Other.html#.calculateCursorPosition) - 计算光标位置
57
+ - [compressImage](https://doly-dev.github.io/util-helpers/module-Other.html#.compressImage) - 压缩图片
58
+ - [download](https://doly-dev.github.io/util-helpers/module-Other.html#.download) - 下载
59
+ - [getFileBlob](https://doly-dev.github.io/util-helpers/module-Other.html#.getFileBlob) - 获取文件 Blob
60
+ - [getImageInfo](https://doly-dev.github.io/util-helpers/module-Other.html#.getImageInfo) - 获取图片信息
61
+ - [loadImage](https://doly-dev.github.io/util-helpers/module-Other.html#.loadImage) - 加载图片
62
+ - [loadImageWithBlob](https://doly-dev.github.io/util-helpers/module-Other.html#.loadImageWithBlob) - 加载图片和 blob 对象
63
+ - [loadScript](https://doly-dev.github.io/util-helpers/module-Other.html#.loadScript) - 加载 js 文件
64
+ - [randomString](https://doly-dev.github.io/util-helpers/module-Other.html#.randomString) - 随机字符串
65
+ - [strlen](https://doly-dev.github.io/util-helpers/module-Other.html#.strlen) - 字符长度
54
66
  - 数据处理
55
67
  - [bytesToSize](https://doly-dev.github.io/util-helpers/module-Processor.html#.bytesToSize) - 字节转换为存储单位
56
68
  - [dataURLToBlob](https://doly-dev.github.io/util-helpers/module-Processor.html#.dataURLToBlob) - 将 DataURL 转为 Blob 对象
57
69
  - [fileReader](https://doly-dev.github.io/util-helpers/module-Processor.html#.fileReader) - 读取 Blob 或 File 对象,转为 Base64/String/ArrayBuffer
58
- - [formatMoney](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMoney) - 格式化金额
59
- - [formatMobile](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMobile) - 格式化手机号码
60
70
  - [formatBankCard](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatBankCard) - 格式化银行卡
71
+ - [formatMobile](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMobile) - 格式化手机号码
72
+ - [formatMoney](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMoney) - 格式化金额
61
73
  - [numberToChinese](https://doly-dev.github.io/util-helpers/module-Processor.html#.numberToChinese) - 数字转中文数字
62
74
  - [padZero](https://doly-dev.github.io/util-helpers/module-Processor.html#.padZero) - 前置补零
63
75
  - [parseIdCard](https://doly-dev.github.io/util-helpers/module-Processor.html#.parseIdCard) - 解析身份证号码
@@ -65,48 +77,36 @@ formatBankCard('6228480402564890018', { spaceMark: '-' }); // 6228-4804-0256-489
65
77
  - [safeDate](https://doly-dev.github.io/util-helpers/module-Processor.html#.safeDate) - 创建一个 Date 实例,同 new Date
66
78
  - [setDataURLPrefix](https://doly-dev.github.io/util-helpers/module-Processor.html#.setDataURLPrefix) - 设置 DataURL 前缀、MIME 类型、base64 标识
67
79
  - 树结构数据操作
80
+ - [filterTree](https://doly-dev.github.io/util-helpers/module-Processor.html#.filterTree) - 过滤树节点
68
81
  - [findTreeNode](https://doly-dev.github.io/util-helpers/module-Other.html#.findTreeNode) - 查找树结构数据节点
69
82
  - [findTreeNodes](https://doly-dev.github.io/util-helpers/module-Other.html#.findTreeNodes) - 查找树结构数据多个节点
70
83
  - [findTreeSelect](https://doly-dev.github.io/util-helpers/module-Other.html#.findTreeSelect) - 查找包含当前节点的所有父级节点
71
- - [filterTree](https://doly-dev.github.io/util-helpers/module-Processor.html#.filterTree) - 过滤树节点
72
84
  - [listToTree](https://doly-dev.github.io/util-helpers/module-Processor.html#.listToTree) - 列表数据转树结构
73
85
  - [transformFieldNames](https://doly-dev.github.io/util-helpers/module-Processor.html#.transformFieldNames) - 转换字段名
74
86
  - [treeToList](https://doly-dev.github.io/util-helpers/module-Processor.html#.treeToList) - 树结构转列表数据
75
87
  - 数据验证
76
- - [isMobile](https://doly-dev.github.io/util-helpers/module-Validator.html#.isMobile) - 手机号码
77
- - [isTelephone](https://doly-dev.github.io/util-helpers/module-Validator.html#.isTelephone) - 固定电话
78
- - [isPostcode](https://doly-dev.github.io/util-helpers/module-Validator.html#.isPostcode) - 邮政编码
88
+ - [isBankCard](https://doly-dev.github.io/util-helpers/module-Validator.html#.isBankCard) - 银行卡
89
+ - [isBusinessLicense](https://doly-dev.github.io/util-helpers/module-Validator.html#.isBusinessLicense) - 营业执照,也叫工商注册号
90
+ - [isChinese](https://doly-dev.github.io/util-helpers/module-Validator.html#.isChinese) - 中文
91
+ - [isEmail](https://doly-dev.github.io/util-helpers/module-Validator.html#.isEmail) - 邮箱
79
92
  - [isHMCard](https://doly-dev.github.io/util-helpers/module-Validator.html#.isHMCard) - 港澳居民来往内地通行证,俗称回乡证或回乡卡
80
- - [isTWCard](https://doly-dev.github.io/util-helpers/module-Validator.html#.isTWCard) - 台湾居民来往大陆通行证,俗称台胞证
93
+ - [isIPv4](https://doly-dev.github.io/util-helpers/module-Validator.html#.isIPv4) - IPv4
94
+ - [isIPv6](https://doly-dev.github.io/util-helpers/module-Validator.html#.isIPv6) - IPv6
81
95
  - [isIdCard](https://doly-dev.github.io/util-helpers/module-Validator.html#.isIdCard) - 身份证号
82
- - [isEmail](https://doly-dev.github.io/util-helpers/module-Validator.html#.isEmail) - 邮箱
96
+ - [isMobile](https://doly-dev.github.io/util-helpers/module-Validator.html#.isMobile) - 手机号码
97
+ - [isPassport](https://doly-dev.github.io/util-helpers/module-Validator.html#.isPassport) - 护照号
98
+ - [isPassword](https://doly-dev.github.io/util-helpers/module-Validator.html#.isPassword) 密码强度
99
+ - [isPostcode](https://doly-dev.github.io/util-helpers/module-Validator.html#.isPostcode) - 邮政编码
83
100
  - [isQQ](https://doly-dev.github.io/util-helpers/module-Validator.html#.isQQ) - QQ 号
84
- - [isWX](https://doly-dev.github.io/util-helpers/module-Validator.html#.isWX) - 微信号
85
- - [isVehicle](https://doly-dev.github.io/util-helpers/module-Validator.html#.isVehicle) - 车牌号
86
- - [isBankCard](https://doly-dev.github.io/util-helpers/module-Validator.html#.isBankCard) - 银行卡
87
101
  - [isSocialCreditCode](https://doly-dev.github.io/util-helpers/module-Validator.html#.isSocialCreditCode) - 统一社会信用代码,也叫三证合一组织代码
88
102
  - [isSwiftCode](https://doly-dev.github.io/util-helpers/module-Validator.html#.isSwiftCode) - Swift Code
89
- - [isPassword](https://doly-dev.github.io/util-helpers/module-Validator.html#.isPassword) 密码强度
90
- - [isPassport](https://doly-dev.github.io/util-helpers/module-Validator.html#.isPassport) - 护照号
91
- - [isChinese](https://doly-dev.github.io/util-helpers/module-Validator.html#.isChinese) - 中文
92
- - [isIPv4](https://doly-dev.github.io/util-helpers/module-Validator.html#.isIPv4) - IPv4
93
- - [isIPv6](https://doly-dev.github.io/util-helpers/module-Validator.html#.isIPv6) - IPv6
103
+ - [isTWCard](https://doly-dev.github.io/util-helpers/module-Validator.html#.isTWCard) - 台湾居民来往大陆通行证,俗称台胞证
104
+ - [isTelephone](https://doly-dev.github.io/util-helpers/module-Validator.html#.isTelephone) - 固定电话
94
105
  - [isUrl](https://doly-dev.github.io/util-helpers/module-Validator.html#.isUrl) - URL
95
106
  - [isValidNumber](https://doly-dev.github.io/util-helpers/module-Validator.html#.isValidNumber) - 有效数字
96
- - [isBusinessLicense](https://doly-dev.github.io/util-helpers/module-Validator.html#.isBusinessLicense) - 营业执照,也叫工商注册号
107
+ - [isVehicle](https://doly-dev.github.io/util-helpers/module-Validator.html#.isVehicle) - 车牌号
108
+ - [isWX](https://doly-dev.github.io/util-helpers/module-Validator.html#.isWX) - 微信号
97
109
  - [validatePassword](https://doly-dev.github.io/util-helpers/module-Validator.html#.validatePassword) - 验证密码
98
- - 其他
99
- - [ajax](https://doly-dev.github.io/util-helpers/module-Other.html#.ajax) - 请求
100
- - [calculateCursorPosition](https://doly-dev.github.io/util-helpers/module-Other.html#.calculateCursorPosition) - 计算光标位置
101
- - [compressImage](https://doly-dev.github.io/util-helpers/module-Other.html#.compressImage) - 压缩图片
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
104
- - [getImageInfo](https://doly-dev.github.io/util-helpers/module-Other.html#.getImageInfo) - 获取图片信息
105
- - [loadImage](https://doly-dev.github.io/util-helpers/module-Other.html#.loadImage) - 加载图片
106
- - [loadImageWithBlob](https://doly-dev.github.io/util-helpers/module-Other.html#.loadImageWithBlob) - 加载图片和 blob 对象
107
- - [loadScript](https://doly-dev.github.io/util-helpers/module-Other.html#.loadScript) - 加载 js 文件
108
- - [randomString](https://doly-dev.github.io/util-helpers/module-Other.html#.randomString) - 随机字符串
109
- - [strlen](https://doly-dev.github.io/util-helpers/module-Other.html#.strlen) - 字符长度
110
110
 
111
111
  ## 精选第三方工具库
112
112
 
@@ -475,19 +475,30 @@
475
475
  return reg$4.test(valueStr);
476
476
  }
477
477
 
478
+ var URLExisted = typeof URL !== 'undefined';
479
+
480
+ var objectKeys = Object.keys;
481
+ var objectValues = Object.values;
482
+ var createObjectURL = URLExisted ? URL.createObjectURL : constant('');
483
+ var revokeObjectURL = URLExisted ? URL.revokeObjectURL : noop;
484
+
478
485
  var chineseDictionary = {
479
486
  chineseBasic: '[\u4e00-\u9fa5]',
480
- chineseExtend: '[\u9ea6-\u9fef]',
481
- chineseExtendA: '[\u3400-\u4DB5]',
482
- chineseExtendB: "[\uD840\uDC00-\uD869\uDED6]",
483
- chineseExtendC: "[\uD869\uDF00-\uD86D\uDF34]",
487
+ chineseExtend: '[\u9ea6-\u9fff]',
488
+ chineseExtend2: '[\uF900-\uFAD9]',
489
+ chineseExtendA: '[\u3400-\u4DBF]',
490
+ chineseExtendB: "[\uD840\uDC00-\uD869\uDEDF]",
491
+ chineseExtendC: "[\uD869\uDF00-\uD86D\uDF38]",
484
492
  chineseExtendD: "[\uD86D\uDF40-\uD86E\uDC1D]",
485
493
  chineseExtendE: "[\uD86E\uDC20-\uD873\uDEA1]",
486
- chineseExtendF: "[\uD873\uDEB0-\uD87A\uDFE0]"
494
+ chineseExtendF: "[\uD873\uDEB0-\uD87A\uDFE0]",
495
+ chineseExtendG: "[\uD880\uDC00-\uD884\uDF4A]",
496
+ chineseExtendH: "[\uD884\uDF50-\uD888\uDFAF]",
497
+ chineseExtendI: "[\uD87A\uDFF0-\uD87B\uDE5D]"
487
498
  };
488
499
  var looseChineseRegExp = chineseDictionary.chineseBasic + '+';
489
500
  var chineseRegExp = '^' + chineseDictionary.chineseBasic + '+$';
490
- var chineseWithExtend = '(?:' + chineseDictionary.chineseBasic + '|' + chineseDictionary.chineseExtend + '|' + chineseDictionary.chineseExtendA + '|' + chineseDictionary.chineseExtendB + '|' + chineseDictionary.chineseExtendC + '|' + chineseDictionary.chineseExtendD + '|' + chineseDictionary.chineseExtendE + '|' + chineseDictionary.chineseExtendF + ')';
501
+ var chineseWithExtend = '(?:' + objectValues(chineseDictionary).join('|') + ')';
491
502
  var looseChineseExtendRegExp = chineseWithExtend + '+';
492
503
  var chineseExtendRegExp = '^' + chineseWithExtend + '+$';
493
504
  var supportRegExpUnicode = RegExp.prototype.hasOwnProperty('unicode');
@@ -1141,7 +1152,7 @@
1141
1152
  dataURL: 'readAsDataURL',
1142
1153
  text: 'readAsText'
1143
1154
  };
1144
- function fileReader(blob, type) {
1155
+ var fileReader = function (blob, type) {
1145
1156
  if (type === void 0) { type = 'dataURL'; }
1146
1157
  var method = FileReaderMethodMap[type];
1147
1158
  if (!method) {
@@ -1153,7 +1164,7 @@
1153
1164
  reader.onload = function () { return resolve(reader.result); };
1154
1165
  reader.onerror = function (error) { return reject(error); };
1155
1166
  });
1156
- }
1167
+ };
1157
1168
 
1158
1169
  function blobToDataURL(blob) {
1159
1170
  return fileReader(blob);
@@ -1183,7 +1194,7 @@
1183
1194
  return toString(value);
1184
1195
  }
1185
1196
 
1186
- function safeDate(value) {
1197
+ var safeDate = function (value) {
1187
1198
  var args = [];
1188
1199
  for (var _i = 1; _i < arguments.length; _i++) {
1189
1200
  args[_i - 1] = arguments[_i];
@@ -1193,7 +1204,7 @@
1193
1204
  return new (Date.bind.apply(Date, __spreadArray([void 0, safeValue], __read(args), false)))();
1194
1205
  }
1195
1206
  return typeof safeValue === 'undefined' ? new Date() : new Date(safeValue);
1196
- }
1207
+ };
1197
1208
 
1198
1209
  function formatMobile(mobileNo, options) {
1199
1210
  if (mobileNo === void 0) { mobileNo = ''; }
@@ -1368,12 +1379,6 @@
1368
1379
  return divide(product, gcd.apply(void 0, __spreadArray([], __read(args), false)));
1369
1380
  }
1370
1381
 
1371
- var URLExisted = typeof URL !== 'undefined';
1372
-
1373
- var objectKeys = Object.keys;
1374
- var createObjectURL = URLExisted ? URL.createObjectURL : constant('');
1375
- var revokeObjectURL = URLExisted ? URL.revokeObjectURL : noop;
1376
-
1377
1382
  function ajax(url, options) {
1378
1383
  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;
1379
1384
  return new Promise(function (resolve, reject) {
@@ -1485,72 +1490,98 @@
1485
1490
 
1486
1491
  var EmitterPro = /** @class */ (function () {
1487
1492
  function EmitterPro() {
1488
- this.handler = {};
1493
+ this.handlers = {};
1489
1494
  }
1490
1495
  EmitterPro.prototype.eventNames = function () {
1491
- return Object.keys(this.handler);
1496
+ var _a;
1497
+ var symbols = ((_a = Object.getOwnPropertySymbols) === null || _a === void 0 ? void 0 : _a.call(Object, this.handlers)) || [];
1498
+ var keys = Object.keys(this.handlers);
1499
+ return keys.concat(symbols);
1500
+ };
1501
+ EmitterPro.prototype.rawListeners = function (eventName) {
1502
+ var handler = this.handlers[eventName];
1503
+ return handler ? handler.map(function (item) { return item.raw; }) : [];
1492
1504
  };
1493
1505
  EmitterPro.prototype.listeners = function (eventName) {
1494
- return this.handler[eventName] || [];
1506
+ var handler = this.handlers[eventName];
1507
+ return handler ? handler.map(function (item) { return item.wrap; }) : [];
1495
1508
  };
1496
1509
  EmitterPro.prototype.hasListener = function (eventName, listener) {
1497
- return this.listeners(eventName).some(function (item) { return item === listener; });
1510
+ return this.rawListeners(eventName).some(function (item) { return item === listener; });
1498
1511
  };
1499
- EmitterPro.prototype.on = function (eventName, listener) {
1500
- if (!this.handler[eventName]) {
1501
- this.handler[eventName] = [listener];
1512
+ EmitterPro.prototype._on = function (eventName, raw, wrap, context, dir) {
1513
+ if (context === void 0) { context = null; }
1514
+ if (dir === void 0) { dir = 1; }
1515
+ var currentListener = { raw: raw, wrap: wrap, context: context };
1516
+ if (!this.handlers[eventName]) {
1517
+ this.handlers[eventName] = [currentListener];
1502
1518
  }
1503
1519
  else {
1504
- // 不允许添加相同的方法
1505
- if (!this.hasListener(eventName, listener)) {
1506
- this.handler[eventName].push(listener);
1507
- }
1520
+ var appendMethod = dir === 1 ? 'push' : 'unshift';
1521
+ this.handlers[eventName][appendMethod](currentListener);
1508
1522
  }
1509
1523
  return this;
1510
1524
  };
1525
+ EmitterPro.prototype.prependListener = function (eventName, listener, context) {
1526
+ return this._on(eventName, listener, listener, context, 0);
1527
+ };
1528
+ EmitterPro.prototype.on = function (eventName, listener, context) {
1529
+ return this._on(eventName, listener, listener, context);
1530
+ };
1531
+ EmitterPro.prototype._wrapOnce = function (eventName, listener, context) {
1532
+ var _this = this;
1533
+ if (context === void 0) { context = null; }
1534
+ var wrap = (function () {
1535
+ var args = [];
1536
+ for (var _i = 0; _i < arguments.length; _i++) {
1537
+ args[_i] = arguments[_i];
1538
+ }
1539
+ listener.apply(context, args);
1540
+ _this.off(eventName, wrap);
1541
+ });
1542
+ return wrap;
1543
+ };
1544
+ EmitterPro.prototype.once = function (eventName, listener, context) {
1545
+ var wrap = this._wrapOnce(eventName, listener, context);
1546
+ return this._on(eventName, listener, wrap, context);
1547
+ };
1548
+ EmitterPro.prototype.prependOnceListener = function (eventName, listener, context) {
1549
+ var wrap = this._wrapOnce(eventName, listener, context);
1550
+ return this._on(eventName, listener, wrap, context, 0);
1551
+ };
1511
1552
  EmitterPro.prototype.off = function (eventName, listener) {
1512
- if (this.handler[eventName]) {
1513
- if (typeof listener === 'function') {
1514
- this.handler[eventName] = this.handler[eventName].filter(function (item) { return item !== listener; });
1553
+ var handler = this.handlers[eventName];
1554
+ if (handler) {
1555
+ if (listener) {
1556
+ var index = handler.findIndex(function (item) { return item.wrap === listener || item.raw === listener; });
1557
+ if (index !== -1) {
1558
+ handler.splice(index, 1);
1559
+ }
1515
1560
  }
1516
1561
  else {
1517
- delete this.handler[eventName];
1562
+ delete this.handlers[eventName];
1518
1563
  }
1519
1564
  }
1520
1565
  return this;
1521
1566
  };
1567
+ EmitterPro.prototype.offAll = function () {
1568
+ this.handlers = {};
1569
+ return this;
1570
+ };
1522
1571
  EmitterPro.prototype.emit = function (eventName) {
1523
1572
  var args = [];
1524
1573
  for (var _i = 1; _i < arguments.length; _i++) {
1525
1574
  args[_i - 1] = arguments[_i];
1526
1575
  }
1527
- var listeners = this.listeners(eventName);
1528
- if (listeners.length > 0) {
1529
- listeners.forEach(function (listener) {
1530
- // eslint-disable-next-line prefer-spread
1531
- listener.apply(void 0, args);
1576
+ var handler = this.handlers[eventName];
1577
+ if (handler && handler.length > 0) {
1578
+ handler.forEach(function (listener) {
1579
+ listener.wrap.apply(listener.context, args);
1532
1580
  });
1533
1581
  return true;
1534
1582
  }
1535
1583
  return false;
1536
1584
  };
1537
- EmitterPro.prototype.once = function (eventName, listener) {
1538
- var _this = this;
1539
- var wrap = function () {
1540
- var args = [];
1541
- for (var _i = 0; _i < arguments.length; _i++) {
1542
- args[_i] = arguments[_i];
1543
- }
1544
- // eslint-disable-next-line prefer-spread
1545
- listener.apply(void 0, args);
1546
- _this.off(eventName, wrap);
1547
- };
1548
- return this.on(eventName, wrap);
1549
- };
1550
- EmitterPro.prototype.offAll = function () {
1551
- this.handler = {};
1552
- return this;
1553
- };
1554
1585
  return EmitterPro;
1555
1586
  }());
1556
1587
 
@@ -1649,7 +1680,7 @@
1649
1680
  }, type, quality);
1650
1681
  });
1651
1682
  }
1652
- function compressImage(img, options) {
1683
+ var compressImage = function (img, options) {
1653
1684
  if (options === void 0) { options = {}; }
1654
1685
  return new Promise(function (resolve, reject) {
1655
1686
  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, ajaxOptions = options.ajaxOptions;
@@ -1706,7 +1737,7 @@
1706
1737
  })
1707
1738
  .catch(reject);
1708
1739
  });
1709
- }
1740
+ };
1710
1741
 
1711
1742
  function saver(blobUrl, fileName) {
1712
1743
  if (fileName === void 0) { fileName = ''; }
@@ -2226,9 +2257,9 @@
2226
2257
  return internalFindTreeSelect(tree, predicate, childrenField);
2227
2258
  }
2228
2259
 
2229
- var VERSION = "4.21.3";
2260
+ var VERSION = "4.21.5";
2230
2261
 
2231
- var version = "4.21.3";
2262
+ var version = "4.21.5";
2232
2263
 
2233
2264
  exports.VERSION = VERSION;
2234
2265
  exports.ajax = ajax;