From 8a0938119ef87611928d0e8225277812ee1d7d54 Mon Sep 17 00:00:00 2001 From: caijf Date: Fri, 14 Jun 2024 09:50:38 +0000 Subject: [PATCH] deploy: 1d46413f59c0217d374cbcceeeb6bfd25d9eaf9d --- AsyncMemo.html | 2 +- AsyncMemo.js.html | 2 +- VERSION.js.html | 2 +- ajax.js.html | 2 +- bytesToSize.js.html | 2 +- calculateCursorPosition.js.html | 2 +- compressImage.js.html | 2 +- dataURLToBlob.js.html | 2 +- divide.js.html | 2 +- download.js.html | 2 +- fileReader.js.html | 2 +- filterTree.js.html | 2 +- findTreeNode.js.html | 2 +- findTreeNodes.js.html | 2 +- findTreeSelect.js.html | 2 +- formatBankCard.js.html | 2 +- formatMobile.js.html | 2 +- formatMoney.js.html | 2 +- gcd.js.html | 2 +- getFileBlob.js.html | 2 +- getImageInfo.js.html | 76 +++++++++++++++------------------ global.html | 40 ++++++++++++++++- index.html | 2 +- index.js.html | 2 +- isBankCard.js.html | 2 +- isBusinessLicense.js.html | 2 +- isChinese.js.html | 2 +- isEmail.js.html | 2 +- isHMCard.js.html | 2 +- isIPv4.js.html | 2 +- isIPv6.js.html | 2 +- isIdCard.js.html | 2 +- isMobile.js.html | 2 +- isPassport.js.html | 2 +- isPassword.js.html | 2 +- isPostcode.js.html | 2 +- isQQ.js.html | 2 +- isSocialCreditCode.js.html | 2 +- isSwiftCode.js.html | 2 +- isTWCard.js.html | 2 +- isTelephone.js.html | 2 +- isUrl.js.html | 2 +- isValidNumber.js.html | 2 +- isVehicle.js.html | 2 +- isWX.js.html | 2 +- lcm.js.html | 2 +- listToTree.js.html | 2 +- loadImage.js.html | 51 +++++++++++----------- loadImageWithBlob.js.html | 51 +++++++++++----------- loadScript.js.html | 2 +- minus.js.html | 2 +- module-Math.html | 2 +- module-Other.html | 6 +-- module-Processor.html | 2 +- module-Tree.html | 2 +- module-Validator.html | 2 +- numberToChinese.js.html | 2 +- padZero.js.html | 2 +- parseIdCard.js.html | 2 +- plus.js.html | 2 +- randomString.js.html | 2 +- replaceChar.js.html | 2 +- round.js.html | 2 +- safeDate.js.html | 2 +- setDataURLPrefix.js.html | 2 +- strlen.js.html | 2 +- times.js.html | 2 +- transformFieldNames.js.html | 2 +- transformObjectValue.js.html | 2 +- treeToList.js.html | 2 +- validatePassword.js.html | 2 +- 71 files changed, 192 insertions(+), 164 deletions(-) diff --git a/AsyncMemo.html b/AsyncMemo.html index dd74ad71..8687e1fd 100644 --- a/AsyncMemo.html +++ b/AsyncMemo.html @@ -812,7 +812,7 @@
Returns:

diff --git a/AsyncMemo.js.html b/AsyncMemo.js.html index 3cef8530..16becb4a 100644 --- a/AsyncMemo.js.html +++ b/AsyncMemo.js.html @@ -160,7 +160,7 @@

AsyncMemo.js


diff --git a/VERSION.js.html b/VERSION.js.html index ba2cdf6a..58d68d05 100644 --- a/VERSION.js.html +++ b/VERSION.js.html @@ -93,7 +93,7 @@

VERSION.js


diff --git a/ajax.js.html b/ajax.js.html index fe842352..5b815c3d 100644 --- a/ajax.js.html +++ b/ajax.js.html @@ -189,7 +189,7 @@

ajax.js


