diff --git a/.gitignore b/.gitignore index 6622d3b7ff..f5ab3b4100 100755 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ lib node_modules .history .idea +.vscode coverage .doc .DS_Store diff --git a/package-lock.json b/package-lock.json index 10603747d5..411bc34349 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9035,7 +9035,7 @@ }, "alphanum-sort": { "version": "1.0.2", - "resolved": "https://registry.npm.alibaba-inc.com/alphanum-sort/download/alphanum-sort-1.0.2.tgz", + "resolved": "https://registry.npm.taobao.org/alphanum-sort/download/alphanum-sort-1.0.2.tgz", "integrity": "sha1-l6ERlkmyEa0zaR2fn0hqjsn74KM=", "dev": true }, @@ -9094,7 +9094,7 @@ }, "ansicolors": { "version": "0.3.2", - "resolved": "https://registry.npm.alibaba-inc.com/ansicolors/download/ansicolors-0.3.2.tgz", + "resolved": "https://registry.npm.taobao.org/ansicolors/download/ansicolors-0.3.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansicolors%2Fdownload%2Fansicolors-0.3.2.tgz", "integrity": "sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk=", "dev": true }, @@ -9149,7 +9149,7 @@ }, "any-promise": { "version": "1.3.0", - "resolved": "https://registry.npm.alibaba-inc.com/any-promise/download/any-promise-1.3.0.tgz", + "resolved": "https://registry.npm.taobao.org/any-promise/download/any-promise-1.3.0.tgz", "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=", "dev": true }, @@ -9185,7 +9185,7 @@ }, "append-field": { "version": "1.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/append-field/download/append-field-1.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/append-field/download/append-field-1.0.0.tgz", "integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY=", "dev": true }, @@ -9298,7 +9298,7 @@ }, "array-flatten": { "version": "1.1.1", - "resolved": "https://registry.npm.alibaba-inc.com/array-flatten/download/array-flatten-1.1.1.tgz", + "resolved": "https://registry.npm.taobao.org/array-flatten/download/array-flatten-1.1.1.tgz?cache=0&sync_timestamp=1574313315299&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Farray-flatten%2Fdownload%2Farray-flatten-1.1.1.tgz", "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", "dev": true }, @@ -10243,7 +10243,7 @@ }, "busboy": { "version": "0.2.14", - "resolved": "https://registry.npm.alibaba-inc.com/busboy/download/busboy-0.2.14.tgz", + "resolved": "https://registry.npm.taobao.org/busboy/download/busboy-0.2.14.tgz", "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=", "dev": true, "requires": { @@ -10253,13 +10253,13 @@ "dependencies": { "isarray": { "version": "0.0.1", - "resolved": "https://registry.npm.alibaba-inc.com/isarray/download/isarray-0.0.1.tgz", + "resolved": "https://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz?cache=0&sync_timestamp=1562592096220&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fisarray%2Fdownload%2Fisarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, "readable-stream": { "version": "1.1.14", - "resolved": "https://registry.npm.alibaba-inc.com/readable-stream/download/readable-stream-1.1.14.tgz", + "resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { @@ -10271,7 +10271,7 @@ }, "string_decoder": { "version": "0.10.31", - "resolved": "https://registry.npm.alibaba-inc.com/string_decoder/download/string_decoder-0.10.31.tgz", + "resolved": "https://registry.npm.taobao.org/string_decoder/download/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true } @@ -10285,7 +10285,7 @@ }, "bytes": { "version": "3.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/bytes/download/bytes-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", "dev": true }, @@ -10471,7 +10471,7 @@ }, "cardinal": { "version": "2.1.1", - "resolved": "https://registry.npm.alibaba-inc.com/cardinal/download/cardinal-2.1.1.tgz", + "resolved": "https://registry.npm.taobao.org/cardinal/download/cardinal-2.1.1.tgz", "integrity": "sha1-fMEFXYItISlU0HsIXeolHMe8VQU=", "dev": true, "requires": { @@ -10726,7 +10726,7 @@ }, "cli-table": { "version": "0.3.1", - "resolved": "https://registry.npm.alibaba-inc.com/cli-table/download/cli-table-0.3.1.tgz", + "resolved": "https://registry.npm.taobao.org/cli-table/download/cli-table-0.3.1.tgz", "integrity": "sha1-9TsFJmqLGguTSz0IIebi3FkUriM=", "dev": true, "requires": { @@ -10918,7 +10918,7 @@ }, "clone-response": { "version": "1.0.2", - "resolved": "https://registry.npm.alibaba-inc.com/clone-response/download/clone-response-1.0.2.tgz", + "resolved": "https://registry.npm.taobao.org/clone-response/download/clone-response-1.0.2.tgz", "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", "dev": true, "requires": { @@ -12176,7 +12176,7 @@ }, "cookie-signature": { "version": "1.0.6", - "resolved": "https://registry.npm.alibaba-inc.com/cookie-signature/download/cookie-signature-1.0.6.tgz", + "resolved": "https://registry.npm.taobao.org/cookie-signature/download/cookie-signature-1.0.6.tgz", "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", "dev": true }, @@ -12463,7 +12463,7 @@ }, "crequire": { "version": "1.8.1", - "resolved": "https://registry.npm.alibaba-inc.com/crequire/download/crequire-1.8.1.tgz", + "resolved": "https://registry.npm.taobao.org/crequire/download/crequire-1.8.1.tgz", "integrity": "sha1-rIHyBHhrXyARlOsWmM9EGxCktX0=", "dev": true }, @@ -12525,7 +12525,7 @@ }, "css-color-names": { "version": "0.0.4", - "resolved": "https://registry.npm.alibaba-inc.com/css-color-names/download/css-color-names-0.0.4.tgz", + "resolved": "https://registry.npm.taobao.org/css-color-names/download/css-color-names-0.0.4.tgz", "integrity": "sha1-gIrcLnnPhHOAabZGyyDsJ762KeA=", "dev": true }, @@ -12768,13 +12768,13 @@ }, "cssnano-util-get-arguments": { "version": "4.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/cssnano-util-get-arguments/download/cssnano-util-get-arguments-4.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/cssnano-util-get-arguments/download/cssnano-util-get-arguments-4.0.0.tgz", "integrity": "sha1-7ToIKZ8h11dBsg87gfGU7UnMFQ8=", "dev": true }, "cssnano-util-get-match": { "version": "4.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/cssnano-util-get-match/download/cssnano-util-get-match-4.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/cssnano-util-get-match/download/cssnano-util-get-match-4.0.0.tgz", "integrity": "sha1-wOTKB/U4a7F+xeUiULT1lhNlFW0=", "dev": true }, @@ -12974,7 +12974,7 @@ }, "decompress-response": { "version": "3.3.0", - "resolved": "https://registry.npm.alibaba-inc.com/decompress-response/download/decompress-response-3.3.0.tgz", + "resolved": "https://registry.npm.taobao.org/decompress-response/download/decompress-response-3.3.0.tgz", "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", "dev": true, "requires": { @@ -13207,7 +13207,7 @@ }, "depd": { "version": "1.1.2", - "resolved": "https://registry.npm.alibaba-inc.com/depd/download/depd-1.1.2.tgz", + "resolved": "https://registry.npm.taobao.org/depd/download/depd-1.1.2.tgz", "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", "dev": true }, @@ -13223,7 +13223,7 @@ }, "destroy": { "version": "1.0.4", - "resolved": "https://registry.npm.alibaba-inc.com/destroy/download/destroy-1.0.4.tgz", + "resolved": "https://registry.npm.taobao.org/destroy/download/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", "dev": true }, @@ -13262,7 +13262,7 @@ }, "dicer": { "version": "0.2.5", - "resolved": "https://registry.npm.alibaba-inc.com/dicer/download/dicer-0.2.5.tgz", + "resolved": "https://registry.npm.taobao.org/dicer/download/dicer-0.2.5.tgz", "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=", "dev": true, "requires": { @@ -13272,13 +13272,13 @@ "dependencies": { "isarray": { "version": "0.0.1", - "resolved": "https://registry.npm.alibaba-inc.com/isarray/download/isarray-0.0.1.tgz", + "resolved": "https://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz?cache=0&sync_timestamp=1562592096220&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fisarray%2Fdownload%2Fisarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, "readable-stream": { "version": "1.1.14", - "resolved": "https://registry.npm.alibaba-inc.com/readable-stream/download/readable-stream-1.1.14.tgz", + "resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { @@ -13290,7 +13290,7 @@ }, "string_decoder": { "version": "0.10.31", - "resolved": "https://registry.npm.alibaba-inc.com/string_decoder/download/string_decoder-0.10.31.tgz", + "resolved": "https://registry.npm.taobao.org/string_decoder/download/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true } @@ -13518,7 +13518,7 @@ }, "ee-first": { "version": "1.1.1", - "resolved": "https://registry.npm.alibaba-inc.com/ee-first/download/ee-first-1.1.1.tgz", + "resolved": "https://registry.npm.taobao.org/ee-first/download/ee-first-1.1.1.tgz", "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", "dev": true }, @@ -13574,7 +13574,7 @@ }, "encodeurl": { "version": "1.0.2", - "resolved": "https://registry.npm.alibaba-inc.com/encodeurl/download/encodeurl-1.0.2.tgz", + "resolved": "https://registry.npm.taobao.org/encodeurl/download/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", "dev": true }, @@ -13785,7 +13785,7 @@ }, "escape-html": { "version": "1.0.3", - "resolved": "https://registry.npm.alibaba-inc.com/escape-html/download/escape-html-1.0.3.tgz", + "resolved": "https://registry.npm.taobao.org/escape-html/download/escape-html-1.0.3.tgz", "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", "dev": true }, @@ -14665,7 +14665,7 @@ }, "etag": { "version": "1.8.1", - "resolved": "https://registry.npm.alibaba-inc.com/etag/download/etag-1.8.1.tgz", + "resolved": "https://registry.npm.taobao.org/etag/download/etag-1.8.1.tgz", "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", "dev": true }, @@ -15448,7 +15448,7 @@ }, "flatmap": { "version": "0.0.3", - "resolved": "https://registry.npm.alibaba-inc.com/flatmap/download/flatmap-0.0.3.tgz", + "resolved": "https://registry.npm.taobao.org/flatmap/download/flatmap-0.0.3.tgz", "integrity": "sha1-Hxik2TgVLUlZZfnJWNkjqy3WabQ=", "dev": true }, @@ -15488,7 +15488,7 @@ }, "for-own": { "version": "0.1.5", - "resolved": "https://registry.npm.alibaba-inc.com/for-own/download/for-own-0.1.5.tgz", + "resolved": "https://registry.npm.taobao.org/for-own/download/for-own-0.1.5.tgz", "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", "dev": true, "requires": { @@ -15631,7 +15631,7 @@ }, "format": { "version": "0.2.2", - "resolved": "https://registry.npm.alibaba-inc.com/format/download/format-0.2.2.tgz", + "resolved": "https://registry.npm.taobao.org/format/download/format-0.2.2.tgz", "integrity": "sha1-1hcBB+nv3E7TDJ3DkBbflCtctYs=", "dev": true }, @@ -15643,7 +15643,7 @@ }, "forwarded": { "version": "0.1.2", - "resolved": "https://registry.npm.alibaba-inc.com/forwarded/download/forwarded-0.1.2.tgz", + "resolved": "https://registry.npm.taobao.org/forwarded/download/forwarded-0.1.2.tgz", "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", "dev": true }, @@ -15658,7 +15658,7 @@ }, "fresh": { "version": "0.5.2", - "resolved": "https://registry.npm.alibaba-inc.com/fresh/download/fresh-0.5.2.tgz", + "resolved": "https://registry.npm.taobao.org/fresh/download/fresh-0.5.2.tgz", "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", "dev": true }, @@ -16688,7 +16688,7 @@ }, "good-listener": { "version": "1.2.2", - "resolved": "https://registry.npm.alibaba-inc.com/good-listener/download/good-listener-1.2.2.tgz", + "resolved": "https://registry.npm.taobao.org/good-listener/download/good-listener-1.2.2.tgz", "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=", "dev": true, "optional": true, @@ -17125,7 +17125,7 @@ }, "has-ansi": { "version": "2.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/has-ansi/download/has-ansi-2.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/has-ansi/download/has-ansi-2.0.0.tgz", "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { @@ -17134,7 +17134,7 @@ "dependencies": { "ansi-regex": { "version": "2.1.1", - "resolved": "https://registry.npm.alibaba-inc.com/ansi-regex/download/ansi-regex-2.1.1.tgz", + "resolved": "https://registry.npm.taobao.org/ansi-regex/download/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true } @@ -17554,7 +17554,7 @@ }, "hpack.js": { "version": "2.1.6", - "resolved": "https://registry.npm.alibaba-inc.com/hpack.js/download/hpack.js-2.1.6.tgz", + "resolved": "https://registry.npm.taobao.org/hpack.js/download/hpack.js-2.1.6.tgz", "integrity": "sha1-h3dMCUnlE/QuhFdbPEVoH63ioLI=", "dev": true, "requires": { @@ -17566,13 +17566,13 @@ }, "hsl-regex": { "version": "1.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/hsl-regex/download/hsl-regex-1.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/hsl-regex/download/hsl-regex-1.0.0.tgz", "integrity": "sha1-1JMwx4ntgZ4nakwNJy3/owsY/m4=", "dev": true }, "hsla-regex": { "version": "1.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/hsla-regex/download/hsla-regex-1.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/hsla-regex/download/hsla-regex-1.0.0.tgz", "integrity": "sha1-wc56MWjIxmFAM6S194d/OyJfnDg=", "dev": true }, @@ -17653,7 +17653,7 @@ }, "http-deceiver": { "version": "1.2.7", - "resolved": "https://registry.npm.alibaba-inc.com/http-deceiver/download/http-deceiver-1.2.7.tgz", + "resolved": "https://registry.npm.taobao.org/http-deceiver/download/http-deceiver-1.2.7.tgz", "integrity": "sha1-+nFolEq5pRnTN8sL7HKE3D5yPYc=", "dev": true }, @@ -17954,7 +17954,7 @@ }, "image-size": { "version": "0.5.5", - "resolved": "https://registry.npm.alibaba-inc.com/image-size/download/image-size-0.5.5.tgz", + "resolved": "https://registry.npm.taobao.org/image-size/download/image-size-0.5.5.tgz?cache=0&sync_timestamp=1569841504754&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fimage-size%2Fdownload%2Fimage-size-0.5.5.tgz", "integrity": "sha1-Cd/Uq50g4p6xw+gLiZA3jfnjy5w=", "dev": true, "optional": true @@ -17967,7 +17967,7 @@ }, "import-cwd": { "version": "2.1.0", - "resolved": "https://registry.npm.alibaba-inc.com/import-cwd/download/import-cwd-2.1.0.tgz", + "resolved": "https://registry.npm.taobao.org/import-cwd/download/import-cwd-2.1.0.tgz", "integrity": "sha1-qmzzbnInYShcs3HsZRn1PiQ1sKk=", "dev": true, "requires": { @@ -17986,7 +17986,7 @@ }, "import-from": { "version": "2.1.0", - "resolved": "https://registry.npm.alibaba-inc.com/import-from/download/import-from-2.1.0.tgz", + "resolved": "https://registry.npm.taobao.org/import-from/download/import-from-2.1.0.tgz", "integrity": "sha1-M1238qev/VOqpHHUuAId7ja387E=", "dev": true, "requires": { @@ -17995,7 +17995,7 @@ "dependencies": { "resolve-from": { "version": "3.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/resolve-from/download/resolve-from-3.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/resolve-from/download/resolve-from-3.0.0.tgz", "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", "dev": true } @@ -18378,7 +18378,7 @@ }, "is-color-stop": { "version": "1.1.0", - "resolved": "https://registry.npm.alibaba-inc.com/is-color-stop/download/is-color-stop-1.1.0.tgz", + "resolved": "https://registry.npm.taobao.org/is-color-stop/download/is-color-stop-1.1.0.tgz", "integrity": "sha1-z/9HGu5N1cnhWFmPvhKWe1za00U=", "dev": true, "requires": { @@ -21260,7 +21260,7 @@ }, "json-buffer": { "version": "3.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/json-buffer/download/json-buffer-3.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/json-buffer/download/json-buffer-3.0.0.tgz", "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=", "dev": true }, @@ -21437,7 +21437,7 @@ }, "kebab-case": { "version": "1.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/kebab-case/download/kebab-case-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/kebab-case/-/kebab-case-1.0.0.tgz", "integrity": "sha1-P55JkK3K0MaGwOcB92RYaPdfkes=", "dev": true }, @@ -21490,7 +21490,7 @@ }, "lazy-cache": { "version": "1.0.4", - "resolved": "https://registry.npm.alibaba-inc.com/lazy-cache/download/lazy-cache-1.0.4.tgz", + "resolved": "https://registry.npm.taobao.org/lazy-cache/download/lazy-cache-1.0.4.tgz", "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", "dev": true }, @@ -22141,7 +22141,7 @@ }, "levdist": { "version": "1.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/levdist/download/levdist-1.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/levdist/download/levdist-1.0.0.tgz", "integrity": "sha1-kdejBElk8szEIaBHfKyCf+dcVxg=", "dev": true }, @@ -22352,7 +22352,7 @@ }, "lodash.toarray": { "version": "4.4.0", - "resolved": "https://registry.npm.alibaba-inc.com/lodash.toarray/download/lodash.toarray-4.4.0.tgz", + "resolved": "https://registry.npm.taobao.org/lodash.toarray/download/lodash.toarray-4.4.0.tgz", "integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE=", "dev": true }, @@ -22370,7 +22370,7 @@ }, "lodash.uniq": { "version": "4.5.0", - "resolved": "https://registry.npm.alibaba-inc.com/lodash.uniq/download/lodash.uniq-4.5.0.tgz", + "resolved": "https://registry.npm.taobao.org/lodash.uniq/download/lodash.uniq-4.5.0.tgz", "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=", "dev": true }, @@ -22452,7 +22452,7 @@ }, "lz-string": { "version": "1.4.4", - "resolved": "https://registry.npm.alibaba-inc.com/lz-string/download/lz-string-1.4.4.tgz", + "resolved": "https://registry.npm.taobao.org/lz-string/download/lz-string-1.4.4.tgz", "integrity": "sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY=", "dev": true }, @@ -22742,13 +22742,13 @@ }, "mdurl": { "version": "1.0.1", - "resolved": "https://registry.npm.alibaba-inc.com/mdurl/download/mdurl-1.0.1.tgz", + "resolved": "https://registry.npm.taobao.org/mdurl/download/mdurl-1.0.1.tgz", "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", "dev": true }, "media-typer": { "version": "0.3.0", - "resolved": "https://registry.npm.alibaba-inc.com/media-typer/download/media-typer-0.3.0.tgz", + "resolved": "https://registry.npm.taobao.org/media-typer/download/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", "dev": true }, @@ -22993,7 +22993,7 @@ }, "merge-descriptors": { "version": "1.0.1", - "resolved": "https://registry.npm.alibaba-inc.com/merge-descriptors/download/merge-descriptors-1.0.1.tgz", + "resolved": "https://registry.npm.taobao.org/merge-descriptors/download/merge-descriptors-1.0.1.tgz", "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", "dev": true }, @@ -23011,7 +23011,7 @@ }, "methods": { "version": "1.1.2", - "resolved": "https://registry.npm.alibaba-inc.com/methods/download/methods-1.1.2.tgz", + "resolved": "https://registry.npm.taobao.org/methods/download/methods-1.1.2.tgz", "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", "dev": true }, @@ -23262,7 +23262,7 @@ }, "mixin-object": { "version": "2.0.1", - "resolved": "https://registry.npm.alibaba-inc.com/mixin-object/download/mixin-object-2.0.1.tgz", + "resolved": "https://registry.npm.taobao.org/mixin-object/download/mixin-object-2.0.1.tgz", "integrity": "sha1-T7lJRB2rGCVA8f4DW6YOGUel5X4=", "dev": true, "requires": { @@ -23272,7 +23272,7 @@ "dependencies": { "for-in": { "version": "0.1.8", - "resolved": "https://registry.npm.alibaba-inc.com/for-in/download/for-in-0.1.8.tgz", + "resolved": "https://registry.npm.taobao.org/for-in/download/for-in-0.1.8.tgz", "integrity": "sha1-2Hc5COMSVhCZUrH9ubP6hn0ndeE=", "dev": true } @@ -23942,7 +23942,7 @@ }, "on-finished": { "version": "2.3.0", - "resolved": "https://registry.npm.alibaba-inc.com/on-finished/download/on-finished-2.3.0.tgz", + "resolved": "https://registry.npm.taobao.org/on-finished/download/on-finished-2.3.0.tgz", "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", "dev": true, "requires": { @@ -24437,7 +24437,7 @@ }, "pkg-conf": { "version": "2.1.0", - "resolved": "https://registry.npm.alibaba-inc.com/pkg-conf/download/pkg-conf-2.1.0.tgz", + "resolved": "https://registry.npm.taobao.org/pkg-conf/download/pkg-conf-2.1.0.tgz", "integrity": "sha1-ISZRTKbyq/69FoWW3xi6V4Z/AFg=", "dev": true, "requires": { @@ -24447,7 +24447,7 @@ "dependencies": { "load-json-file": { "version": "4.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/load-json-file/download/load-json-file-4.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/load-json-file/download/load-json-file-4.0.0.tgz", "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", "dev": true, "requires": { @@ -24459,7 +24459,7 @@ }, "parse-json": { "version": "4.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/parse-json/download/parse-json-4.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/parse-json/download/parse-json-4.0.0.tgz", "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", "dev": true, "requires": { @@ -26952,7 +26952,7 @@ }, "redeyed": { "version": "2.1.1", - "resolved": "https://registry.npm.alibaba-inc.com/redeyed/download/redeyed-2.1.1.tgz", + "resolved": "https://registry.npm.taobao.org/redeyed/download/redeyed-2.1.1.tgz", "integrity": "sha1-iYS1gV2ZyyIEacme7v/jiRPmzAs=", "dev": true, "requires": { @@ -27639,7 +27639,7 @@ }, "requires-port": { "version": "1.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/requires-port/download/requires-port-1.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/requires-port/download/requires-port-1.0.0.tgz", "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", "dev": true }, @@ -27755,7 +27755,7 @@ }, "responselike": { "version": "1.0.2", - "resolved": "https://registry.npm.alibaba-inc.com/responselike/download/responselike-1.0.2.tgz", + "resolved": "https://registry.npm.taobao.org/responselike/download/responselike-1.0.2.tgz?cache=0&sync_timestamp=1570573217730&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fresponselike%2Fdownload%2Fresponselike-1.0.2.tgz", "integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=", "dev": true, "requires": { @@ -27792,13 +27792,13 @@ }, "rgb-regex": { "version": "1.0.1", - "resolved": "https://registry.npm.alibaba-inc.com/rgb-regex/download/rgb-regex-1.0.1.tgz", + "resolved": "https://registry.npm.taobao.org/rgb-regex/download/rgb-regex-1.0.1.tgz", "integrity": "sha1-wODWiC3w4jviVKR16O3UGRX+rrE=", "dev": true }, "rgba-regex": { "version": "1.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/rgba-regex/download/rgba-regex-1.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/rgba-regex/download/rgba-regex-1.0.0.tgz", "integrity": "sha1-QzdOLiyglosO8VI0YLfXMP8i7rM=", "dev": true }, @@ -28057,14 +28057,14 @@ }, "select": { "version": "1.1.2", - "resolved": "https://registry.npm.alibaba-inc.com/select/download/select-1.1.2.tgz", + "resolved": "https://registry.npm.taobao.org/select/download/select-1.1.2.tgz", "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=", "dev": true, "optional": true }, "select-hose": { "version": "2.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/select-hose/download/select-hose-2.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/select-hose/download/select-hose-2.0.0.tgz", "integrity": "sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo=", "dev": true }, @@ -28273,7 +28273,7 @@ }, "simple-swizzle": { "version": "0.2.2", - "resolved": "https://registry.npm.alibaba-inc.com/simple-swizzle/download/simple-swizzle-0.2.2.tgz", + "resolved": "https://registry.npm.taobao.org/simple-swizzle/download/simple-swizzle-0.2.2.tgz", "integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=", "dev": true, "requires": { @@ -28485,7 +28485,7 @@ }, "sort-keys": { "version": "1.1.2", - "resolved": "https://registry.npm.alibaba-inc.com/sort-keys/download/sort-keys-1.1.2.tgz", + "resolved": "https://registry.npm.taobao.org/sort-keys/download/sort-keys-1.1.2.tgz?cache=0&sync_timestamp=1565864727994&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsort-keys%2Fdownload%2Fsort-keys-1.1.2.tgz", "integrity": "sha1-RBttTTRnmPG05J6JIK37oOVD+a0=", "dev": true, "requires": { @@ -28810,7 +28810,7 @@ }, "statuses": { "version": "1.5.0", - "resolved": "https://registry.npm.alibaba-inc.com/statuses/download/statuses-1.5.0.tgz", + "resolved": "https://registry.npm.taobao.org/statuses/download/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", "dev": true }, @@ -28890,13 +28890,13 @@ }, "streamsearch": { "version": "0.1.2", - "resolved": "https://registry.npm.alibaba-inc.com/streamsearch/download/streamsearch-0.1.2.tgz", + "resolved": "https://registry.npm.taobao.org/streamsearch/download/streamsearch-0.1.2.tgz", "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=", "dev": true }, "strict-uri-encode": { "version": "2.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/strict-uri-encode/download/strict-uri-encode-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", "integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=", "dev": true }, @@ -31644,7 +31644,7 @@ }, "thenify-all": { "version": "1.6.0", - "resolved": "https://registry.npm.alibaba-inc.com/thenify-all/download/thenify-all-1.6.0.tgz", + "resolved": "https://registry.npm.taobao.org/thenify-all/download/thenify-all-1.6.0.tgz", "integrity": "sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=", "dev": true, "requires": { @@ -31716,7 +31716,7 @@ }, "timsort": { "version": "0.3.0", - "resolved": "https://registry.npm.alibaba-inc.com/timsort/download/timsort-0.3.0.tgz", + "resolved": "https://registry.npm.taobao.org/timsort/download/timsort-0.3.0.tgz", "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=", "dev": true }, @@ -32532,7 +32532,7 @@ }, "uniqs": { "version": "2.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/uniqs/download/uniqs-2.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/uniqs/download/uniqs-2.0.0.tgz", "integrity": "sha1-/+3ks2slKQaW5uFl1KWe25mOawI=", "dev": true }, @@ -32676,13 +32676,13 @@ }, "unpipe": { "version": "1.0.0", - "resolved": "https://registry.npm.alibaba-inc.com/unpipe/download/unpipe-1.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/unpipe/download/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", "dev": true }, "unquote": { "version": "1.1.1", - "resolved": "https://registry.npm.alibaba-inc.com/unquote/download/unquote-1.1.1.tgz", + "resolved": "https://registry.npm.taobao.org/unquote/download/unquote-1.1.1.tgz", "integrity": "sha1-j97XMk7G6IoP+LkF58CYzcCG1UQ=", "dev": true }, @@ -32894,7 +32894,7 @@ }, "utils-merge": { "version": "1.0.1", - "resolved": "https://registry.npm.alibaba-inc.com/utils-merge/download/utils-merge-1.0.1.tgz", + "resolved": "https://registry.npm.taobao.org/utils-merge/download/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", "dev": true }, @@ -32962,7 +32962,7 @@ }, "vary": { "version": "1.1.2", - "resolved": "https://registry.npm.alibaba-inc.com/vary/download/vary-1.1.2.tgz", + "resolved": "https://registry.npm.taobao.org/vary/download/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", "dev": true }, diff --git a/packages/hooks/src/index.ts b/packages/hooks/src/index.ts index e7e34338ed..a33da9699b 100644 --- a/packages/hooks/src/index.ts +++ b/packages/hooks/src/index.ts @@ -53,6 +53,7 @@ import useReactive from './useReactive'; import useFavicon from './useFavicon'; import useCountDown from './useCountDown'; import useWebSocket from './useWebSocket'; +import useLockFn from './useLockFn'; const useControlledValue: typeof useControllableValue = function (...args) { console.warn( @@ -121,4 +122,5 @@ export { useFavicon, useCountDown, useWebSocket, + useLockFn, }; diff --git a/packages/hooks/src/useLockFn/__tests__/index.test.ts b/packages/hooks/src/useLockFn/__tests__/index.test.ts new file mode 100644 index 0000000000..f18fc12ccb --- /dev/null +++ b/packages/hooks/src/useLockFn/__tests__/index.test.ts @@ -0,0 +1,41 @@ +import { renderHook, act } from '@testing-library/react-hooks'; +import { useRef } from 'react'; +import useLockFn from '../index'; +import { sleep } from '../../utils/testingHelpers'; + +describe('useLockFn', () => { + it('should be defined', () => { + expect(useLockFn).toBeDefined(); + }); + + const setUp = (): any => + renderHook(() => { + const countRef = useRef(0); + const locked = useLockFn(async (step: number) => { + countRef.current += step; + await sleep(50); + }); + + return { + locked, + countRef, + }; + }); + + it('should work', async () => { + const hook = setUp(); + const { locked, countRef } = hook.result.current; + locked(1); + expect(countRef.current).toBe(1); + locked(2); + expect(countRef.current).toBe(1); + await sleep(30); + locked(3); + expect(countRef.current).toBe(1); + await sleep(30); + locked(4); + expect(countRef.current).toBe(5); + locked(5); + expect(countRef.current).toBe(5); + }); +}); diff --git a/packages/hooks/src/useLockFn/demo/demo1.tsx b/packages/hooks/src/useLockFn/demo/demo1.tsx new file mode 100644 index 0000000000..0978f18a7b --- /dev/null +++ b/packages/hooks/src/useLockFn/demo/demo1.tsx @@ -0,0 +1,37 @@ +/** + * title: Prevent duplicated submits + * desc: Before the `submit` function finishes, the other click actions will be ignored. + * + * title.zh-CN: 防止重复提交 + * desc.zh-CN: 在 `submit` 函数执行完成前,其余的点击动作都会被忽略。 + */ + +import React, { useState } from 'react'; +import { message } from 'antd'; +import { useLockFn } from 'ahooks'; + +function mockApiRequest() { + return new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, 2000); + }); +} + +export default () => { + const [count, setCount] = useState(0); + + const submit = useLockFn(async () => { + message.info('Start to submit'); + await mockApiRequest(); + setCount((val) => val + 1); + message.success('Submit finished'); + }); + + return ( + <> +
Submit count: {count}
+ + > + ); +}; diff --git a/packages/hooks/src/useLockFn/index.en-US.md b/packages/hooks/src/useLockFn/index.en-US.md new file mode 100644 index 0000000000..f894cded82 --- /dev/null +++ b/packages/hooks/src/useLockFn/index.en-US.md @@ -0,0 +1,40 @@ +--- +title: useLockFn +nav: + title: Hooks + path: /hooks +group: + title: Advanced + path: /advanced +--- + +# useLockFn + +Add lock to an async function to prevent parallel executions. + +## Examples + +### Prevent duplicated submits + +
+
+## API
+
+```typescript
+function useLockFn(
+ fn: (...args: P) => Promise (fn: (...args: P) => Promise (
+ fn: (...args: P) => Promise
+
+## API
+
+```typescript
+function useLockFn