diff --git a/package.json b/package.json index 6ad4ee3..e1a5f01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@byloth/core", - "version": "2.0.0-rc.2", + "version": "2.0.0-rc.3", "description": "An unopinionated collection of useful functions and classes that I use widely in all my projects. 🔧", "keywords": [ "Core", @@ -57,15 +57,14 @@ "ci": "pnpm install --frozen-lockfile" }, "devDependencies": { - "@byloth/eslint-config-typescript": "^2.8.2", + "@byloth/eslint-config-typescript": "^2.8.3", "@types/node": "^20.16.5", "@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/parser": "^7.18.0", - "eslint": "^8.57.0", - "husky": "^9.1.5", + "eslint": "^8.57.1", + "husky": "^9.1.6", "typescript": "^5.6.2", - "vite": "^5.4.4", - "vitest": "^2.0.5" + "vite": "^5.4.7" }, "packageManager": "pnpm@9.3.0+sha512.ee7b93e0c2bd11409c6424f92b866f31d3ea1bef5fbe47d3c7500cdc3c9668833d2e55681ad66df5b640c61fa9dc25d546efa54d76d7f8bf54b13614ac293631" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b5be99..a17c2f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,47 +9,40 @@ importers: .: devDependencies: '@byloth/eslint-config-typescript': - specifier: ^2.8.2 - version: 2.8.2(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0)(typescript@5.6.2))(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0) + specifier: ^2.8.3 + version: 2.8.3(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.2))(eslint@8.57.1)(typescript@5.6.2))(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.2))(eslint@8.57.1) '@types/node': specifier: ^20.16.5 version: 20.16.5 '@typescript-eslint/eslint-plugin': specifier: ^7.18.0 - version: 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0)(typescript@5.6.2) + version: 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.2))(eslint@8.57.1)(typescript@5.6.2) '@typescript-eslint/parser': specifier: ^7.18.0 - version: 7.18.0(eslint@8.57.0)(typescript@5.6.2) + version: 7.18.0(eslint@8.57.1)(typescript@5.6.2) eslint: - specifier: ^8.57.0 - version: 8.57.0 + specifier: ^8.57.1 + version: 8.57.1 husky: - specifier: ^9.1.5 - version: 9.1.5 + specifier: ^9.1.6 + version: 9.1.6 typescript: specifier: ^5.6.2 version: 5.6.2 vite: - specifier: ^5.4.4 - version: 5.4.4(@types/node@20.16.5) - vitest: - specifier: ^2.0.5 - version: 2.0.5(@types/node@20.16.5) + specifier: ^5.4.7 + version: 5.4.7(@types/node@20.16.5) packages: - '@ampproject/remapping@2.3.0': - resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} - engines: {node: '>=6.0.0'} - - '@byloth/eslint-config-typescript@2.8.2': - resolution: {integrity: sha512-kpBhUJLj5Ckb95nuztZ28mOz0YWsWbOtRZPXiyHduyeYuZQINWweXmE1EJ04KSiRo2CsCyKjWHucfjq2B+KfkA==} + '@byloth/eslint-config-typescript@2.8.3': + resolution: {integrity: sha512-ehhfL1ikSxx0BcRqZM8UbLgtpI22QRuSqbxkXKVNrM/7mEjF8WuD2yn2O2MMxACg+CLWvFDYgG4t2VFUf34S1w==} peerDependencies: '@typescript-eslint/eslint-plugin': ^7.18.0 '@typescript-eslint/parser': ^7.18.0 - '@byloth/eslint-config@2.8.2': - resolution: {integrity: sha512-f5eZYx3CM97ith3Sf32GBIRPp8YLbZWAYPEwI4lJleFaOJi6r4hdoIF4XUqV3HZpJVD1MoLrvXO6pgHUiawHkw==} + '@byloth/eslint-config@2.8.3': + resolution: {integrity: sha512-wJxNanreXPeIiVuQMnxjy7muvjRbiPM/xZ0YHiSnmJ35FOc0QjbjZFnvLhZPntkMOKMwA1/CGT1zKt48lBoVrw==} peerDependencies: eslint: ^8.57.0 @@ -197,20 +190,20 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 - '@eslint-community/regexpp@4.11.0': - resolution: {integrity: sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==} + '@eslint-community/regexpp@4.11.1': + resolution: {integrity: sha512-m4DVN9ZqskZoLU5GlWZadwDnYo3vAEydiUayB9widCl9ffWx2IvPnp6n3on5rJmziJSw9Bv+Z3ChDVdMwXCY8Q==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} '@eslint/eslintrc@2.1.4': resolution: {integrity: sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - '@eslint/js@8.57.0': - resolution: {integrity: sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==} + '@eslint/js@8.57.1': + resolution: {integrity: sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - '@humanwhocodes/config-array@0.11.14': - resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==} + '@humanwhocodes/config-array@0.13.0': + resolution: {integrity: sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==} engines: {node: '>=10.10.0'} deprecated: Use @eslint/config-array instead @@ -222,24 +215,6 @@ packages: resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==} deprecated: Use @eslint/object-schema instead - '@jridgewell/gen-mapping@0.3.5': - resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==} - engines: {node: '>=6.0.0'} - - '@jridgewell/resolve-uri@3.1.2': - resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} - engines: {node: '>=6.0.0'} - - '@jridgewell/set-array@1.2.1': - resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==} - engines: {node: '>=6.0.0'} - - '@jridgewell/sourcemap-codec@1.5.0': - resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} - - '@jridgewell/trace-mapping@0.3.25': - resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -252,83 +227,83 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@rollup/rollup-android-arm-eabi@4.21.2': - resolution: {integrity: sha512-fSuPrt0ZO8uXeS+xP3b+yYTCBUd05MoSp2N/MFOgjhhUhMmchXlpTQrTpI8T+YAwAQuK7MafsCOxW7VrPMrJcg==} + '@rollup/rollup-android-arm-eabi@4.22.4': + resolution: {integrity: sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.21.2': - resolution: {integrity: sha512-xGU5ZQmPlsjQS6tzTTGwMsnKUtu0WVbl0hYpTPauvbRAnmIvpInhJtgjj3mcuJpEiuUw4v1s4BimkdfDWlh7gA==} + '@rollup/rollup-android-arm64@4.22.4': + resolution: {integrity: sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.21.2': - resolution: {integrity: sha512-99AhQ3/ZMxU7jw34Sq8brzXqWH/bMnf7ZVhvLk9QU2cOepbQSVTns6qoErJmSiAvU3InRqC2RRZ5ovh1KN0d0Q==} + '@rollup/rollup-darwin-arm64@4.22.4': + resolution: {integrity: sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.21.2': - resolution: {integrity: sha512-ZbRaUvw2iN/y37x6dY50D8m2BnDbBjlnMPotDi/qITMJ4sIxNY33HArjikDyakhSv0+ybdUxhWxE6kTI4oX26w==} + '@rollup/rollup-darwin-x64@4.22.4': + resolution: {integrity: sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==} cpu: [x64] os: [darwin] - '@rollup/rollup-linux-arm-gnueabihf@4.21.2': - resolution: {integrity: sha512-ztRJJMiE8nnU1YFcdbd9BcH6bGWG1z+jP+IPW2oDUAPxPjo9dverIOyXz76m6IPA6udEL12reYeLojzW2cYL7w==} + '@rollup/rollup-linux-arm-gnueabihf@4.22.4': + resolution: {integrity: sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.21.2': - resolution: {integrity: sha512-flOcGHDZajGKYpLV0JNc0VFH361M7rnV1ee+NTeC/BQQ1/0pllYcFmxpagltANYt8FYf9+kL6RSk80Ziwyhr7w==} + '@rollup/rollup-linux-arm-musleabihf@4.22.4': + resolution: {integrity: sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.21.2': - resolution: {integrity: sha512-69CF19Kp3TdMopyteO/LJbWufOzqqXzkrv4L2sP8kfMaAQ6iwky7NoXTp7bD6/irKgknDKM0P9E/1l5XxVQAhw==} + '@rollup/rollup-linux-arm64-gnu@4.22.4': + resolution: {integrity: sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-musl@4.21.2': - resolution: {integrity: sha512-48pD/fJkTiHAZTnZwR0VzHrao70/4MlzJrq0ZsILjLW/Ab/1XlVUStYyGt7tdyIiVSlGZbnliqmult/QGA2O2w==} + '@rollup/rollup-linux-arm64-musl@4.22.4': + resolution: {integrity: sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-powerpc64le-gnu@4.21.2': - resolution: {integrity: sha512-cZdyuInj0ofc7mAQpKcPR2a2iu4YM4FQfuUzCVA2u4HI95lCwzjoPtdWjdpDKyHxI0UO82bLDoOaLfpZ/wviyQ==} + '@rollup/rollup-linux-powerpc64le-gnu@4.22.4': + resolution: {integrity: sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==} cpu: [ppc64] os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.21.2': - resolution: {integrity: sha512-RL56JMT6NwQ0lXIQmMIWr1SW28z4E4pOhRRNqwWZeXpRlykRIlEpSWdsgNWJbYBEWD84eocjSGDu/XxbYeCmwg==} + '@rollup/rollup-linux-riscv64-gnu@4.22.4': + resolution: {integrity: sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.21.2': - resolution: {integrity: sha512-PMxkrWS9z38bCr3rWvDFVGD6sFeZJw4iQlhrup7ReGmfn7Oukrr/zweLhYX6v2/8J6Cep9IEA/SmjXjCmSbrMQ==} + '@rollup/rollup-linux-s390x-gnu@4.22.4': + resolution: {integrity: sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==} cpu: [s390x] os: [linux] - '@rollup/rollup-linux-x64-gnu@4.21.2': - resolution: {integrity: sha512-B90tYAUoLhU22olrafY3JQCFLnT3NglazdwkHyxNDYF/zAxJt5fJUB/yBoWFoIQ7SQj+KLe3iL4BhOMa9fzgpw==} + '@rollup/rollup-linux-x64-gnu@4.22.4': + resolution: {integrity: sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==} cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-musl@4.21.2': - resolution: {integrity: sha512-7twFizNXudESmC9oneLGIUmoHiiLppz/Xs5uJQ4ShvE6234K0VB1/aJYU3f/4g7PhssLGKBVCC37uRkkOi8wjg==} + '@rollup/rollup-linux-x64-musl@4.22.4': + resolution: {integrity: sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==} cpu: [x64] os: [linux] - '@rollup/rollup-win32-arm64-msvc@4.21.2': - resolution: {integrity: sha512-9rRero0E7qTeYf6+rFh3AErTNU1VCQg2mn7CQcI44vNUWM9Ze7MSRS/9RFuSsox+vstRt97+x3sOhEey024FRQ==} + '@rollup/rollup-win32-arm64-msvc@4.22.4': + resolution: {integrity: sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.21.2': - resolution: {integrity: sha512-5rA4vjlqgrpbFVVHX3qkrCo/fZTj1q0Xxpg+Z7yIo3J2AilW7t2+n6Q8Jrx+4MrYpAnjttTYF8rr7bP46BPzRw==} + '@rollup/rollup-win32-ia32-msvc@4.22.4': + resolution: {integrity: sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.21.2': - resolution: {integrity: sha512-6UUxd0+SKomjdzuAcp+HAmxw1FlGBnl1v2yEPSabtx4lBfdXHDVsW7+lQkgz9cNFJGY3AWR7+V8P5BqkD9L9nA==} + '@rollup/rollup-win32-x64-msvc@4.22.4': + resolution: {integrity: sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==} cpu: [x64] os: [win32] @@ -399,24 +374,6 @@ packages: '@ungap/structured-clone@1.2.0': resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} - '@vitest/expect@2.0.5': - resolution: {integrity: sha512-yHZtwuP7JZivj65Gxoi8upUN2OzHTi3zVfjwdpu2WrvCZPLwsJ2Ey5ILIPccoW23dd/zQBlJ4/dhi7DWNyXCpA==} - - '@vitest/pretty-format@2.0.5': - resolution: {integrity: sha512-h8k+1oWHfwTkyTkb9egzwNMfJAEx4veaPSnMeKbVSjp4euqGSbQlm5+6VHwTr7u4FJslVVsUG5nopCaAYdOmSQ==} - - '@vitest/runner@2.0.5': - resolution: {integrity: sha512-TfRfZa6Bkk9ky4tW0z20WKXFEwwvWhRY+84CnSEtq4+3ZvDlJyY32oNTJtM7AW9ihW90tX/1Q78cb6FjoAs+ig==} - - '@vitest/snapshot@2.0.5': - resolution: {integrity: sha512-SgCPUeDFLaM0mIUHfaArq8fD2WbaXG/zVXjRupthYfYGzc8ztbFbu6dUNOblBG7XLMR1kEhS/DNnfCZ2IhdDew==} - - '@vitest/spy@2.0.5': - resolution: {integrity: sha512-c/jdthAhvJdpfVuaexSrnawxZz6pywlTPe84LUB2m/4t3rl2fTo9NFGBG4oWgaD+FTgDDV8hJ/nibT7IfH3JfA==} - - '@vitest/utils@2.0.5': - resolution: {integrity: sha512-d8HKbqIcya+GR67mkZbrzhS5kKhtp8dQLcmRZLGTscGVg7yImT82cIrhtn2L8+VujWcy6KZweApgNmPsTAO/UQ==} - acorn-jsx@5.3.2: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -445,10 +402,6 @@ packages: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} engines: {node: '>=8'} - assertion-error@2.0.1: - resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} - engines: {node: '>=12'} - balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -462,26 +415,14 @@ packages: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} - cac@6.7.14: - resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} - engines: {node: '>=8'} - callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} - chai@5.1.1: - resolution: {integrity: sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==} - engines: {node: '>=12'} - chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} - check-error@2.1.1: - resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} - engines: {node: '>= 16'} - color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} @@ -505,10 +446,6 @@ packages: supports-color: optional: true - deep-eql@5.0.2: - resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} - engines: {node: '>=6'} - deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} @@ -537,8 +474,8 @@ packages: resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - eslint@8.57.0: - resolution: {integrity: sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==} + eslint@8.57.1: + resolution: {integrity: sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true @@ -558,17 +495,10 @@ packages: resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} engines: {node: '>=4.0'} - estree-walker@3.0.3: - resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} - esutils@2.0.3: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} - execa@8.0.1: - resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} - engines: {node: '>=16.17'} - fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} @@ -612,13 +542,6 @@ packages: engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] - get-func-name@2.0.2: - resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==} - - get-stream@8.0.1: - resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} - engines: {node: '>=16'} - glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -646,12 +569,8 @@ packages: resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} engines: {node: '>=8'} - human-signals@5.0.0: - resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} - engines: {node: '>=16.17.0'} - - husky@9.1.5: - resolution: {integrity: sha512-rowAVRUBfI0b4+niA4SJMhfQwc107VLkBUgEYYAOQAbqDCnra1nYh83hF/MDmhYs9t9n1E3DuKOrs2LYNC+0Ag==} + husky@9.1.6: + resolution: {integrity: sha512-sqbjZKK7kf44hfdE94EoX8MZNk0n7HeW37O4YrVGCF4wzgQjp+akPAkfUK5LZ6KuR/6sqeAVuXHji+RzQgOn5A==} engines: {node: '>=18'} hasBin: true @@ -690,10 +609,6 @@ packages: resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} engines: {node: '>=8'} - is-stream@3.0.0: - resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} @@ -724,15 +639,6 @@ packages: lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} - loupe@3.1.1: - resolution: {integrity: sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==} - - magic-string@0.30.11: - resolution: {integrity: sha512-+Wri9p0QHMy+545hKww7YAu5NyzF8iomPL/RQazugQ9+Ez4Ic3mERMd8ZTX5rfK944j+560ZJi8iAwgak1Ac7A==} - - merge-stream@2.0.0: - resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} - merge2@1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} @@ -741,10 +647,6 @@ packages: resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} - mimic-fn@4.0.0: - resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} - engines: {node: '>=12'} - minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} @@ -763,17 +665,9 @@ packages: natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} - npm-run-path@5.3.0: - resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} - onetime@6.0.0: - resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} - engines: {node: '>=12'} - optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} @@ -802,21 +696,10 @@ packages: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} - path-key@4.0.0: - resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} - engines: {node: '>=12'} - path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} - pathe@1.1.2: - resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} - - pathval@2.0.0: - resolution: {integrity: sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==} - engines: {node: '>= 14.16'} - picocolors@1.1.0: resolution: {integrity: sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==} @@ -824,8 +707,8 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - postcss@8.4.45: - resolution: {integrity: sha512-7KTLTdzdZZYscUc65XmjFiB73vBhBfbPztCYdUNvlaso9PrzjzcmjqBPR0lNGkcVlcO4BjiO5rK/qNz+XAen1Q==} + postcss@8.4.47: + resolution: {integrity: sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==} engines: {node: ^10 || ^12 || >=14} prelude-ls@1.2.1: @@ -852,8 +735,8 @@ packages: deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true - rollup@4.21.2: - resolution: {integrity: sha512-e3TapAgYf9xjdLvKQCkQTnbTKd4a6jwlpQSJJFokHGaX2IVjoEqkIIhiQfqsi0cdwlOD+tQGuOd5AJkc5RngBw==} + rollup@4.22.4: + resolution: {integrity: sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true @@ -873,13 +756,6 @@ packages: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} - siginfo@2.0.0: - resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} - - signal-exit@4.1.0: - resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} - engines: {node: '>=14'} - slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -888,20 +764,10 @@ packages: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} - stackback@0.0.2: - resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} - - std-env@3.7.0: - resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} - strip-ansi@6.0.1: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} - strip-final-newline@3.0.0: - resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} - engines: {node: '>=12'} - strip-json-comments@3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} @@ -913,21 +779,6 @@ packages: text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} - tinybench@2.9.0: - resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} - - tinypool@1.0.1: - resolution: {integrity: sha512-URZYihUbRPcGv95En+sz6MfghfIc2OJ1sv/RmhWZLouPY0/8Vo80viwPvg3dlaS9fuq7fQMEfgRRK7BBZThBEA==} - engines: {node: ^18.0.0 || >=20.0.0} - - tinyrainbow@1.2.0: - resolution: {integrity: sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==} - engines: {node: '>=14.0.0'} - - tinyspy@3.0.2: - resolution: {integrity: sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==} - engines: {node: '>=14.0.0'} - to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -957,13 +808,8 @@ packages: uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} - vite-node@2.0.5: - resolution: {integrity: sha512-LdsW4pxj0Ot69FAoXZ1yTnA9bjGohr2yNBU7QKRxpz8ITSkhuDl6h3zS/tvgz4qrNjeRnvrWeXQ8ZF7Um4W00Q==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - - vite@5.4.4: - resolution: {integrity: sha512-RHFCkULitycHVTtelJ6jQLd+KSAAzOgEYorV32R2q++M6COBjKJR6BxqClwp5sf0XaBDjVMuJ9wnNfyAJwjMkA==} + vite@5.4.7: + resolution: {integrity: sha512-5l2zxqMEPVENgvzTuBpHer2awaetimj2BGkhBPdnwKbPNOlHsODU+oiazEZzLK7KhAnOrO+XGYJYn4ZlUhDtDQ==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -993,41 +839,11 @@ packages: terser: optional: true - vitest@2.0.5: - resolution: {integrity: sha512-8GUxONfauuIdeSl5f9GTgVEpg5BTOlplET4WEDaeY2QBiN8wSm68vxN/tb5z405OwppfoCavnwXafiaYBC/xOA==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@edge-runtime/vm': '*' - '@types/node': ^18.0.0 || >=20.0.0 - '@vitest/browser': 2.0.5 - '@vitest/ui': 2.0.5 - happy-dom: '*' - jsdom: '*' - peerDependenciesMeta: - '@edge-runtime/vm': - optional: true - '@types/node': - optional: true - '@vitest/browser': - optional: true - '@vitest/ui': - optional: true - happy-dom: - optional: true - jsdom: - optional: true - which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} hasBin: true - why-is-node-running@2.3.0: - resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} - engines: {node: '>=8'} - hasBin: true - word-wrap@1.2.5: resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} engines: {node: '>=0.10.0'} @@ -1041,22 +857,17 @@ packages: snapshots: - '@ampproject/remapping@2.3.0': + '@byloth/eslint-config-typescript@2.8.3(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.2))(eslint@8.57.1)(typescript@5.6.2))(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.2))(eslint@8.57.1)': dependencies: - '@jridgewell/gen-mapping': 0.3.5 - '@jridgewell/trace-mapping': 0.3.25 - - '@byloth/eslint-config-typescript@2.8.2(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0)(typescript@5.6.2))(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0)': - dependencies: - '@byloth/eslint-config': 2.8.2(eslint@8.57.0) - '@typescript-eslint/eslint-plugin': 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0)(typescript@5.6.2) - '@typescript-eslint/parser': 7.18.0(eslint@8.57.0)(typescript@5.6.2) + '@byloth/eslint-config': 2.8.3(eslint@8.57.1) + '@typescript-eslint/eslint-plugin': 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.2))(eslint@8.57.1)(typescript@5.6.2) + '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.6.2) transitivePeerDependencies: - eslint - '@byloth/eslint-config@2.8.2(eslint@8.57.0)': + '@byloth/eslint-config@2.8.3(eslint@8.57.1)': dependencies: - eslint: 8.57.0 + eslint: 8.57.1 '@esbuild/aix-ppc64@0.21.5': optional: true @@ -1127,12 +938,12 @@ snapshots: '@esbuild/win32-x64@0.21.5': optional: true - '@eslint-community/eslint-utils@4.4.0(eslint@8.57.0)': + '@eslint-community/eslint-utils@4.4.0(eslint@8.57.1)': dependencies: - eslint: 8.57.0 + eslint: 8.57.1 eslint-visitor-keys: 3.4.3 - '@eslint-community/regexpp@4.11.0': {} + '@eslint-community/regexpp@4.11.1': {} '@eslint/eslintrc@2.1.4': dependencies: @@ -1148,9 +959,9 @@ snapshots: transitivePeerDependencies: - supports-color - '@eslint/js@8.57.0': {} + '@eslint/js@8.57.1': {} - '@humanwhocodes/config-array@0.11.14': + '@humanwhocodes/config-array@0.13.0': dependencies: '@humanwhocodes/object-schema': 2.0.3 debug: 4.3.7 @@ -1162,23 +973,6 @@ snapshots: '@humanwhocodes/object-schema@2.0.3': {} - '@jridgewell/gen-mapping@0.3.5': - dependencies: - '@jridgewell/set-array': 1.2.1 - '@jridgewell/sourcemap-codec': 1.5.0 - '@jridgewell/trace-mapping': 0.3.25 - - '@jridgewell/resolve-uri@3.1.2': {} - - '@jridgewell/set-array@1.2.1': {} - - '@jridgewell/sourcemap-codec@1.5.0': {} - - '@jridgewell/trace-mapping@0.3.25': - dependencies: - '@jridgewell/resolve-uri': 3.1.2 - '@jridgewell/sourcemap-codec': 1.5.0 - '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -1191,52 +985,52 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.17.1 - '@rollup/rollup-android-arm-eabi@4.21.2': + '@rollup/rollup-android-arm-eabi@4.22.4': optional: true - '@rollup/rollup-android-arm64@4.21.2': + '@rollup/rollup-android-arm64@4.22.4': optional: true - '@rollup/rollup-darwin-arm64@4.21.2': + '@rollup/rollup-darwin-arm64@4.22.4': optional: true - '@rollup/rollup-darwin-x64@4.21.2': + '@rollup/rollup-darwin-x64@4.22.4': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.21.2': + '@rollup/rollup-linux-arm-gnueabihf@4.22.4': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.21.2': + '@rollup/rollup-linux-arm-musleabihf@4.22.4': optional: true - '@rollup/rollup-linux-arm64-gnu@4.21.2': + '@rollup/rollup-linux-arm64-gnu@4.22.4': optional: true - '@rollup/rollup-linux-arm64-musl@4.21.2': + '@rollup/rollup-linux-arm64-musl@4.22.4': optional: true - '@rollup/rollup-linux-powerpc64le-gnu@4.21.2': + '@rollup/rollup-linux-powerpc64le-gnu@4.22.4': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.21.2': + '@rollup/rollup-linux-riscv64-gnu@4.22.4': optional: true - '@rollup/rollup-linux-s390x-gnu@4.21.2': + '@rollup/rollup-linux-s390x-gnu@4.22.4': optional: true - '@rollup/rollup-linux-x64-gnu@4.21.2': + '@rollup/rollup-linux-x64-gnu@4.22.4': optional: true - '@rollup/rollup-linux-x64-musl@4.21.2': + '@rollup/rollup-linux-x64-musl@4.22.4': optional: true - '@rollup/rollup-win32-arm64-msvc@4.21.2': + '@rollup/rollup-win32-arm64-msvc@4.22.4': optional: true - '@rollup/rollup-win32-ia32-msvc@4.21.2': + '@rollup/rollup-win32-ia32-msvc@4.22.4': optional: true - '@rollup/rollup-win32-x64-msvc@4.21.2': + '@rollup/rollup-win32-x64-msvc@4.22.4': optional: true '@types/estree@1.0.5': {} @@ -1245,15 +1039,15 @@ snapshots: dependencies: undici-types: 6.19.8 - '@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0)(typescript@5.6.2)': + '@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.2))(eslint@8.57.1)(typescript@5.6.2)': dependencies: - '@eslint-community/regexpp': 4.11.0 - '@typescript-eslint/parser': 7.18.0(eslint@8.57.0)(typescript@5.6.2) + '@eslint-community/regexpp': 4.11.1 + '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.6.2) '@typescript-eslint/scope-manager': 7.18.0 - '@typescript-eslint/type-utils': 7.18.0(eslint@8.57.0)(typescript@5.6.2) - '@typescript-eslint/utils': 7.18.0(eslint@8.57.0)(typescript@5.6.2) + '@typescript-eslint/type-utils': 7.18.0(eslint@8.57.1)(typescript@5.6.2) + '@typescript-eslint/utils': 7.18.0(eslint@8.57.1)(typescript@5.6.2) '@typescript-eslint/visitor-keys': 7.18.0 - eslint: 8.57.0 + eslint: 8.57.1 graphemer: 1.4.0 ignore: 5.3.2 natural-compare: 1.4.0 @@ -1263,14 +1057,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.6.2)': + '@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.2)': dependencies: '@typescript-eslint/scope-manager': 7.18.0 '@typescript-eslint/types': 7.18.0 '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.6.2) '@typescript-eslint/visitor-keys': 7.18.0 debug: 4.3.7 - eslint: 8.57.0 + eslint: 8.57.1 optionalDependencies: typescript: 5.6.2 transitivePeerDependencies: @@ -1281,12 +1075,12 @@ snapshots: '@typescript-eslint/types': 7.18.0 '@typescript-eslint/visitor-keys': 7.18.0 - '@typescript-eslint/type-utils@7.18.0(eslint@8.57.0)(typescript@5.6.2)': + '@typescript-eslint/type-utils@7.18.0(eslint@8.57.1)(typescript@5.6.2)': dependencies: '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.6.2) - '@typescript-eslint/utils': 7.18.0(eslint@8.57.0)(typescript@5.6.2) + '@typescript-eslint/utils': 7.18.0(eslint@8.57.1)(typescript@5.6.2) debug: 4.3.7 - eslint: 8.57.0 + eslint: 8.57.1 ts-api-utils: 1.3.0(typescript@5.6.2) optionalDependencies: typescript: 5.6.2 @@ -1310,13 +1104,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@7.18.0(eslint@8.57.0)(typescript@5.6.2)': + '@typescript-eslint/utils@7.18.0(eslint@8.57.1)(typescript@5.6.2)': dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.1) '@typescript-eslint/scope-manager': 7.18.0 '@typescript-eslint/types': 7.18.0 '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.6.2) - eslint: 8.57.0 + eslint: 8.57.1 transitivePeerDependencies: - supports-color - typescript @@ -1328,39 +1122,6 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitest/expect@2.0.5': - dependencies: - '@vitest/spy': 2.0.5 - '@vitest/utils': 2.0.5 - chai: 5.1.1 - tinyrainbow: 1.2.0 - - '@vitest/pretty-format@2.0.5': - dependencies: - tinyrainbow: 1.2.0 - - '@vitest/runner@2.0.5': - dependencies: - '@vitest/utils': 2.0.5 - pathe: 1.1.2 - - '@vitest/snapshot@2.0.5': - dependencies: - '@vitest/pretty-format': 2.0.5 - magic-string: 0.30.11 - pathe: 1.1.2 - - '@vitest/spy@2.0.5': - dependencies: - tinyspy: 3.0.2 - - '@vitest/utils@2.0.5': - dependencies: - '@vitest/pretty-format': 2.0.5 - estree-walker: 3.0.3 - loupe: 3.1.1 - tinyrainbow: 1.2.0 - acorn-jsx@5.3.2(acorn@8.12.1): dependencies: acorn: 8.12.1 @@ -1384,8 +1145,6 @@ snapshots: array-union@2.1.0: {} - assertion-error@2.0.1: {} - balanced-match@1.0.2: {} brace-expansion@1.1.11: @@ -1401,25 +1160,13 @@ snapshots: dependencies: fill-range: 7.1.1 - cac@6.7.14: {} - callsites@3.1.0: {} - chai@5.1.1: - dependencies: - assertion-error: 2.0.1 - check-error: 2.1.1 - deep-eql: 5.0.2 - loupe: 3.1.1 - pathval: 2.0.0 - chalk@4.1.2: dependencies: ansi-styles: 4.3.0 supports-color: 7.2.0 - check-error@2.1.1: {} - color-convert@2.0.1: dependencies: color-name: 1.1.4 @@ -1438,8 +1185,6 @@ snapshots: dependencies: ms: 2.1.3 - deep-eql@5.0.2: {} - deep-is@0.1.4: {} dir-glob@3.0.1: @@ -1485,13 +1230,13 @@ snapshots: eslint-visitor-keys@3.4.3: {} - eslint@8.57.0: + eslint@8.57.1: dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) - '@eslint-community/regexpp': 4.11.0 + '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.1) + '@eslint-community/regexpp': 4.11.1 '@eslint/eslintrc': 2.1.4 - '@eslint/js': 8.57.0 - '@humanwhocodes/config-array': 0.11.14 + '@eslint/js': 8.57.1 + '@humanwhocodes/config-array': 0.13.0 '@humanwhocodes/module-importer': 1.0.1 '@nodelib/fs.walk': 1.2.8 '@ungap/structured-clone': 1.2.0 @@ -1544,24 +1289,8 @@ snapshots: estraverse@5.3.0: {} - estree-walker@3.0.3: - dependencies: - '@types/estree': 1.0.5 - esutils@2.0.3: {} - execa@8.0.1: - dependencies: - cross-spawn: 7.0.3 - get-stream: 8.0.1 - human-signals: 5.0.0 - is-stream: 3.0.0 - merge-stream: 2.0.0 - npm-run-path: 5.3.0 - onetime: 6.0.0 - signal-exit: 4.1.0 - strip-final-newline: 3.0.0 - fast-deep-equal@3.1.3: {} fast-glob@3.3.2: @@ -1606,10 +1335,6 @@ snapshots: fsevents@2.3.3: optional: true - get-func-name@2.0.2: {} - - get-stream@8.0.1: {} - glob-parent@5.1.2: dependencies: is-glob: 4.0.3 @@ -1644,9 +1369,7 @@ snapshots: has-flag@4.0.0: {} - human-signals@5.0.0: {} - - husky@9.1.5: {} + husky@9.1.6: {} ignore@5.3.2: {} @@ -1674,8 +1397,6 @@ snapshots: is-path-inside@3.0.3: {} - is-stream@3.0.0: {} - isexe@2.0.0: {} js-yaml@4.1.0: @@ -1703,16 +1424,6 @@ snapshots: lodash.merge@4.6.2: {} - loupe@3.1.1: - dependencies: - get-func-name: 2.0.2 - - magic-string@0.30.11: - dependencies: - '@jridgewell/sourcemap-codec': 1.5.0 - - merge-stream@2.0.0: {} - merge2@1.4.1: {} micromatch@4.0.8: @@ -1720,8 +1431,6 @@ snapshots: braces: 3.0.3 picomatch: 2.3.1 - mimic-fn@4.0.0: {} - minimatch@3.1.2: dependencies: brace-expansion: 1.1.11 @@ -1736,18 +1445,10 @@ snapshots: natural-compare@1.4.0: {} - npm-run-path@5.3.0: - dependencies: - path-key: 4.0.0 - once@1.4.0: dependencies: wrappy: 1.0.2 - onetime@6.0.0: - dependencies: - mimic-fn: 4.0.0 - optionator@0.9.4: dependencies: deep-is: 0.1.4 @@ -1775,19 +1476,13 @@ snapshots: path-key@3.1.1: {} - path-key@4.0.0: {} - path-type@4.0.0: {} - pathe@1.1.2: {} - - pathval@2.0.0: {} - picocolors@1.1.0: {} picomatch@2.3.1: {} - postcss@8.4.45: + postcss@8.4.47: dependencies: nanoid: 3.3.7 picocolors: 1.1.0 @@ -1807,26 +1502,26 @@ snapshots: dependencies: glob: 7.2.3 - rollup@4.21.2: + rollup@4.22.4: dependencies: '@types/estree': 1.0.5 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.21.2 - '@rollup/rollup-android-arm64': 4.21.2 - '@rollup/rollup-darwin-arm64': 4.21.2 - '@rollup/rollup-darwin-x64': 4.21.2 - '@rollup/rollup-linux-arm-gnueabihf': 4.21.2 - '@rollup/rollup-linux-arm-musleabihf': 4.21.2 - '@rollup/rollup-linux-arm64-gnu': 4.21.2 - '@rollup/rollup-linux-arm64-musl': 4.21.2 - '@rollup/rollup-linux-powerpc64le-gnu': 4.21.2 - '@rollup/rollup-linux-riscv64-gnu': 4.21.2 - '@rollup/rollup-linux-s390x-gnu': 4.21.2 - '@rollup/rollup-linux-x64-gnu': 4.21.2 - '@rollup/rollup-linux-x64-musl': 4.21.2 - '@rollup/rollup-win32-arm64-msvc': 4.21.2 - '@rollup/rollup-win32-ia32-msvc': 4.21.2 - '@rollup/rollup-win32-x64-msvc': 4.21.2 + '@rollup/rollup-android-arm-eabi': 4.22.4 + '@rollup/rollup-android-arm64': 4.22.4 + '@rollup/rollup-darwin-arm64': 4.22.4 + '@rollup/rollup-darwin-x64': 4.22.4 + '@rollup/rollup-linux-arm-gnueabihf': 4.22.4 + '@rollup/rollup-linux-arm-musleabihf': 4.22.4 + '@rollup/rollup-linux-arm64-gnu': 4.22.4 + '@rollup/rollup-linux-arm64-musl': 4.22.4 + '@rollup/rollup-linux-powerpc64le-gnu': 4.22.4 + '@rollup/rollup-linux-riscv64-gnu': 4.22.4 + '@rollup/rollup-linux-s390x-gnu': 4.22.4 + '@rollup/rollup-linux-x64-gnu': 4.22.4 + '@rollup/rollup-linux-x64-musl': 4.22.4 + '@rollup/rollup-win32-arm64-msvc': 4.22.4 + '@rollup/rollup-win32-ia32-msvc': 4.22.4 + '@rollup/rollup-win32-x64-msvc': 4.22.4 fsevents: 2.3.3 run-parallel@1.2.0: @@ -1841,24 +1536,14 @@ snapshots: shebang-regex@3.0.0: {} - siginfo@2.0.0: {} - - signal-exit@4.1.0: {} - slash@3.0.0: {} source-map-js@1.2.1: {} - stackback@0.0.2: {} - - std-env@3.7.0: {} - strip-ansi@6.0.1: dependencies: ansi-regex: 5.0.1 - strip-final-newline@3.0.0: {} - strip-json-comments@3.1.1: {} supports-color@7.2.0: @@ -1867,14 +1552,6 @@ snapshots: text-table@0.2.0: {} - tinybench@2.9.0: {} - - tinypool@1.0.1: {} - - tinyrainbow@1.2.0: {} - - tinyspy@3.0.2: {} - to-regex-range@5.0.1: dependencies: is-number: 7.0.0 @@ -1897,75 +1574,19 @@ snapshots: dependencies: punycode: 2.3.1 - vite-node@2.0.5(@types/node@20.16.5): - dependencies: - cac: 6.7.14 - debug: 4.3.7 - pathe: 1.1.2 - tinyrainbow: 1.2.0 - vite: 5.4.4(@types/node@20.16.5) - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - - vite@5.4.4(@types/node@20.16.5): + vite@5.4.7(@types/node@20.16.5): dependencies: esbuild: 0.21.5 - postcss: 8.4.45 - rollup: 4.21.2 + postcss: 8.4.47 + rollup: 4.22.4 optionalDependencies: '@types/node': 20.16.5 fsevents: 2.3.3 - vitest@2.0.5(@types/node@20.16.5): - dependencies: - '@ampproject/remapping': 2.3.0 - '@vitest/expect': 2.0.5 - '@vitest/pretty-format': 2.0.5 - '@vitest/runner': 2.0.5 - '@vitest/snapshot': 2.0.5 - '@vitest/spy': 2.0.5 - '@vitest/utils': 2.0.5 - chai: 5.1.1 - debug: 4.3.7 - execa: 8.0.1 - magic-string: 0.30.11 - pathe: 1.1.2 - std-env: 3.7.0 - tinybench: 2.9.0 - tinypool: 1.0.1 - tinyrainbow: 1.2.0 - vite: 5.4.4(@types/node@20.16.5) - vite-node: 2.0.5(@types/node@20.16.5) - why-is-node-running: 2.3.0 - optionalDependencies: - '@types/node': 20.16.5 - transitivePeerDependencies: - - less - - lightningcss - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - which@2.0.2: dependencies: isexe: 2.0.0 - why-is-node-running@2.3.0: - dependencies: - siginfo: 2.0.0 - stackback: 0.0.2 - word-wrap@1.2.5: {} wrappy@1.0.2: {} diff --git a/src/index.ts b/src/index.ts index e117c92..3d7c719 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export const VERSION = "2.0.0-rc.2"; +export const VERSION = "2.0.0-rc.3"; export type { Constructor, Interval, Timeout } from "./core/types.js"; @@ -7,8 +7,6 @@ export { isBrowser, isNode, isWebWorker } from "./helpers.js"; export { AggregatedIterator, AggregatedAsyncIterator, - Aggregator, - AsyncAggregator, Clock, Countdown, DeferredPromise, @@ -40,23 +38,23 @@ export { export type { AsyncGeneratorFunction, - AsyncIterLike, + AsyncIteratorLike, FulfilledHandler, GeneratorFunction, Iteratee, - IterLike, + IteratorLike, JSONArray, JSONObject, JSONValue, - KeyIteratee, - KeyReducer, - KeyTypeGuardIteratee, - MaybeAsyncKeyIteratee, - MaybeAsyncKeyReducer, - MaybeAsyncKeyTypeGuardIteratee, + KeyedIteratee, + KeyedReducer, + KeyedTypeGuardIteratee, + MaybeAsyncKeyedIteratee, + MaybeAsyncKeyedReducer, + MaybeAsyncKeyedTypeGuardIteratee, MaybeAsyncReducer, MaybeAsyncIteratee, - MaybeAsyncIterLike, + MaybeAsyncIteratorLike, MaybeAsyncTypeGuardIteratee, MaybePromise, PromiseExecutor, diff --git a/src/models/aggregators/aggregated-async-iterator.ts b/src/models/aggregators/aggregated-async-iterator.ts index d1b133b..d5b8ad8 100644 --- a/src/models/aggregators/aggregated-async-iterator.ts +++ b/src/models/aggregators/aggregated-async-iterator.ts @@ -1,9 +1,15 @@ import { SmartAsyncIterator } from "../iterators/index.js"; -import type { AsyncGeneratorFunction, GeneratorFunction, MaybeAsyncIterLike } from "../iterators/types.js"; +import type { + GeneratorFunction, + AsyncGeneratorFunction, + MaybeAsyncGeneratorFunction, + MaybeAsyncIteratorLike + +} from "../iterators/types.js"; import type { MaybePromise } from "../types.js"; import ReducedIterator from "./reduced-iterator.js"; -import type { MaybeAsyncKeyIteratee, MaybeAsyncKeyTypeGuardIteratee, MaybeAsyncKeyReducer } from "./types.js"; +import type { MaybeAsyncKeyedIteratee, MaybeAsyncKeyedTypeGuardIteratee, MaybeAsyncKeyedReducer } from "./types.js"; export default class AggregatedAsyncIterator { @@ -15,58 +21,52 @@ export default class AggregatedAsyncIterator public constructor(iterator: AsyncIterator<[K, T]>); public constructor(generatorFn: GeneratorFunction<[K, T]>); public constructor(generatorFn: AsyncGeneratorFunction<[K, T]>); - public constructor(argument: MaybeAsyncIterLike<[K, T]>); - public constructor(argument: MaybeAsyncIterLike<[K, T]>) + public constructor(argument: MaybeAsyncIteratorLike<[K, T]> | MaybeAsyncGeneratorFunction<[K, T]>); + public constructor(argument: MaybeAsyncIteratorLike<[K, T]> | MaybeAsyncGeneratorFunction<[K, T]>) { this._elements = new SmartAsyncIterator(argument); } - public async every(predicate: MaybeAsyncKeyIteratee): Promise> + public async every(predicate: MaybeAsyncKeyedIteratee): Promise> { - const indexes = new Map(); + const values = new Map(); for await (const [key, element] of this._elements) { - const [index, result] = indexes.get(key) ?? [0, true]; + const [index, result] = values.get(key) ?? [0, true]; if (!(result)) { continue; } - indexes.set(key, [index + 1, await predicate(key, element, index)]); + values.set(key, [index + 1, await predicate(key, element, index)]); } return new ReducedIterator(function* () { - for (const [key, [_, result]] of indexes) - { - yield [key, result]; - } + for (const [key, [_, result]] of values) { yield [key, result]; } }); } - public async some(predicate: MaybeAsyncKeyIteratee): Promise> + public async some(predicate: MaybeAsyncKeyedIteratee): Promise> { - const indexes = new Map(); + const values = new Map(); for await (const [key, element] of this._elements) { - const [index, result] = indexes.get(key) ?? [0, false]; + const [index, result] = values.get(key) ?? [0, false]; if (result) { continue; } - indexes.set(key, [index + 1, await predicate(key, element, index)]); + values.set(key, [index + 1, await predicate(key, element, index)]); } return new ReducedIterator(function* () { - for (const [key, [_, result]] of indexes) - { - yield [key, result]; - } + for (const [key, [_, result]] of values) { yield [key, result]; } }); } - public filter(predicate: MaybeAsyncKeyIteratee): AggregatedAsyncIterator; - public filter(predicate: MaybeAsyncKeyTypeGuardIteratee): AggregatedAsyncIterator; - public filter(predicate: MaybeAsyncKeyIteratee): AggregatedAsyncIterator + public filter(predicate: MaybeAsyncKeyedIteratee): AggregatedAsyncIterator; + public filter(predicate: MaybeAsyncKeyedTypeGuardIteratee): AggregatedAsyncIterator; + public filter(predicate: MaybeAsyncKeyedIteratee): AggregatedAsyncIterator { const elements = this._elements; @@ -78,13 +78,13 @@ export default class AggregatedAsyncIterator { const index = indexes.get(key) ?? 0; - indexes.set(key, index + 1); - if (await predicate(key, element, index)) { yield [key, element]; } + + indexes.set(key, index + 1); } }); } - public map(iteratee: MaybeAsyncKeyIteratee): AggregatedAsyncIterator + public map(iteratee: MaybeAsyncKeyedIteratee): AggregatedAsyncIterator { const elements = this._elements; @@ -96,31 +96,26 @@ export default class AggregatedAsyncIterator { const index = indexes.get(key) ?? 0; - indexes.set(key, index + 1); - yield [key, await iteratee(key, element, index)]; + + indexes.set(key, index + 1); } }); } - public async reduce(reducer: MaybeAsyncKeyReducer): Promise>; - public async reduce(reducer: MaybeAsyncKeyReducer, initialValue: (key: K) => MaybePromise) + public async reduce(reducer: MaybeAsyncKeyedReducer): Promise>; + public async reduce(reducer: MaybeAsyncKeyedReducer, initialValue: (key: K) => MaybePromise) : Promise>; - public async reduce(reducer: MaybeAsyncKeyReducer, initialValue?: (key: K) => MaybePromise) + public async reduce(reducer: MaybeAsyncKeyedReducer, initialValue?: (key: K) => MaybePromise) : Promise> { - const accumulators = new Map(); + const values = new Map(); for await (const [key, element] of this._elements) { let index: number; let accumulator: A; - if (accumulators.has(key)) - { - [index, accumulator] = accumulators.get(key)!; - - index += 1; - } + if (values.has(key)) { [index, accumulator] = values.get(key)!; } else if (initialValue !== undefined) { index = 0; @@ -128,103 +123,164 @@ export default class AggregatedAsyncIterator } else { - accumulators.set(key, [0, (element as unknown) as A]); + values.set(key, [0, (element as unknown) as A]); continue; } - accumulator = await reducer(key, accumulator, element, index); - - accumulators.set(key, [index, accumulator]); + values.set(key, [index + 1, await reducer(key, accumulator, element, index)]); } return new ReducedIterator(function* () { - for (const [key, [_, accumulator]] of accumulators) + for (const [key, [_, accumulator]] of values) { yield [key, accumulator]; } + }); + } + + public flatMap(iteratee: MaybeAsyncKeyedIteratee>): AggregatedAsyncIterator + { + const elements = this._elements; + + return new AggregatedAsyncIterator(async function* (): AsyncGenerator<[K, V]> + { + const indexes = new Map(); + + for await (const [key, element] of elements) { - yield [key, accumulator]; + const index = indexes.get(key) ?? 0; + const values = await iteratee(key, element, index); + + for await (const value of values) { yield [key, value]; } + + indexes.set(key, index + 1); } }); } - public unique(): AggregatedAsyncIterator + public drop(count: number): AggregatedAsyncIterator { const elements = this._elements; return new AggregatedAsyncIterator(async function* (): AsyncGenerator<[K, T]> { - const keys = new Map>(); + const indexes = new Map(); for await (const [key, element] of elements) { - const values = keys.get(key) ?? new Set(); - - if (values.has(element)) { continue; } + const index = indexes.get(key) ?? 0; + if (index < count) + { + indexes.set(key, index + 1); - values.add(element); - keys.set(key, values); + continue; + } yield [key, element]; } }); } - - public async count(): Promise> + public take(limit: number): AggregatedAsyncIterator { - const counters = new Map(); + const elements = this._elements; - for await (const [key] of this._elements) + return new AggregatedAsyncIterator(async function* (): AsyncGenerator<[K, T]> { - const count = counters.get(key) ?? 0; - - counters.set(key, count + 1); - } + const indexes = new Map(); - return new ReducedIterator(function* () - { - for (const [key, count] of counters) + for await (const [key, element] of elements) { - yield [key, count]; + const index = indexes.get(key) ?? 0; + if (index >= limit) + { + if (indexes.values().every((value) => value >= limit)) { break; } + + continue; + } + + yield [key, element]; + + indexes.set(key, index + 1); } }); } - public async first(): Promise> + + public async find(predicate: MaybeAsyncKeyedIteratee): Promise>; + public async find(predicate: MaybeAsyncKeyedTypeGuardIteratee) + : Promise>; + + public async find(predicate: MaybeAsyncKeyedIteratee): Promise> { - const firsts = new Map(); + const values = new Map(); for await (const [key, element] of this._elements) { - if (firsts.has(key)) { continue; } + let [index, finding] = values.get(key) ?? [0, undefined]; - firsts.set(key, element); + if (finding !== undefined) { continue; } + if (await predicate(key, element, index)) { finding = element; } + + values.set(key, [index + 1, finding]); } return new ReducedIterator(function* () { - for (const [key, element] of firsts) + for (const [key, [_, finding]] of values) { yield [key, finding]; } + }); + } + + public unique(): AggregatedAsyncIterator + { + const elements = this._elements; + + return new AggregatedAsyncIterator(async function* (): AsyncGenerator<[K, T]> + { + const keys = new Map>(); + + for await (const [key, element] of elements) { + const values = keys.get(key) ?? new Set(); + + if (values.has(element)) { continue; } + + values.add(element); + keys.set(key, values); + yield [key, element]; } }); } - public async last(): Promise> + + public async count(): Promise> { - const lasts = new Map(); + const counters = new Map(); - for await (const [key, element] of this._elements) + for await (const [key] of this._elements) { - lasts.set(key, element); + const count = counters.get(key) ?? 0; + + counters.set(key, count + 1); } return new ReducedIterator(function* () { - for (const [key, element] of lasts) - { - yield [key, element]; - } + for (const [key, count] of counters) { yield [key, count]; } }); } + public async forEach(iteratee: MaybeAsyncKeyedIteratee): Promise + { + const indexes = new Map(); + + for await (const [key, element] of this._elements) + { + const index = indexes.get(key) ?? 0; + + iteratee(key, element, index); + + indexes.set(key, index + 1); + } + } + public keys(): SmartAsyncIterator { const elements = this._elements; @@ -252,10 +308,7 @@ export default class AggregatedAsyncIterator return new SmartAsyncIterator(async function* () { - for await (const [_, element] of elements) - { - yield element; - } + for await (const [_, element] of elements) { yield element; } }); } diff --git a/src/models/aggregators/aggregated-iterator.ts b/src/models/aggregators/aggregated-iterator.ts index c36adf4..97074fa 100644 --- a/src/models/aggregators/aggregated-iterator.ts +++ b/src/models/aggregators/aggregated-iterator.ts @@ -1,8 +1,8 @@ import { SmartIterator } from "../iterators/index.js"; -import type { GeneratorFunction } from "../iterators/types.js"; +import type { GeneratorFunction, IteratorLike } from "../iterators/types.js"; import ReducedIterator from "./reduced-iterator.js"; -import type { KeyIteratee, KeyTypeGuardIteratee, KeyReducer } from "./types.js"; +import type { KeyedIteratee, KeyedTypeGuardIteratee, KeyedReducer } from "./types.js"; export default class AggregatedIterator { @@ -11,58 +11,52 @@ export default class AggregatedIterator public constructor(iterable: Iterable<[K, T]>); public constructor(iterator: Iterator<[K, T]>); public constructor(generatorFn: GeneratorFunction<[K, T]>); - public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>); - public constructor(argument: Iterable<[K, T]> | Iterator<[K, T]> | GeneratorFunction<[K, T]>) + public constructor(argument: IteratorLike<[K, T]> | GeneratorFunction<[K, T]>); + public constructor(argument: IteratorLike<[K, T]> | GeneratorFunction<[K, T]>) { this._elements = new SmartIterator(argument); } - public every(predicate: KeyIteratee): ReducedIterator + public every(predicate: KeyedIteratee): ReducedIterator { - const indexes = new Map(); + const values = new Map(); for (const [key, element] of this._elements) { - const [index, result] = indexes.get(key) ?? [0, true]; + const [index, result] = values.get(key) ?? [0, true]; if (!(result)) { continue; } - indexes.set(key, [index + 1, predicate(key, element, index)]); + values.set(key, [index + 1, predicate(key, element, index)]); } return new ReducedIterator(function* () { - for (const [key, [_, result]] of indexes) - { - yield [key, result]; - } + for (const [key, [_, result]] of values) { yield [key, result]; } }); } - public some(predicate: KeyIteratee): ReducedIterator + public some(predicate: KeyedIteratee): ReducedIterator { - const indexes = new Map(); + const values = new Map(); for (const [key, element] of this._elements) { - const [index, result] = indexes.get(key) ?? [0, false]; + const [index, result] = values.get(key) ?? [0, false]; if (result) { continue; } - indexes.set(key, [index + 1, predicate(key, element, index)]); + values.set(key, [index + 1, predicate(key, element, index)]); } return new ReducedIterator(function* () { - for (const [key, [_, result]] of indexes) - { - yield [key, result]; - } + for (const [key, [_, result]] of values) { yield [key, result]; } }); } - public filter(predicate: KeyIteratee): AggregatedIterator; - public filter(predicate: KeyTypeGuardIteratee): AggregatedIterator; - public filter(predicate: KeyIteratee): AggregatedIterator + public filter(predicate: KeyedIteratee): AggregatedIterator; + public filter(predicate: KeyedTypeGuardIteratee): AggregatedIterator; + public filter(predicate: KeyedIteratee): AggregatedIterator { const elements = this._elements; @@ -74,13 +68,13 @@ export default class AggregatedIterator { const index = indexes.get(key) ?? 0; - indexes.set(key, index + 1); - if (predicate(key, element, index)) { yield [key, element]; } + + indexes.set(key, index + 1); } }); } - public map(iteratee: KeyIteratee): AggregatedIterator + public map(iteratee: KeyedIteratee): AggregatedIterator { const elements = this._elements; @@ -92,29 +86,24 @@ export default class AggregatedIterator { const index = indexes.get(key) ?? 0; - indexes.set(key, index + 1); - yield [key, iteratee(key, element, index)]; + + indexes.set(key, index + 1); } }); } - public reduce(reducer: KeyReducer): ReducedIterator; - public reduce(reducer: KeyReducer, initialValue: (key: K) => A): ReducedIterator; - public reduce(reducer: KeyReducer, initialValue?: (key: K) => A): ReducedIterator + public reduce(reducer: KeyedReducer): ReducedIterator; + public reduce(reducer: KeyedReducer, initialValue: (key: K) => A): ReducedIterator; + public reduce(reducer: KeyedReducer, initialValue?: (key: K) => A): ReducedIterator { - const accumulators = new Map(); + const values = new Map(); for (const [key, element] of this._elements) { let index: number; let accumulator: A; - if (accumulators.has(key)) - { - [index, accumulator] = accumulators.get(key)!; - - index += 1; - } + if (values.has(key)) { [index, accumulator] = values.get(key)!; } else if (initialValue !== undefined) { index = 0; @@ -122,103 +111,166 @@ export default class AggregatedIterator } else { - accumulators.set(key, [0, (element as unknown) as A]); + values.set(key, [0, (element as unknown) as A]); continue; } - accumulator = reducer(key, accumulator, element, index); - - accumulators.set(key, [index, accumulator]); + values.set(key, [index + 1, reducer(key, accumulator, element, index)]); } return new ReducedIterator(function* () { - for (const [key, [_, accumulator]] of accumulators) - { - yield [key, accumulator]; - } + for (const [key, [_, accumulator]] of values) { yield [key, accumulator]; } }); } - public unique(): AggregatedIterator + public flatMap(iteratee: KeyedIteratee>): AggregatedIterator { const elements = this._elements; return new AggregatedIterator(function* () { - const keys = new Map>(); + const indexes = new Map(); for (const [key, element] of elements) { - const values = keys.get(key) ?? new Set(); - - if (values.has(element)) { continue; } + const index = indexes.get(key) ?? 0; + const values = iteratee(key, element, index); - values.add(element); - keys.set(key, values); + for (const value of values) { yield [key, value]; } - yield [key, element]; + indexes.set(key, index + 1); } }); } - public count(): ReducedIterator + public drop(count: number): AggregatedIterator { - const counters = new Map(); + const elements = this._elements; - for (const [key] of this._elements) + return new AggregatedIterator(function* () { - const count = counters.get(key) ?? 0; + const indexes = new Map(); - counters.set(key, count + 1); - } + for (const [key, element] of elements) + { + const index = indexes.get(key) ?? 0; + if (index < count) + { + indexes.set(key, index + 1); - return new ReducedIterator(function* () + continue; + } + + yield [key, element]; + } + }); + } + public take(limit: number): AggregatedIterator + { + const elements = this._elements; + + return new AggregatedIterator(function* () { - for (const [key, count] of counters) + const indexes = new Map(); + + for (const [key, element] of elements) { - yield [key, count]; + const index = indexes.get(key) ?? 0; + if (index >= limit) + { + if (indexes.values().every((value) => value >= limit)) { break; } + + continue; + } + + yield [key, element]; + + indexes.set(key, index + 1); } }); } - public first(): ReducedIterator + + public find(predicate: KeyedIteratee): ReducedIterator; + public find(predicate: KeyedTypeGuardIteratee): ReducedIterator; + public find(predicate: KeyedIteratee): ReducedIterator { - const firsts = new Map(); + const values = new Map(); for (const [key, element] of this._elements) { - if (firsts.has(key)) { continue; } + let [index, finding] = values.get(key) ?? [0, undefined]; + + if (finding !== undefined) { continue; } + if (predicate(key, element, index)) { finding = element; } - firsts.set(key, element); + values.set(key, [index + 1, finding]); } return new ReducedIterator(function* () { - for (const [key, element] of firsts) + for (const [key, [_, finding]] of values) { yield [key, finding]; } + }); + } + + public enumerate(): AggregatedIterator + { + return this.map((_, value, index) => [index, value]); + } + public unique(): AggregatedIterator + { + const elements = this._elements; + + return new AggregatedIterator(function* () + { + const keys = new Map>(); + + for (const [key, element] of elements) { + const values = keys.get(key) ?? new Set(); + + if (values.has(element)) { continue; } + + values.add(element); + keys.set(key, values); + yield [key, element]; } }); } - public last(): ReducedIterator + + public count(): ReducedIterator { - const lasts = new Map(); + const counters = new Map(); - for (const [key, element] of this._elements) + for (const [key] of this._elements) { - lasts.set(key, element); + const count = counters.get(key) ?? 0; + + counters.set(key, count + 1); } return new ReducedIterator(function* () { - for (const [key, element] of lasts) - { - yield [key, element]; - } + for (const [key, count] of counters) { yield [key, count]; } }); } + public forEach(iteratee: KeyedIteratee): void + { + const indexes = new Map(); + + for (const [key, element] of this._elements) + { + const index = indexes.get(key) ?? 0; + + iteratee(key, element, index); + + indexes.set(key, index + 1); + } + } + public keys(): SmartIterator { const elements = this._elements; @@ -246,16 +298,15 @@ export default class AggregatedIterator return new SmartIterator(function* () { - for (const [_, element] of elements) - { - yield element; - } + for (const [_, element] of elements) { yield element; } }); } public toArray(): T[][] { - return Array.from(this.toMap().values()); + const map = this.toMap(); + + return Array.from(map.values()); } public toMap(): Map { diff --git a/src/models/aggregators/aggregator.ts b/src/models/aggregators/aggregator.ts deleted file mode 100644 index 476532d..0000000 --- a/src/models/aggregators/aggregator.ts +++ /dev/null @@ -1,46 +0,0 @@ -import AggregatedIterator from "./aggregated-iterator.js"; - -import { SmartIterator } from "../iterators/index.js"; -import type { GeneratorFunction, Iteratee, IterLike, TypeGuardIteratee } from "../iterators/types.js"; - -export default class Aggregator -{ - protected _elements: SmartIterator; - - public constructor(iterable: Iterable); - public constructor(iterator: Iterator); - public constructor(generatorFn: GeneratorFunction); - public constructor(argument: IterLike); - public constructor(argument: IterLike) - { - this._elements = new SmartIterator(argument); - } - - public filter(predicate: Iteratee): Aggregator; - public filter(predicate: TypeGuardIteratee): Aggregator; - public filter(predicate: Iteratee): Aggregator - { - return new Aggregator(this._elements.filter(predicate)); - } - public map(iteratee: Iteratee): Aggregator - { - return new Aggregator(this._elements.map(iteratee)); - } - - public unique(): Aggregator - { - return new Aggregator(this._elements.unique()); - } - - public groupBy(iteratee: Iteratee): AggregatedIterator - { - return new AggregatedIterator(this._elements.map((element, index) => - { - const key = iteratee(element, index); - - return [key, element] as [K, T]; - })); - } - - public get [Symbol.toStringTag]() { return "Aggregator"; } -} diff --git a/src/models/aggregators/async-aggregator.ts b/src/models/aggregators/async-aggregator.ts deleted file mode 100644 index 796a96e..0000000 --- a/src/models/aggregators/async-aggregator.ts +++ /dev/null @@ -1,56 +0,0 @@ -import AggregatedAsyncIterator from "./aggregated-async-iterator.js"; - -import { SmartAsyncIterator } from "../iterators/index.js"; -import type { - AsyncGeneratorFunction, - GeneratorFunction, - MaybeAsyncIterLike, - MaybeAsyncIteratee, - MaybeAsyncTypeGuardIteratee - -} from "../iterators/types.js"; - -export default class AsyncAggregator -{ - protected _elements: SmartAsyncIterator; - - public constructor(iterable: Iterable); - public constructor(iterable: AsyncIterable); - public constructor(iterator: Iterator); - public constructor(iterator: AsyncIterator); - public constructor(generatorFn: GeneratorFunction); - public constructor(generatorFn: AsyncGeneratorFunction); - public constructor(argument: MaybeAsyncIterLike); - public constructor(argument: MaybeAsyncIterLike) - { - this._elements = new SmartAsyncIterator(argument); - } - - public filter(predicate: MaybeAsyncIteratee): AsyncAggregator; - public filter(predicate: MaybeAsyncTypeGuardIteratee): AsyncAggregator; - public filter(predicate: MaybeAsyncIteratee): AsyncAggregator - { - return new AsyncAggregator(this._elements.filter(predicate)); - } - public map(iteratee: MaybeAsyncIteratee): AsyncAggregator - { - return new AsyncAggregator(this._elements.map(iteratee)); - } - - public unique(): AsyncAggregator - { - return new AsyncAggregator(this._elements.unique()); - } - - public groupBy(iteratee: MaybeAsyncIteratee): AggregatedAsyncIterator - { - return new AggregatedAsyncIterator(this._elements.map(async (element, index) => - { - const key = await iteratee(element, index); - - return [key, element] as [K, T]; - })); - } - - public get [Symbol.toStringTag]() { return "AsyncAggregator"; } -} diff --git a/src/models/aggregators/index.ts b/src/models/aggregators/index.ts index 4c623f6..3404dca 100644 --- a/src/models/aggregators/index.ts +++ b/src/models/aggregators/index.ts @@ -1,7 +1,5 @@ -import Aggregator from "./aggregator.js"; -import AsyncAggregator from "./async-aggregator.js"; import AggregatedIterator from "./aggregated-iterator.js"; import AggregatedAsyncIterator from "./aggregated-async-iterator.js"; import ReducedIterator from "./reduced-iterator.js"; -export { Aggregator, AsyncAggregator, AggregatedIterator, AggregatedAsyncIterator, ReducedIterator }; +export { AggregatedIterator, AggregatedAsyncIterator, ReducedIterator }; diff --git a/src/models/aggregators/reduced-iterator.ts b/src/models/aggregators/reduced-iterator.ts index 9d347af..e520273 100644 --- a/src/models/aggregators/reduced-iterator.ts +++ b/src/models/aggregators/reduced-iterator.ts @@ -2,7 +2,8 @@ import { ValueException } from "../exceptions/index.js"; import { SmartIterator } from "../iterators/index.js"; import type { GeneratorFunction } from "../iterators/types.js"; -import type { KeyIteratee, KeyReducer, KeyTypeGuardIteratee } from "./types.js"; +import AggregatedIterator from "./aggregated-iterator.js"; +import type { KeyedIteratee, KeyedReducer, KeyedTypeGuardIteratee } from "./types.js"; export default class ReducedIterator { @@ -17,56 +18,64 @@ export default class ReducedIterator this._elements = new SmartIterator(argument); } - public filter(predicate: KeyIteratee): ReducedIterator; - public filter(predicate: KeyTypeGuardIteratee): ReducedIterator; - public filter(predicate: KeyIteratee): ReducedIterator + public every(predicate: KeyedIteratee): boolean { - const elements = this._elements; + for (const [index, [key, element]] of this._elements.enumerate()) + { + if (!(predicate(key, element, index))) { return false; } + } + + return true; + } + public some(predicate: KeyedIteratee): boolean + { + for (const [index, [key, element]] of this._elements.enumerate()) + { + if (predicate(key, element, index)) { return true; } + } + + return false; + } + + public filter(predicate: KeyedIteratee): ReducedIterator; + public filter(predicate: KeyedTypeGuardIteratee): ReducedIterator; + public filter(predicate: KeyedIteratee): ReducedIterator + { + const elements = this._elements.enumerate(); return new ReducedIterator(function* () { - for (const [index, [key, element]] of elements.enumerate()) + for (const [index, [key, element]] of elements) { - if (predicate(key, element, index)) - { - yield [key, element]; - } + if (predicate(key, element, index)) { yield [key, element]; } } }); } - public map(iteratee: KeyIteratee): ReducedIterator + public map(iteratee: KeyedIteratee): ReducedIterator { - const elements = this._elements; + const elements = this._elements.enumerate(); return new ReducedIterator(function* () { - for (const [index, [key, element]] of elements.enumerate()) + for (const [index, [key, element]] of elements) { yield [key, iteratee(key, element, index)]; } }); } - public reduce(reducer: KeyReducer): T; - public reduce(reducer: KeyReducer, initialValue: A): A; - public reduce(reducer: KeyReducer, initialValue?: A): A + public reduce(reducer: KeyedReducer): T; + public reduce(reducer: KeyedReducer, initialValue: A): A; + public reduce(reducer: KeyedReducer, initialValue?: A): A { let index = 0; - let accumulator: A; - - if (initialValue !== undefined) + let accumulator = initialValue; + if (accumulator === undefined) { - accumulator = initialValue; - } - else - { - const firstElement = this._elements.next(); - if (firstElement.done) - { - throw new ValueException("Cannot reduce an empty iterator without an initial value."); - } + const result = this._elements.next(); + if (result.done) { throw new ValueException("Cannot reduce an empty iterator without an initial value."); } + accumulator = (result.value[1] as unknown) as A; index += 1; - accumulator = (firstElement.value[1] as unknown) as A; } for (const [key, element] of this._elements) @@ -79,6 +88,85 @@ export default class ReducedIterator return accumulator; } + public flatMap(iteratee: KeyedIteratee>): AggregatedIterator + { + const elements = this._elements.enumerate(); + + return new AggregatedIterator(function* () + { + for (const [index, [key, element]] of elements) + { + for (const value of iteratee(key, element, index)) { yield [key, value]; } + } + }); + } + + public drop(count: number): ReducedIterator + { + const elements = this._elements.enumerate(); + + return new ReducedIterator(function* () + { + for (const [index, [key, element]] of elements) + { + if (index >= count) { yield [key, element]; } + } + }); + } + public take(count: number): ReducedIterator + { + const elements = this._elements.enumerate(); + + return new ReducedIterator(function* () + { + for (const [index, [key, element]] of elements) + { + if (index >= count) { break; } + + yield [key, element]; + } + }); + } + + public enumerate(): ReducedIterator + { + return this.map((_, element, index) => [index, element]); + } + public unique(): ReducedIterator + { + const elements = this._elements; + + return new ReducedIterator(function* () + { + const values = new Set(); + + for (const [key, element] of elements) + { + if (values.has(element)) { continue; } + values.add(element); + + yield [key, element]; + } + }); + } + + public count(): number + { + let index = 0; + + for (const _ of this._elements) { index += 1; } + + return index; + } + + public forEach(iteratee: KeyedIteratee): void + { + for (const [index, [key, element]] of this._elements.enumerate()) + { + iteratee(key, element, index); + } + } + public keys(): SmartIterator { const elements = this._elements; diff --git a/src/models/aggregators/types.ts b/src/models/aggregators/types.ts index 1d51ae8..7236482 100644 --- a/src/models/aggregators/types.ts +++ b/src/models/aggregators/types.ts @@ -1,14 +1,19 @@ +/* eslint-disable max-len */ + import type { MaybePromise } from "../promises/types.js"; -export type KeyIteratee = (key: K, value: T, index: number) => R; -export type MaybeAsyncKeyIteratee = (key: K, value: T, index: number) => - MaybePromise; +export type KeyedIteratee = (key: K, value: T, index: number) => R; +export type AsyncKeyedIteratee = (key: K, value: T, index: number) => Promise; +export type MaybeAsyncKeyedIteratee = (key: K, value: T, index: number) => MaybePromise; + +export type KeyedTypeGuardIteratee = (key: K, value: T, index: number) => value is R; + +// @ts-expect-error - This is an asyncronous type guard keyed-iteratee that guarantees the return value is a promise. +export type AsyncKeyedTypeGuardIteratee = (key: K, value: T, index: number) => value is Promise; -export type KeyTypeGuardIteratee = - (key: K, value: T, index: number) => value is R; -export type MaybeAsyncKeyTypeGuardIteratee = - (key: K, value: MaybePromise, index: number) => value is Awaited; +// @ts-expect-error - This may be an asyncronous type guard keyed-iteratee that guarantees the return value may be a promise. +export type MaybeAsyncKeyedTypeGuardIteratee = (key: K, value: T, index: number) => value is MaybePromise; -export type KeyReducer = (key: K, accumulator: A, value: T, index: number) => A; -export type MaybeAsyncKeyReducer = - (key: K, accumulator: A, value: T, index: number) => MaybePromise; +export type KeyedReducer = (key: K, accumulator: A, value: T, index: number) => A; +export type AsyncKeyedReducer = (key: K, accumulator: A, value: T, index: number) => Promise; +export type MaybeAsyncKeyedReducer = (key: K, accumulator: A, value: T, index: number) => MaybePromise; diff --git a/src/models/index.ts b/src/models/index.ts index 6bdd6e5..8b7a69e 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -1,6 +1,4 @@ export { - Aggregator, - AsyncAggregator, AggregatedIterator, AggregatedAsyncIterator, ReducedIterator diff --git a/src/models/iterators/smart-async-iterator.ts b/src/models/iterators/smart-async-iterator.ts index b57becd..c59de76 100644 --- a/src/models/iterators/smart-async-iterator.ts +++ b/src/models/iterators/smart-async-iterator.ts @@ -1,11 +1,14 @@ +import AggregatedAsyncIterator from "../aggregators/aggregated-async-iterator.js"; import { ValueException } from "../exceptions/index.js"; import type { - AsyncGeneratorFunction, GeneratorFunction, + AsyncGeneratorFunction, + MaybeAsyncGeneratorFunction, MaybeAsyncIteratee, MaybeAsyncReducer, - MaybeAsyncIterLike, + MaybeAsyncIterable, + MaybeAsyncIteratorLike, MaybeAsyncTypeGuardIteratee } from "./types.js"; @@ -23,8 +26,8 @@ export default class SmartAsyncIterator implements A public constructor(iterator: AsyncIterator); public constructor(generatorFn: GeneratorFunction); public constructor(generatorFn: AsyncGeneratorFunction); - public constructor(argument: MaybeAsyncIterLike); - public constructor(argument: MaybeAsyncIterLike) + public constructor(argument: MaybeAsyncIteratorLike | MaybeAsyncGeneratorFunction); + public constructor(argument: MaybeAsyncIteratorLike | MaybeAsyncGeneratorFunction) { if (argument instanceof Function) { @@ -100,7 +103,7 @@ export default class SmartAsyncIterator implements A const result = await this._iterator.next(); if (result.done) { return true; } - if (!(predicate(result.value, index))) { return false; } + if (!(await predicate(result.value, index))) { return false; } index += 1; } @@ -115,7 +118,7 @@ export default class SmartAsyncIterator implements A const result = await this._iterator.next(); if (result.done) { return false; } - if (predicate(result.value, index)) { return true; } + if (await predicate(result.value, index)) { return true; } index += 1; } @@ -136,7 +139,7 @@ export default class SmartAsyncIterator implements A const result = await iterator.next(); if (result.done) { return result.value; } - if (predicate(result.value, index)) { yield result.value; } + if (await predicate(result.value, index)) { yield result.value; } index += 1; } @@ -155,7 +158,7 @@ export default class SmartAsyncIterator implements A const result = await iterator.next(); if (result.done) { return result.value; } - yield iteratee(result.value, index); + yield await iteratee(result.value, index); index += 1; } @@ -188,6 +191,94 @@ export default class SmartAsyncIterator implements A } } + public flatMap(iteratee: MaybeAsyncIteratee>): SmartAsyncIterator + { + const iterator = this._iterator; + + return new SmartAsyncIterator(async function* () + { + let index = 0; + + while (true) + { + const result = await iterator.next(); + if (result.done) { return result.value; } + + const elements = await iteratee(result.value, index); + + for await (const element of elements) + { + yield element; + } + + index += 1; + } + }); + } + + public drop(count: number): SmartAsyncIterator + { + const iterator = this._iterator; + + return new SmartAsyncIterator(async function* () + { + let index = 0; + + while (index < count) + { + const result = await iterator.next(); + if (result.done) { return; } + + index += 1; + } + + while (true) + { + const result = await iterator.next(); + if (result.done) { return result.value; } + + yield result.value; + } + }); + } + public take(limit: number): SmartAsyncIterator + { + const iterator = this._iterator; + + return new SmartAsyncIterator(async function* () + { + let index = 0; + + while (index < limit) + { + const result = await iterator.next(); + if (result.done) { return result.value; } + + yield result.value; + + index += 1; + } + + return; + }); + } + + public async find(predicate: MaybeAsyncIteratee): Promise + { + let index = 0; + + // eslint-disable-next-line no-constant-condition + while (true) + { + const result = await this._iterator.next(); + + if (result.done) { return; } + if (await predicate(result.value, index)) { return result.value; } + + index += 1; + } + } + public enumerate(): SmartAsyncIterator<[number, T], R> { return this.map((value, index) => [index, value]); @@ -248,18 +339,19 @@ export default class SmartAsyncIterator implements A return this._iterator.next(...values); } - public async toArray(): Promise + public groupBy(iteratee: MaybeAsyncIteratee): AggregatedAsyncIterator { - const elements: T[] = []; - - // eslint-disable-next-line no-constant-condition - while (true) + return new AggregatedAsyncIterator(this.map(async (element, index) => { - const result = await this._iterator.next(); - if (result.done) { return elements; } + const key = await iteratee(element, index); - elements.push(result.value); - } + return [key, element] as [K, T]; + })); + } + + public toArray(): Promise + { + return Array.fromAsync(this as AsyncIterable); } public get [Symbol.toStringTag]() { return "SmartAsyncIterator"; } diff --git a/src/models/iterators/smart-iterator.ts b/src/models/iterators/smart-iterator.ts index 2fafc4b..c3214a8 100644 --- a/src/models/iterators/smart-iterator.ts +++ b/src/models/iterators/smart-iterator.ts @@ -1,6 +1,7 @@ +import AggregatedIterator from "../aggregators/aggregated-iterator.js"; import { ValueException } from "../exceptions/index.js"; -import type { GeneratorFunction, Iteratee, TypeGuardIteratee, Reducer, IterLike } from "./types.js"; +import type { GeneratorFunction, Iteratee, TypeGuardIteratee, Reducer, IteratorLike } from "./types.js"; export default class SmartIterator implements Iterator { @@ -9,11 +10,11 @@ export default class SmartIterator implements Iterat public return?: (value?: R) => IteratorResult; public throw?: (error?: unknown) => IteratorResult; - public constructor(iterable: Iterable); + public constructor(iterable: Iterable); public constructor(iterator: Iterator); public constructor(generatorFn: GeneratorFunction); - public constructor(argument: IterLike); - public constructor(argument: IterLike) + public constructor(argument: IteratorLike | GeneratorFunction); + public constructor(argument: IteratorLike | GeneratorFunction) { if (argument instanceof Function) { @@ -28,8 +29,8 @@ export default class SmartIterator implements Iterat this._iterator = argument; } - if (this._iterator.return) { this.return = (value?: R) => this._iterator.return!(value); } - if (this._iterator.throw) { this.throw = (error?: unknown) => this._iterator.throw!(error); } + if (this._iterator.return) { this.return = (value) => this._iterator.return!(value); } + if (this._iterator.throw) { this.throw = (error) => this._iterator.throw!(error); } } public every(predicate: Iteratee): boolean @@ -130,6 +131,93 @@ export default class SmartIterator implements Iterat } } + public flatMap(iteratee: Iteratee>): SmartIterator + { + const iterator = this._iterator; + + return new SmartIterator(function* () + { + let index = 0; + + while (true) + { + const result = iterator.next(); + if (result.done) { return result.value; } + + const iterable = iteratee(result.value, index); + for (const value of iterable) + { + yield value; + } + + index += 1; + } + }); + } + + public drop(count: number): SmartIterator + { + const iterator = this._iterator; + + return new SmartIterator(function* () + { + let index = 0; + while (index < count) + { + const result = iterator.next(); + if (result.done) { return; } + + index += 1; + } + + while (true) + { + const result = iterator.next(); + if (result.done) { return result.value; } + + yield result.value; + } + }); + } + public take(limit: number): SmartIterator + { + const iterator = this._iterator; + + return new SmartIterator(function* () + { + let index = 0; + while (index < limit) + { + const result = iterator.next(); + if (result.done) { return result.value; } + + yield result.value; + + index += 1; + } + + return; + }); + } + + public find(predicate: Iteratee): T | void; + public find(predicate: TypeGuardIteratee): S | void; + public find(predicate: Iteratee): T | void + { + let index = 0; + + // eslint-disable-next-line no-constant-condition + while (true) + { + const result = this._iterator.next(); + + if (result.done) { return; } + if (predicate(result.value, index)) { return result.value; } + + index += 1; + } + } + public enumerate(): SmartIterator<[number, T], R> { return this.map((value, index) => [index, value]); @@ -169,6 +257,7 @@ export default class SmartIterator implements Iterat index += 1; } } + public forEach(iteratee: Iteratee): void { let index = 0; @@ -190,6 +279,16 @@ export default class SmartIterator implements Iterat return this._iterator.next(...values); } + public groupBy(iteratee: Iteratee): AggregatedIterator + { + return new AggregatedIterator(this.map((element, index) => + { + const key = iteratee(element, index); + + return [key, element] as [K, T]; + })); + } + public toArray(): T[] { return Array.from(this as Iterable); diff --git a/src/models/iterators/types.ts b/src/models/iterators/types.ts index ae209e6..a9808cb 100644 --- a/src/models/iterators/types.ts +++ b/src/models/iterators/types.ts @@ -1,20 +1,31 @@ +/* eslint-disable max-len */ + import type { MaybePromise } from "../promises/types.js"; +export type MaybeAsyncIterable = Iterable | AsyncIterable; +export type MaybeAsyncIterator = Iterator | AsyncIterator; +export type MaybeAsyncGenerator = Generator | AsyncGenerator; + export type GeneratorFunction = () => Generator; export type AsyncGeneratorFunction = () => AsyncGenerator; +export type MaybeAsyncGeneratorFunction = () => MaybeAsyncGenerator; export type Iteratee = (value: T, index: number) => R; +export type AsyncIteratee = (value: T, index: number) => Promise; export type MaybeAsyncIteratee = (value: T, index: number) => MaybePromise; export type TypeGuardIteratee = (value: T, index: number) => value is R; -export type MaybeAsyncTypeGuardIteratee = (value: MaybePromise, index: number) => - value is MaybePromise; + +// @ts-expect-error - This is an asyncronous type guard iteratee that guarantees the return value is a promise. +export type AsyncTypeGuardIteratee = (value: T, index: number) => value is Promise; + +// @ts-expect-error - This may be an asyncronous type guard iteratee that guarantees the return value may be a promise. +export type MaybeAsyncTypeGuardIteratee = (value: T, index: number) => value is MaybePromise; export type Reducer = (accumulator: A, value: T, index: number) => A; +export type AsyncReducer = (accumulator: A, value: T, index: number) => Promise; export type MaybeAsyncReducer = (accumulator: A, value: T, index: number) => MaybePromise; -export type IterLike = Iterable | Iterator | GeneratorFunction; -export type AsyncIterLike = - AsyncIterable | AsyncIterator | AsyncGeneratorFunction; - -export type MaybeAsyncIterLike = IterLike | AsyncIterLike; +export type IteratorLike = Iterable | Iterator; +export type AsyncIteratorLike = AsyncIterable | AsyncIterator; +export type MaybeAsyncIteratorLike = IteratorLike | AsyncIteratorLike; diff --git a/src/models/promises/smart-promise.ts b/src/models/promises/smart-promise.ts index de4f8be..cc0c338 100644 --- a/src/models/promises/smart-promise.ts +++ b/src/models/promises/smart-promise.ts @@ -2,6 +2,11 @@ import type { FulfilledHandler, PromiseExecutor, RejectedHandler } from "./types export default class SmartPromise implements Promise { + public static FromPromise(promise: Promise): SmartPromise + { + return new SmartPromise((resolve, reject) => promise.then(resolve, reject)); + } + protected _isPending: boolean; protected _isFulfilled: boolean; protected _isRejected: boolean; diff --git a/src/models/timers/clock.ts b/src/models/timers/clock.ts index 28103fc..55327a1 100644 --- a/src/models/timers/clock.ts +++ b/src/models/timers/clock.ts @@ -6,7 +6,7 @@ import Publisher from "../publisher.js"; export default class Clock extends GameLoop { - protected _publisher: Publisher<[number], void>; + protected _publisher: Publisher<[number]>; public constructor(fpsIfNotBrowser: number = TimeUnit.Second) { diff --git a/src/models/timers/countdown.ts b/src/models/timers/countdown.ts index f0edb98..fcb54e2 100644 --- a/src/models/timers/countdown.ts +++ b/src/models/timers/countdown.ts @@ -9,7 +9,7 @@ import Publisher from "../publisher.js"; export default class Countdown extends GameLoop { protected _deferrer?: DeferredPromise; - protected _publisher: Publisher<[number], void>; + protected _publisher: Publisher<[number]>; protected _duration: number; public get duration(): number diff --git a/src/models/types.ts b/src/models/types.ts index 40ecd4e..6c267e5 100644 --- a/src/models/types.ts +++ b/src/models/types.ts @@ -1,10 +1,10 @@ export type { - KeyIteratee, - MaybeAsyncKeyIteratee, - KeyTypeGuardIteratee, - MaybeAsyncKeyTypeGuardIteratee, - KeyReducer, - MaybeAsyncKeyReducer + KeyedIteratee, + MaybeAsyncKeyedIteratee, + KeyedTypeGuardIteratee, + MaybeAsyncKeyedTypeGuardIteratee, + KeyedReducer, + MaybeAsyncKeyedReducer } from "./aggregators/types.js"; @@ -17,9 +17,9 @@ export type { MaybeAsyncTypeGuardIteratee, Reducer, MaybeAsyncReducer, - IterLike, - AsyncIterLike, - MaybeAsyncIterLike + IteratorLike, + AsyncIteratorLike, + MaybeAsyncIteratorLike } from "./iterators/types.js"; diff --git a/src/utils/async.ts b/src/utils/async.ts index 1727bfe..9c345bd 100644 --- a/src/utils/async.ts +++ b/src/utils/async.ts @@ -1,9 +1,9 @@ -export async function delay(milliseconds: number): Promise +export function delay(milliseconds: number): Promise { - return new Promise((resolve, reject) => setTimeout(resolve, milliseconds)); + return new Promise((resolve) => setTimeout(resolve, milliseconds)); } -export async function nextAnimationFrame(): Promise +export function nextAnimationFrame(): Promise { - return new Promise((resolve, reject) => requestAnimationFrame(() => resolve())); + return new Promise((resolve) => requestAnimationFrame(() => resolve())); }