diff --git a/bytesToSize.js.html b/bytesToSize.js.html index 4e3ad76a..ce4b912c 100644 --- a/bytesToSize.js.html +++ b/bytesToSize.js.html @@ -121,7 +121,7 @@

bytesToSize.js


diff --git a/calculateCursorPosition.js.html b/calculateCursorPosition.js.html index df1e9d30..e44e08ed 100644 --- a/calculateCursorPosition.js.html +++ b/calculateCursorPosition.js.html @@ -133,7 +133,7 @@

calculateCursorPosition.js


diff --git a/compressImage.js.html b/compressImage.js.html index ba92b359..99108023 100644 --- a/compressImage.js.html +++ b/compressImage.js.html @@ -230,7 +230,7 @@

compressImage.js


diff --git a/dataURLToBlob.js.html b/dataURLToBlob.js.html index 7d7dc3ca..ae94abe6 100644 --- a/dataURLToBlob.js.html +++ b/dataURLToBlob.js.html @@ -112,7 +112,7 @@

dataURLToBlob.js


diff --git a/divide.js.html b/divide.js.html index 18fcbc71..e2caf2db 100644 --- a/divide.js.html +++ b/divide.js.html @@ -133,7 +133,7 @@

divide.js


diff --git a/download.js.html b/download.js.html index 803781b2..78a6babb 100644 --- a/download.js.html +++ b/download.js.html @@ -225,7 +225,7 @@

download.js


diff --git a/fileReader.js.html b/fileReader.js.html index 961c74b1..7c43fb77 100644 --- a/fileReader.js.html +++ b/fileReader.js.html @@ -130,7 +130,7 @@

fileReader.js


diff --git a/filterTree.js.html b/filterTree.js.html index 1442f00f..7dd5d730 100644 --- a/filterTree.js.html +++ b/filterTree.js.html @@ -139,7 +139,7 @@

filterTree.js


diff --git a/findTreeNode.js.html b/findTreeNode.js.html index 7c60d87a..6f5f038e 100644 --- a/findTreeNode.js.html +++ b/findTreeNode.js.html @@ -139,7 +139,7 @@

findTreeNode.js


diff --git a/findTreeNodes.js.html b/findTreeNodes.js.html index 37c86166..a1527204 100644 --- a/findTreeNodes.js.html +++ b/findTreeNodes.js.html @@ -138,7 +138,7 @@

findTreeNodes.js


diff --git a/findTreeSelect.js.html b/findTreeSelect.js.html index 13f298b8..1f11133d 100644 --- a/findTreeSelect.js.html +++ b/findTreeSelect.js.html @@ -145,7 +145,7 @@

findTreeSelect.js


diff --git a/formatBankCard.js.html b/formatBankCard.js.html index 71d7f174..8c662a17 100644 --- a/formatBankCard.js.html +++ b/formatBankCard.js.html @@ -122,7 +122,7 @@

formatBankCard.js


diff --git a/formatMobile.js.html b/formatMobile.js.html index 11f65d54..d4ca7a36 100644 --- a/formatMobile.js.html +++ b/formatMobile.js.html @@ -125,7 +125,7 @@

formatMobile.js


diff --git a/formatMoney.js.html b/formatMoney.js.html index 0fbd4f00..764fcfc2 100644 --- a/formatMoney.js.html +++ b/formatMoney.js.html @@ -216,7 +216,7 @@

formatMoney.js


diff --git a/gcd.js.html b/gcd.js.html index 8614f001..166b42f1 100644 --- a/gcd.js.html +++ b/gcd.js.html @@ -150,7 +150,7 @@

gcd.js


diff --git a/getFileBlob.js.html b/getFileBlob.js.html index 420c86d4..f6ab7bf0 100644 --- a/getFileBlob.js.html +++ b/getFileBlob.js.html @@ -136,7 +136,7 @@

getFileBlob.js


diff --git a/getImageInfo.js.html b/getImageInfo.js.html index 8648a394..f55960e3 100644 --- a/getImageInfo.js.html +++ b/getImageInfo.js.html @@ -71,22 +71,22 @@

getImageInfo.js

-
import { round } from 'ut2';
+            
import { defaultTo, round } from 'ut2';
 import divide from './divide';
 import gcd from './gcd';
 import loadImageWithBlob from './loadImageWithBlob';
 import bytesToSize from './bytesToSize';
-import Cache from './utils/Cache';
 import { revokeObjectURL } from './utils/native';
-const cache = new Cache({ max: 1 });
-cache.on('del', (v) => {
-    if (v.r) {
-        try {
+import AsyncMemo from './AsyncMemo';
+const asyncMemo = new AsyncMemo({ max: 1, maxStrategy: 'replaced' });
+asyncMemo.cache.on('del', (k, v) => {
+    try {
+        if (v.r) {
             revokeObjectURL(v.data.image.src);
         }
-        catch {
-            /* empty */
-        }
+    }
+    catch {
+        /* empty */
     }
 });
 /**
@@ -140,39 +140,33 @@ 

getImageInfo.js

* */ function getImageInfo(img, cacheOptions = true, ajaxOptions) { + const cacheOptionsIsObject = typeof cacheOptions === 'object'; const _cacheOptions = { - useCache: typeof cacheOptions === 'object' ? cacheOptions.useCache !== false : cacheOptions !== false, - autoRevokeOnDel: typeof cacheOptions === 'object' ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions + useCache: cacheOptionsIsObject ? cacheOptions.useCache !== false : cacheOptions !== false, + autoRevokeOnDel: cacheOptionsIsObject ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions, + cacheKey: defaultTo(cacheOptionsIsObject ? cacheOptions.cacheKey : undefined, typeof img === 'string' ? img : undefined) }; - return new Promise((resolve, reject) => { - if (_cacheOptions.useCache && cache.has(img)) { - resolve(cache.get(img).data); - } - else { - loadImageWithBlob(img, false, ajaxOptions) - .then(({ image, blob }) => { - const { width, height } = image; - const result = { - width, - height, - contrast: calcContrast(width, height), - measure: `${width} × ${height} px`, - size: bytesToSize(blob.size), - bytes: blob.size, - image, - blob - }; - if (_cacheOptions.useCache) { - cache.set(img, { - data: result, - r: _cacheOptions.autoRevokeOnDel - }); - } - resolve(result); - }) - .catch(reject); - } - }); + return asyncMemo + .run(() => { + return loadImageWithBlob(img, false, ajaxOptions).then(({ image, blob }) => { + const { width, height } = image; + const data = { + width, + height, + contrast: calcContrast(width, height), + measure: `${width} × ${height} px`, + size: bytesToSize(blob.size), + bytes: blob.size, + image, + blob + }; + return { + data, + r: _cacheOptions.autoRevokeOnDel + }; + }); + }, _cacheOptions.useCache && _cacheOptions.cacheKey ? _cacheOptions.cacheKey : undefined) + .then((res) => res.data); } export default getImageInfo;
@@ -189,7 +183,7 @@

getImageInfo.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/global.html b/global.html index cc63c60d..84f0a751 100644 --- a/global.html +++ b/global.html @@ -1132,6 +1132,42 @@
Properties:
+ + + + cacheKey + + + + + +string + + + + + + + + + + <optional>
+ + + + + + + + + + + + +

缓存键

+ + + @@ -1750,7 +1786,7 @@

ImageWithBlob

Source:
@@ -2620,7 +2656,7 @@
Type:

- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/index.html b/index.html index 53d2958d..91818042 100644 --- a/index.html +++ b/index.html @@ -244,7 +244,7 @@

精选第三方工具库


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/index.js.html b/index.js.html index e79be794..d1f064a2 100644 --- a/index.js.html +++ b/index.js.html @@ -229,7 +229,7 @@

index.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isBankCard.js.html b/isBankCard.js.html index 88d64e3b..7d304265 100644 --- a/isBankCard.js.html +++ b/isBankCard.js.html @@ -140,7 +140,7 @@

isBankCard.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isBusinessLicense.js.html b/isBusinessLicense.js.html index bfad61d9..ae255df9 100644 --- a/isBusinessLicense.js.html +++ b/isBusinessLicense.js.html @@ -155,7 +155,7 @@

isBusinessLicense.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isChinese.js.html b/isChinese.js.html index 08333b40..cbf5c3c8 100644 --- a/isChinese.js.html +++ b/isChinese.js.html @@ -163,7 +163,7 @@

isChinese.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isEmail.js.html b/isEmail.js.html index 273a5c2a..81c22dce 100644 --- a/isEmail.js.html +++ b/isEmail.js.html @@ -107,7 +107,7 @@

isEmail.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isHMCard.js.html b/isHMCard.js.html index 04bae389..359d253e 100644 --- a/isHMCard.js.html +++ b/isHMCard.js.html @@ -115,7 +115,7 @@

isHMCard.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isIPv4.js.html b/isIPv4.js.html index a1c5a168..429240be 100644 --- a/isIPv4.js.html +++ b/isIPv4.js.html @@ -109,7 +109,7 @@

isIPv4.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isIPv6.js.html b/isIPv6.js.html index 0e393b9a..794f9539 100644 --- a/isIPv6.js.html +++ b/isIPv6.js.html @@ -123,7 +123,7 @@

isIPv6.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isIdCard.js.html b/isIdCard.js.html index 07edece4..ca2433c8 100644 --- a/isIdCard.js.html +++ b/isIdCard.js.html @@ -153,7 +153,7 @@

isIdCard.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isMobile.js.html b/isMobile.js.html index 0b33e0a6..12b04955 100644 --- a/isMobile.js.html +++ b/isMobile.js.html @@ -107,7 +107,7 @@

isMobile.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isPassport.js.html b/isPassport.js.html index cfebca72..46d29a01 100644 --- a/isPassport.js.html +++ b/isPassport.js.html @@ -109,7 +109,7 @@

isPassport.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isPassword.js.html b/isPassword.js.html index d515421c..48314adb 100644 --- a/isPassword.js.html +++ b/isPassword.js.html @@ -124,7 +124,7 @@

isPassword.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isPostcode.js.html b/isPostcode.js.html index 68116d57..04abb168 100644 --- a/isPostcode.js.html +++ b/isPostcode.js.html @@ -107,7 +107,7 @@

isPostcode.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isQQ.js.html b/isQQ.js.html index 831bc77c..ecf1986e 100644 --- a/isQQ.js.html +++ b/isQQ.js.html @@ -107,7 +107,7 @@

isQQ.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isSocialCreditCode.js.html b/isSocialCreditCode.js.html index 34b14416..fc75c748 100644 --- a/isSocialCreditCode.js.html +++ b/isSocialCreditCode.js.html @@ -155,7 +155,7 @@

isSocialCreditCode.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isSwiftCode.js.html b/isSwiftCode.js.html index f7c735bf..8dfcf6b1 100644 --- a/isSwiftCode.js.html +++ b/isSwiftCode.js.html @@ -112,7 +112,7 @@

isSwiftCode.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isTWCard.js.html b/isTWCard.js.html index 6b62758c..8d730e6c 100644 --- a/isTWCard.js.html +++ b/isTWCard.js.html @@ -121,7 +121,7 @@

isTWCard.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isTelephone.js.html b/isTelephone.js.html index 3eca7998..f3e9c9a5 100644 --- a/isTelephone.js.html +++ b/isTelephone.js.html @@ -113,7 +113,7 @@

isTelephone.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isUrl.js.html b/isUrl.js.html index 5cf2a7ca..96e16110 100644 --- a/isUrl.js.html +++ b/isUrl.js.html @@ -137,7 +137,7 @@

isUrl.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isValidNumber.js.html b/isValidNumber.js.html index 6fb908af..10496375 100644 --- a/isValidNumber.js.html +++ b/isValidNumber.js.html @@ -139,7 +139,7 @@

isValidNumber.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isVehicle.js.html b/isVehicle.js.html index 9685615e..7474fc6b 100644 --- a/isVehicle.js.html +++ b/isVehicle.js.html @@ -115,7 +115,7 @@

isVehicle.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/isWX.js.html b/isWX.js.html index 64c81d05..372060af 100644 --- a/isWX.js.html +++ b/isWX.js.html @@ -107,7 +107,7 @@

isWX.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/lcm.js.html b/lcm.js.html index 0f6e3bc4..1c63a85f 100644 --- a/lcm.js.html +++ b/lcm.js.html @@ -127,7 +127,7 @@

lcm.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/listToTree.js.html b/listToTree.js.html index a6d86cd6..0572bdfd 100644 --- a/listToTree.js.html +++ b/listToTree.js.html @@ -186,7 +186,7 @@

listToTree.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/loadImage.js.html b/loadImage.js.html index 18bd83d5..28631c02 100644 --- a/loadImage.js.html +++ b/loadImage.js.html @@ -71,24 +71,25 @@

loadImage.js

-
import { isBlob } from 'ut2';
+            
import { defaultTo, isBlob } from 'ut2';
 import { createObjectURL, revokeObjectURL } from './utils/native';
-import Cache from './utils/Cache';
-const cache = new Cache({ max: 1 });
-cache.on('del', (v) => {
-    if (v.r) {
-        try {
+import AsyncMemo from './AsyncMemo';
+const asyncMemo = new AsyncMemo({ max: 1, maxStrategy: 'replaced' });
+asyncMemo.cache.on('del', (k, v) => {
+    try {
+        if (v.r) {
             revokeObjectURL(v.data.src);
         }
-        catch {
-            /* empty */
-        }
+    }
+    catch {
+        /* empty */
     }
 });
 /**
  * @typedef {Object} CacheOptions 缓存配置
  * @property {boolean} [useCache=true] 是否使用缓存
  * @property {boolean} [autoRevokeOnDel=true] 删除时自动释放缓存
+ * @property {string} [cacheKey] 缓存键
  */
 /**
  * 加载图片。
@@ -117,15 +118,15 @@ 

loadImage.js

* */ function loadImage(img, cacheOptions = true) { + const cacheOptionsIsObject = typeof cacheOptions === 'object'; const _cacheOptions = { - useCache: typeof cacheOptions === 'object' ? cacheOptions.useCache !== false : cacheOptions !== false, - autoRevokeOnDel: typeof cacheOptions === 'object' ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions + useCache: cacheOptionsIsObject ? cacheOptions.useCache !== false : cacheOptions !== false, + autoRevokeOnDel: cacheOptionsIsObject ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions, + cacheKey: defaultTo(cacheOptionsIsObject ? cacheOptions.cacheKey : undefined, typeof img === 'string' ? img : undefined) }; - return new Promise((resolve, reject) => { - if (_cacheOptions.useCache && cache.has(img)) { - resolve(cache.get(img).data); - } - else { + return asyncMemo + .run(() => { + return new Promise((resolve, reject) => { const imgIsBlob = isBlob(img); const url = imgIsBlob ? createObjectURL(img) : img; const image = new Image(); @@ -133,13 +134,10 @@

loadImage.js

image.crossOrigin = 'anonymous'; } image.onload = () => { - if (_cacheOptions.useCache) { - cache.set(img, { - data: image, - r: _cacheOptions.autoRevokeOnDel - }); - } - resolve(image); + resolve({ + data: image, + r: _cacheOptions.autoRevokeOnDel + }); }; image.onerror = (err) => { if (imgIsBlob) { @@ -149,8 +147,9 @@

loadImage.js

reject(err); }; image.src = url; - } - }); + }); + }, _cacheOptions.useCache && _cacheOptions.cacheKey ? _cacheOptions.cacheKey : undefined) + .then((res) => res.data); } export default loadImage;
@@ -167,7 +166,7 @@

loadImage.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/loadImageWithBlob.js.html b/loadImageWithBlob.js.html index 2b0e74ed..08b7b212 100644 --- a/loadImageWithBlob.js.html +++ b/loadImageWithBlob.js.html @@ -73,16 +73,17 @@

loadImageWithBlob.js

import { createObjectURL, revokeObjectURL } from './utils/native';
 import getFileBlob from './getFileBlob';
-import Cache from './utils/Cache';
-const cache = new Cache({ max: 1 });
-cache.on('del', (v) => {
-    if (v.r) {
-        try {
+import AsyncMemo from './AsyncMemo';
+import { defaultTo } from 'ut2';
+const asyncMemo = new AsyncMemo({ max: 1, maxStrategy: 'replaced' });
+asyncMemo.cache.on('del', (k, v) => {
+    try {
+        if (v.r) {
             revokeObjectURL(v.data.image.src);
         }
-        catch {
-            /* empty */
-        }
+    }
+    catch {
+        /* empty */
     }
 });
 /**
@@ -118,28 +119,25 @@ 

loadImageWithBlob.js

* */ function loadImageWithBlob(img, cacheOptions = true, ajaxOptions) { + const cacheOptionsIsObject = typeof cacheOptions === 'object'; const _cacheOptions = { - useCache: typeof cacheOptions === 'object' ? cacheOptions.useCache !== false : cacheOptions !== false, - autoRevokeOnDel: typeof cacheOptions === 'object' ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions + useCache: cacheOptionsIsObject ? cacheOptions.useCache !== false : cacheOptions !== false, + autoRevokeOnDel: cacheOptionsIsObject ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions, + cacheKey: defaultTo(cacheOptionsIsObject ? cacheOptions.cacheKey : undefined, typeof img === 'string' ? img : undefined) }; - return new Promise((resolve, reject) => { - if (_cacheOptions.useCache && cache.has(img)) { - resolve(cache.get(img).data); - } - else { + return asyncMemo + .run(() => { + return new Promise((resolve, reject) => { getFileBlob(img, ajaxOptions) .then((blob) => { const url = createObjectURL(blob); const image = new Image(); image.onload = () => { - const result = { blob, image }; - if (_cacheOptions.useCache) { - cache.set(img, { - data: result, - r: _cacheOptions.autoRevokeOnDel - }); - } - resolve(result); + const data = { blob, image }; + resolve({ + data, + r: _cacheOptions.autoRevokeOnDel + }); }; image.onerror = (err) => { revokeObjectURL(url); @@ -149,8 +147,9 @@

loadImageWithBlob.js

image.src = url; }) .catch(reject); - } - }); + }); + }, _cacheOptions.useCache && _cacheOptions.cacheKey ? _cacheOptions.cacheKey : undefined) + .then((res) => res.data); } export default loadImageWithBlob;
@@ -167,7 +166,7 @@

loadImageWithBlob.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/loadScript.js.html b/loadScript.js.html index 049cd721..47713fb0 100644 --- a/loadScript.js.html +++ b/loadScript.js.html @@ -152,7 +152,7 @@

loadScript.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/minus.js.html b/minus.js.html index b88148db..c800b49d 100644 --- a/minus.js.html +++ b/minus.js.html @@ -125,7 +125,7 @@

minus.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/module-Math.html b/module-Math.html index d25e18d8..a1440017 100644 --- a/module-Math.html +++ b/module-Math.html @@ -1624,7 +1624,7 @@
Returns:

- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/module-Other.html b/module-Other.html index b3d0ff76..4bdf8e5f 100644 --- a/module-Other.html +++ b/module-Other.html @@ -2519,7 +2519,7 @@

Source:
@@ -2758,7 +2758,7 @@

Source:
@@ -3849,7 +3849,7 @@
Returns:

- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/module-Processor.html b/module-Processor.html index ee846ac6..57118ac5 100644 --- a/module-Processor.html +++ b/module-Processor.html @@ -4328,7 +4328,7 @@
Returns:

- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/module-Tree.html b/module-Tree.html index 5bbea980..8e7f93c0 100644 --- a/module-Tree.html +++ b/module-Tree.html @@ -2280,7 +2280,7 @@
Returns:

- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/module-Validator.html b/module-Validator.html index 4b88d42f..4d3e63fb 100644 --- a/module-Validator.html +++ b/module-Validator.html @@ -5422,7 +5422,7 @@
Returns:

- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/numberToChinese.js.html b/numberToChinese.js.html index fd94b05c..71d0ccaa 100644 --- a/numberToChinese.js.html +++ b/numberToChinese.js.html @@ -279,7 +279,7 @@

numberToChinese.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/padZero.js.html b/padZero.js.html index 352ef255..b51b8fde 100644 --- a/padZero.js.html +++ b/padZero.js.html @@ -121,7 +121,7 @@

padZero.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/parseIdCard.js.html b/parseIdCard.js.html index 28d6e99f..21b28ea3 100644 --- a/parseIdCard.js.html +++ b/parseIdCard.js.html @@ -197,7 +197,7 @@

parseIdCard.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/plus.js.html b/plus.js.html index 83e83191..085bf631 100644 --- a/plus.js.html +++ b/plus.js.html @@ -125,7 +125,7 @@

plus.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/randomString.js.html b/randomString.js.html index 9f71613e..b834c6d9 100644 --- a/randomString.js.html +++ b/randomString.js.html @@ -140,7 +140,7 @@

randomString.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/replaceChar.js.html b/replaceChar.js.html index 15d14fc7..a5a3bc3e 100644 --- a/replaceChar.js.html +++ b/replaceChar.js.html @@ -161,7 +161,7 @@

replaceChar.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/round.js.html b/round.js.html index e5ede1fe..701e996d 100644 --- a/round.js.html +++ b/round.js.html @@ -106,7 +106,7 @@

round.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/safeDate.js.html b/safeDate.js.html index 7fe3b273..d54f344a 100644 --- a/safeDate.js.html +++ b/safeDate.js.html @@ -117,7 +117,7 @@

safeDate.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/setDataURLPrefix.js.html b/setDataURLPrefix.js.html index 286ec275..9c98b779 100644 --- a/setDataURLPrefix.js.html +++ b/setDataURLPrefix.js.html @@ -114,7 +114,7 @@

setDataURLPrefix.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/strlen.js.html b/strlen.js.html index d60d23fb..e6175953 100644 --- a/strlen.js.html +++ b/strlen.js.html @@ -119,7 +119,7 @@

strlen.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/times.js.html b/times.js.html index 76d04c86..6b140428 100644 --- a/times.js.html +++ b/times.js.html @@ -128,7 +128,7 @@

times.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/transformFieldNames.js.html b/transformFieldNames.js.html index 4ae6a58d..5f4f66d2 100644 --- a/transformFieldNames.js.html +++ b/transformFieldNames.js.html @@ -166,7 +166,7 @@

transformFieldNames.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/transformObjectValue.js.html b/transformObjectValue.js.html index 29ba3b87..74e40348 100644 --- a/transformObjectValue.js.html +++ b/transformObjectValue.js.html @@ -163,7 +163,7 @@

transformObjectValue.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/treeToList.js.html b/treeToList.js.html index af2e1489..efb9e5b9 100644 --- a/treeToList.js.html +++ b/treeToList.js.html @@ -159,7 +159,7 @@

treeToList.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/validatePassword.js.html b/validatePassword.js.html index 6a216788..bea6472a 100644 --- a/validatePassword.js.html +++ b/validatePassword.js.html @@ -301,7 +301,7 @@

validatePassword.js


- Documentation generated by JSDoc 4.0.3 on Thu Jun 13 2024 06:03:56 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 4.0.3 on Fri Jun 14 2024 09:50:37 GMT+0000 (Coordinated Universal Time) using the docdash theme.