diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..62f705b --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["plugin:prettier/recommended"], +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..188f27f --- /dev/null +++ b/.prettierrc @@ -0,0 +1,13 @@ +{ + "semi": true, + "endOfLine": "lf", + "tabWidth": 2, + "printWidth": 80, + "singleQuote": true, + "bracketSameLine": false, + "bracketSpacing": true, + "arrowParens": "always", + "singleAttributePerLine": true, + "quoteProps": "as-needed", + "trailingComma": "all" +} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..a027e87 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,9 @@ +import globals from 'globals'; +import pluginJs from '@eslint/js'; +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; + +export default [ + { languageOptions: { globals: { ...globals.browser, ...globals.node } } }, + pluginJs.configs.recommended, + eslintPluginPrettierRecommended, +]; diff --git a/package-lock.json b/package-lock.json index 2e1d661..4d2383f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,12 @@ "version": "1.0.0", "license": "ISC", "devDependencies": { + "@eslint/js": "^9.6.0", + "eslint": "^9.6.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.3", + "globals": "^15.8.0", + "prettier": "3.3.2", "vitest": "^1.6.0" } }, @@ -380,6 +386,135 @@ "node": ">=12" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.11.0.tgz", + "integrity": "sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.17.0.tgz", + "integrity": "sha512-A68TBu6/1mHHuc5YJL0U0VVeGNiklLAL6rRmhTCP2B5XjWLMnrX+HkO+IAXyHvks5cyyY1jjK5ITPQ1HGS2EVA==", + "dev": true, + "dependencies": { + "@eslint/object-schema": "^2.1.4", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/js": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.6.0.tgz", + "integrity": "sha512-D9B0/3vNg44ZeWbYMpBoXqNP4j6eQD5vNwIlGAuFRRzK/WtT/jvDQW3Bi9kkf3PMDMlM7Yi+73VLUsn5bJcl8A==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", + "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.0.tgz", + "integrity": "sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==", + "dev": true, + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@jest/schemas": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", @@ -398,6 +533,53 @@ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", "dev": true }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@pkgr/core": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", + "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.18.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.18.0.tgz", @@ -699,6 +881,15 @@ "node": ">=0.4.0" } }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, "node_modules/acorn-walk": { "version": "8.3.3", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", @@ -711,6 +902,31 @@ "node": ">=0.4.0" } }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/ansi-styles": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", @@ -723,6 +939,12 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -732,6 +954,22 @@ "node": "*" } }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -741,6 +979,15 @@ "node": ">=8" } }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/chai": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz", @@ -759,6 +1006,37 @@ "node": ">=4" } }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/check-error": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", @@ -771,6 +1049,30 @@ "node": "*" } }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, "node_modules/confbox": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.7.tgz", @@ -820,6 +1122,12 @@ "node": ">=6" } }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, "node_modules/diff-sequences": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", @@ -867,6 +1175,189 @@ "@esbuild/win32-x64": "0.21.5" } }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.6.0.tgz", + "integrity": "sha512-ElQkdLMEEqQNM9Njff+2Y4q2afHk7JpkPvrd7Xh7xefwgQynqPxwf55J7di9+MEibWUGdNjFF9ITG9Pck5M84w==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/config-array": "^0.17.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "9.6.0", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.3.0", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.0.1", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.1.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + } + }, + "node_modules/eslint-config-prettier": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", + "dev": true, + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-plugin-prettier": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz", + "integrity": "sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==", + "dev": true, + "dependencies": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.8.6" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": "*", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.1.tgz", + "integrity": "sha512-pL8XjgP4ZOmmwfFE8mEhSxA7ZY4C+LWyqjQ3o4yWkkmD0qcMT9kkW3zWHOczhWcjTSgqycYAgwSlXvZltv65og==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", + "dev": true, + "dependencies": { + "acorn": "^8.12.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, "node_modules/estree-walker": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", @@ -876,71 +1367,257 @@ "@types/estree": "^1.0.0" } }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/execa": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", "dev": true, "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.1.0", - "onetime": "^6.0.0", - "signal-exit": "^4.1.0", - "strip-final-newline": "^3.0.0" + "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.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": ">=16.17" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, + "node_modules/fastq": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", + "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-func-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "dev": true, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "15.8.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.8.0.tgz", + "integrity": "sha512-VZAJ4cewHTExBWDHR6yptdIBlx9YSSZuwojj9Nt5mBRXQzrKakDsVKQ1J63sklLvzAJm0X5+RpO4i3Y2hcOnFw==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/human-signals": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "dev": true, + "engines": { + "node": ">=16.17.0" + } + }, + "node_modules/ignore": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" }, "engines": { - "node": ">=16.17" + "node": ">=6" }, "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + "node": ">=0.8.19" } }, - "node_modules/get-func-name": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", - "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, "engines": { - "node": "*" + "node": ">=0.10.0" } }, - "node_modules/get-stream": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", - "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, - "engines": { - "node": ">=16" + "dependencies": { + "is-extglob": "^2.1.1" }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "engines": { + "node": ">=0.10.0" } }, - "node_modules/human-signals": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", - "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", "dev": true, "engines": { - "node": ">=16.17.0" + "node": ">=8" } }, "node_modules/is-stream": { @@ -967,6 +1644,58 @@ "integrity": "sha512-WriZw1luRMlmV3LGJaR6QOJjWwgLUTf89OwT2lUOyjX2dJGBwgmIkbcz+7WFZjrZM635JOIR517++e/67CP9dQ==", "dev": true }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/local-pkg": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.5.0.tgz", @@ -983,6 +1712,27 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, "node_modules/loupe": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", @@ -1019,6 +1769,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/mlly": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.1.tgz", @@ -1055,6 +1817,12 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, "node_modules/npm-run-path": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", @@ -1097,6 +1865,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/p-limit": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-5.0.0.tgz", @@ -1112,6 +1897,69 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate/node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -1181,6 +2029,42 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", @@ -1195,12 +2079,60 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", "dev": true }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/rollup": { "version": "4.18.0", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.18.0.tgz", @@ -1236,6 +2168,29 @@ "fsevents": "~2.3.2" } }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -1296,6 +2251,18 @@ "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", "dev": true }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-final-newline": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", @@ -1308,6 +2275,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/strip-literal": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-2.1.0.tgz", @@ -1320,6 +2299,40 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/synckit": { + "version": "0.8.8", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.8.tgz", + "integrity": "sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ==", + "dev": true, + "dependencies": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, "node_modules/tinybench": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.8.0.tgz", @@ -1344,6 +2357,24 @@ "node": ">=14.0.0" } }, + "node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", + "dev": true + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -1359,6 +2390,15 @@ "integrity": "sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw==", "dev": true }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, "node_modules/vite": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.1.tgz", @@ -1532,6 +2572,15 @@ "node": ">=8" } }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/yocto-queue": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", diff --git a/package.json b/package.json index 1fe342c..0426eee 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "로또 미션을 통해서 학습하는 클린코드", "main": "./src/main.js", - "type": "module", + "type": "module", "scripts": { "start": "node src/main.js", "start:watch": "node --watch src/main.js", @@ -13,6 +13,12 @@ "author": "", "license": "ISC", "devDependencies": { + "@eslint/js": "^9.6.0", + "eslint": "^9.6.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.3", + "globals": "^15.8.0", + "prettier": "3.3.2", "vitest": "^1.6.0" } } diff --git a/src/View/Input.js b/src/View/Input.js new file mode 100644 index 0000000..532c0a6 --- /dev/null +++ b/src/View/Input.js @@ -0,0 +1,35 @@ +import readlineAsync from '../utils/readline.js'; +import InputValidator from '../validator/View/InputValidator.js'; +import createValidator from '../utils/createValidator.js'; + +export default class Input { + #rl; + + constructor() { + this.#rl = readlineAsync; + this.validator = createValidator(InputValidator); + } + + async readInput( + message, + options = { + postProcessFn: undefined, + validate: undefined, + }, + ) { + try { + const { postProcessFn, validate } = options; + this.validator({ message, options, postProcessFn, validate }); + + const input = await this.#rl(message); + const postInput = postProcessFn ? postProcessFn(input) : input; + validate && validate(postInput); + + return postInput; + } catch (error) { + console.log(error); + + return this.readInput(message, options); + } + } +} diff --git a/src/View/Output.js b/src/View/Output.js new file mode 100644 index 0000000..7c79cfa --- /dev/null +++ b/src/View/Output.js @@ -0,0 +1,29 @@ +import createValidator from '../utils/createValidator.js'; +import OutputValidator from '../validator/View/OutputValidator.js'; + +export default class Output { + #template; + constructor({ template }) { + this.#template = template; + this.validator = createValidator(OutputValidator); + } + + static print(...message) { + console.log(...message); + } + + static lineBreak() { + console.log(''); + } + + format(templateKey, templateVariables) { + this.validator({ templateKey, templateVariables }); + let templateString = this.#template[templateKey]; + + Object.entries(templateVariables).forEach(([variable, value]) => { + templateString = templateString.replaceAll(`%{${variable}}`, value); + }); + + return templateString; + } +} diff --git a/src/View/View.js b/src/View/View.js new file mode 100644 index 0000000..f1213f3 --- /dev/null +++ b/src/View/View.js @@ -0,0 +1,62 @@ +import Input from './Input.js'; +import Output from './Output.js'; + +export default class View { + constructor() { + this.input = new Input(); + this.output = new Output({ + template: { + printPurchaseQuantity: `%{quantity}개를 구매했습니다.`, + printLotto: `[%{lotto}]`, + printWinningResult: ` + 당첨 통계\n + ----------------------\n + 3개 일치 (%{fifthMoney}원) - %{fifth}개 + 4개 일치 (%{fourthMoney}원) - %{fourth}개 + 5개 일치 (%{thirdMoney}원) - %{third}개 + 5개 일치, 보너스 볼 일치 (%{secondMoney}원) - %{second}개 + 6개 일치 (%{firstMoney}원) - %{first}개\n + `, + printRevenue: `총 수익률은 %{revenue}%입니다.`, + }, + }); + } + + async inputMoney(options) { + return this.input.readInput('> 구매 금액을 입력해주세요. : ', options); + } + + async inputWinLotto(options) { + return this.input.readInput('> 당첨 번호를 입력해주세요. : ', options); + } + + async inputBonusNumber(options) { + return this.input.readInput('> 보너스 번호를 입력해주세요. : ', options); + } + + async inputRestart(options) { + return this.input.readInput( + '> 로또를 다시 구매하시겠습니까? (예: y, 아니오: n) : ', + options, + ); + } + + printPurchaseQuantity(quantity) { + Output.print(this.output.format('printPurchaseQuantity', { quantity })); + } + + printLottos(lottos) { + lottos.forEach((lotto) => { + Output.print(this.output.format('printLotto', { lotto })); + }); + Output.lineBreak(); + } + + printWinningResult(lottoResult) { + Output.print(this.output.format('printWinningResult', lottoResult)); + } + + printRevenue(revenue) { + Output.print(this.output.format('printRevenue', { revenue })); + } +} diff --git a/src/__tests__/Lotto.test.js b/src/__tests__/Lotto.test.js new file mode 100644 index 0000000..76b17d7 --- /dev/null +++ b/src/__tests__/Lotto.test.js @@ -0,0 +1,87 @@ +import { describe, expect, test } from 'vitest'; +import Lotto from '../domain/Lotto.js'; + +describe('Lotto 도메인 클래스에 대한 단위 테스트', () => { + const correctLotto = [1, 2, 3, 4, 5, 6]; + + test('Lotto 클래스는 콤마로 숫자를 구분한 문자열로 초기화할 수 있다.', () => { + const lotto = makeLottoMocking('1, 2, 3, 4, 5, 6'); + expect(lotto.accord(correctLotto)).toBe(6); + }); + + test('Lotto 클래스는 숫자 요소로 이뤄진 배열로 초기화할 수 있다.', () => { + const lotto = makeLottoMocking([1, 2, 3, 4, 5, 6]); + expect(lotto.accord(correctLotto)).toBe(6); + }); + + test('Lotto 클래스는 숫자로 치환할 수 잇는 문자 요소로 이뤄진 배열로 초기화할 수 있다.', () => { + const lotto = makeLottoMocking(['1', '2', '3', '4', '5', '6']); + expect(lotto.accord(correctLotto)).toBe(6); + }); + + test('Lotto 클래스는 숫자를 열거한 매개변수로 초기화할 수 있다.', () => { + const lotto = makeLottoMocking(1, 2, 3, 4, 5, 6); + expect(lotto.accord(correctLotto)).toBe(6); + }); + + test('Lotto 클래스는 문자열을 열거한 매개변수로 초기화할 수 있다.', () => { + const lotto = makeLottoMocking('1', '2', '3', '4', '5', '6'); + expect(lotto.accord(correctLotto)).toBe(6); + }); + + test.each([ + { lotto: '안, 녕, 하, 세, 요, !' }, + { lotto: [1, 2, 3, 4, 5, '꽝'] }, + ])( + '숫자로 치환할 수 없는 문자($lotto)로 초기화할 경우 에러를 반환한다.', + ({ lotto }) => { + expect(() => { + makeLottoMocking(lotto); + }).toThrowError('숫자로 변환할 수 없는 문자가 포함되어 있습니다.'); + }, + ); + + test.each([{ lotto: '1, 1, 2, 3, 4, 5' }, { lotto: [1, 1, 2, 3, 4, 5, 6] }])( + '중복되는 숫자($lotto)로 초기화할 경우 에러를 반환한다.', + ({ lotto }) => { + expect(() => { + makeLottoMocking(lotto); + }).toThrowError('중복되는 숫자가 포함되어 있습니다.'); + }, + ); + + test.each([ + { lotto: '1' }, + { lotto: [1, 2, 3] }, + { lotto: '1, 2, 3, 4, 5, 6, 7' }, + { lotto: [1, 2, 3, 4, 5, 6, 7] }, + ])('로또번호($lotto)의 개수가 6이 아니면 에러를 반환한다.', ({ lotto }) => { + expect(() => { + makeLottoMocking(lotto); + }).toThrowError('로또번호의 개수는 6개여야 합니다.'); + }); + + test.each([ + { lotto: '0, 1, 2, 3, 4, 5' }, + { lotto: '1, 2, 3, 4, 5, 99' }, + { lotto: [0, 1, 2, 3, 4, 5] }, + { lotto: [1, 2, 3, 4, 5, 99] }, + ])( + '로또번호($lotto)의 각 번호가 1~45 사이의 숫자가 아니면 에러를 반환한다.', + ({ lotto }) => { + expect(() => { + makeLottoMocking(lotto); + }).toThrowError('로또번호의 각 번호는 1~45 사이여야 합니다.'); + }, + ); + + test('로또 번호를 가져올 수 있다.', () => { + expect(makeLottoMocking([1, 2, 3, 4, 5, 6]).get()).toStrictEqual([ + 1, 2, 3, 4, 5, 6, + ]); + }); +}); + +function makeLottoMocking(...lotto) { + return new Lotto(...lotto); +} diff --git a/src/__tests__/WinLotto.test.js b/src/__tests__/WinLotto.test.js new file mode 100644 index 0000000..b8bbc41 --- /dev/null +++ b/src/__tests__/WinLotto.test.js @@ -0,0 +1,130 @@ +import { describe, test, expect } from 'vitest'; +import WinLotto from '../domain/WinLotto'; + +describe('WinLotto 클래스에 대한 단위 테스트', () => { + const correctLotto = [1, 2, 3, 4, 5, 6, 7]; + + test('WinLotto 클래스의 lotto 프로퍼티를 콤마로 숫자를 구분한 문자열로 초기화할 수 있다.', () => { + const winLotto = makeWinLottoMocking('1, 2, 3, 4, 5, 6, 7'); + expect(winLotto.accord(correctLotto)).toBe(7); + }); + + test('WinLotto 클래스의 lotto 프로퍼티를 숫자 요소로 이뤄진 배열로 초기화할 수 있다.', () => { + const winLotto = makeWinLottoMocking([1, 2, 3, 4, 5, 6, 7]); + expect(winLotto.accord(correctLotto)).toBe(7); + }); + + test('WinLotto 클래스의 lotto 프로퍼티를 숫자로 치환할 수 잇는 문자 요소로 이뤄진 배열로 초기화할 수 있다.', () => { + const winLotto = makeWinLottoMocking(['1', '2', '3', '4', '5', '6', '7']); + expect(winLotto.accord(correctLotto)).toBe(7); + }); + + test('WinLotto 클래스의 lotto 프로퍼티를 숫자를 열거한 매개변수로 초기화할 수 있다.', () => { + const winLotto = makeWinLottoMocking(1, 2, 3, 4, 5, 6, 7); + expect(winLotto.accord(correctLotto)).toBe(7); + }); + + test('WinLotto 클래스의 lotto 프로퍼티를 문자열을 열거한 매개변수로 초기화할 수 있다.', () => { + const winLotto = makeWinLottoMocking('1', '2', '3', '4', '5', '6', '7'); + expect(winLotto.accord(correctLotto)).toBe(7); + }); + + test.each([ + { lotto: '안, 녕, 하, 세, 요, !, !' }, + { lotto: [1, 2, 3, 4, 5, '꽝', '꽝!'] }, + ])( + '숫자로 치환할 수 없는 문자($lotto)로 초기화할 경우 에러를 반환한다.', + ({ lotto }) => { + expect(() => { + makeWinLottoMocking(lotto); + }).toThrowError('숫자로 변환할 수 없는 문자가 포함되어 있습니다.'); + }, + ); + + test.each([ + { lotto: '1, 1, 2, 3, 4, 5, 6' }, + { lotto: [1, 1, 2, 3, 4, 5, 6] }, + ])('중복되는 숫자($lotto)로 초기화할 경우 에러를 반환한다.', ({ lotto }) => { + expect(() => { + makeWinLottoMocking(lotto); + }).toThrowError('중복되는 숫자가 포함되어 있습니다.'); + }); + + test.each([ + { lotto: '1' }, + { lotto: [1, 2, 3] }, + { lotto: '1, 2, 3, 4, 5, 6' }, + { lotto: [1, 2, 3, 4, 5, 6] }, + ])('로또번호($lotto)의 개수가 7이 아니면 에러를 반환한다.', ({ lotto }) => { + expect(() => { + makeWinLottoMocking(lotto); + }).toThrowError('로또번호의 개수는 7개여야 합니다.'); + }); + + test.each([ + { lotto: '0, 1, 2, 3, 4, 5, 6' }, + { lotto: '1, 2, 3, 4, 5, 6, 99' }, + { lotto: [0, 1, 2, 3, 4, 5, 6] }, + { lotto: [1, 2, 3, 4, 5, 6, 99] }, + ])( + '로또번호($lotto)의 각 번호가 1~45 사이의 숫자가 아니면 에러를 반환한다.', + ({ lotto }) => { + expect(() => { + makeWinLottoMocking(lotto); + }).toThrowError('로또번호의 각 번호는 1~45 사이여야 합니다.'); + }, + ); + + test('isBonusCorrect 메서드는 보너스 번호가 로또 번호 안에 포함되면 true 를 반환한다.', () => { + const winLotto = makeWinLottoMocking(correctLotto); + + expect(winLotto.isBonusCorrect([1, 2, 3, 4, 5, 7])).toBeTruthy(); + }); + + test.each([ + { lotto: [1, 2, 3, 4, 5, 6], result: 'first' }, + { lotto: [1, 2, 3, 4, 5, 7], result: 'second' }, + { lotto: [1, 2, 3, 4, 5, 8], result: 'third' }, + { lotto: [1, 2, 3, 4, 8, 9], result: 'fourth' }, + { lotto: [1, 2, 3, 8, 9, 10], result: 'fifth' }, + ])( + 'getRank 는 lotto($lotto)가 winLotto와 일치하는 개수에 따라 rank($result)를 반환한다.', + ({ lotto, result }) => { + const winLotto = makeWinLottoMocking(correctLotto); + + expect(winLotto.getRank(lotto)).toBe(result); + }, + ); + + test('getWinningResult 메서드는 lottos 배열을 받아 당첨 결과를 반환한다.', () => { + const winningResult = { + prize: 5000, + purchases: 1000, + details: { + first: 0, + second: 0, + third: 0, + fourth: 0, + fifth: 1, + none: 0, + }, + prizes: { + firstMoney: '2,000,000,000', + secondMoney: '30,000,000', + thirdMoney: '1,500,000', + fourthMoney: '50,000', + fifthMoney: '5,000', + noneMoney: '0', + }, + }; + const winningLotto = makeWinLottoMocking(correctLotto); + + expect(winningLotto.getWinningResult([[1, 2, 3, 8, 9, 10]])).toStrictEqual( + winningResult, + ); + }); +}); + +function makeWinLottoMocking(...lotto) { + return new WinLotto(...lotto); +} diff --git a/src/__tests__/sum.test.js b/src/__tests__/sum.test.js deleted file mode 100644 index efc011c..0000000 --- a/src/__tests__/sum.test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { describe, test, expect } from "vitest"; - -function sum(...args) { - return args.reduce((a, b) => a+ b); -} - -describe('예제 테스트입니다.', () => { - test('sum > ', () => { - expect(sum(1,2,3,4,5)).toBe(15); - }) -}) diff --git a/src/domain/Lotto.js b/src/domain/Lotto.js new file mode 100644 index 0000000..dec009d --- /dev/null +++ b/src/domain/Lotto.js @@ -0,0 +1,43 @@ +import createValidator from '../utils/createValidator.js'; +import LottoValidator from '../validator/domain/LottoValidator.js'; + +export default class Lotto { + lotto; + + constructor(...lotto) { + this.set(...lotto); + } + + static normalize(...lotto) { + if (Array.isArray(lotto[0])) { + lotto = lotto.flat(); + } + if (lotto.length === 1) { + lotto = lotto[0].split(',').map((number) => number.trim()); + } + return [...lotto].map((number) => Number(number)).sort((a, b) => a - b); + } + + get() { + return [...this.lotto]; + } + + set(...lotto) { + const validator = createValidator(LottoValidator); + const normalizedLotto = Lotto.normalize(...lotto); + + validator({ common: normalizedLotto, defaultLotto: normalizedLotto }); + this.lotto = normalizedLotto; + } + + accord(...compareLotto) { + compareLotto = Lotto.normalize(...compareLotto); + const set = new Set( + this.lotto.length > compareLotto.length ? this.lotto : compareLotto, + ); + const base = + this.lotto.length > compareLotto.length ? compareLotto : this.lotto; + + return base.reduce((prev, curr) => (set.has(curr) ? prev + 1 : prev), 0); + } +} diff --git a/src/domain/LottoController.js b/src/domain/LottoController.js new file mode 100644 index 0000000..5c8116c --- /dev/null +++ b/src/domain/LottoController.js @@ -0,0 +1,73 @@ +import createValidator from '../utils/createValidator.js'; +import InputValidator from '../validator/View/InputValidator.js'; +import LottoValidation from '../validator/domain/LottoValidator.js'; +import LottoRule from './LottoRule.js'; + +export default class LottoController { + constructor({ view, lotto, winLotto }) { + this.view = new view(); + this.lotto = lotto; + this.winLotto = winLotto; + } + + async run() { + while (true) { + const lottos = await this.getLottos(); + + this.view.printPurchaseQuantity(lottos.length); + this.view.printLottos(lottos.map((lotto) => lotto.get())); + + const winLotto = await this.getwinLotto(); + const { prize, purchases, details, prizes } = + winLotto.getWinningResult(lottos); + + this.view.printWinningResult({ ...details, ...prizes }); + this.view.printRevenue(prize / purchases); + + const restart = await this.getRestart(); + + if (restart === 'n' || restart === 'N') { + break; + } + } + } + + async getLottos() { + const validator = createValidator(LottoValidation); + const money = await this.view.inputMoney({ + postProcessFn: (value) => Number(value), + validate: (value) => validator({ money: value }), + }); + const quantity = LottoRule.exchange(money); + + return [...new Array(quantity)].map( + () => new this.lotto(LottoRule.generateLottoNumbers()), + ); + } + + async getwinLotto() { + const validator = createValidator(LottoValidation); + const winLotto = await this.view.inputWinLotto({ + postProcessFn: (value) => + value.split(',').map((number) => Number(number)), + validate: (value) => validator({ common: value, defaultLotto: value }), + }); + const bonusNumber = await this.view.inputBonusNumber({ + postProcessFn: (value) => Number(value), + validate: (value) => + validator({ number: value, common: [...winLotto, value] }), + }); + + return new this.winLotto([...winLotto, bonusNumber]); + } + + async getRestart() { + const validator = createValidator(InputValidator); + const restart = await this.view.inputRestart({ + postProcessFn: (value) => value.trim(), + validate: (value) => validator({ restart: value }), + }); + + return restart; + } +} diff --git a/src/domain/LottoRule.js b/src/domain/LottoRule.js new file mode 100644 index 0000000..decc486 --- /dev/null +++ b/src/domain/LottoRule.js @@ -0,0 +1,56 @@ +import generateRandomNumber from '../utils/generateRandomNumber.js'; + +const LottoRule = { + lottoPrice: 1_000, + limitPrice: 10_000_000, + minNumber: 1, + maxNumber: 45, + defaultLength: 6, + winLength: 7, + winningInfo: { + first: { + prize: 2_000_000_000, + checkBonus: false, + accord: 6, + }, + second: { + prize: 30_000_000, + checkBonus: true, + accord: 5, + }, + third: { + prize: 1_500_000, + checkBonus: false, + accord: 5, + }, + fourth: { + prize: 50_000, + checkBonus: false, + accord: 4, + }, + fifth: { + prize: 5_000, + checkBonus: false, + accord: 3, + }, + none: { + prize: 0, + checkBonus: false, + accord: null, + }, + }, + exchange: (money) => { + return Math.floor(money / LottoRule.lottoPrice); + }, + generateLottoNumbers: () => { + const set = new Set(); + + while (set.size < LottoRule.defaultLength) { + set.add(generateRandomNumber(LottoRule.minNumber, LottoRule.maxNumber)); + } + + return [...set]; + }, +}; + +export default LottoRule; diff --git a/src/domain/WinLotto.js b/src/domain/WinLotto.js new file mode 100644 index 0000000..cbeb013 --- /dev/null +++ b/src/domain/WinLotto.js @@ -0,0 +1,68 @@ +import Lotto from './Lotto.js'; +import LottoValidator from '../validator/domain/LottoValidator.js'; +import createValidator from '../utils/createValidator.js'; +import LottoRule from './LottoRule.js'; +import formatCurrency from '../utils/formatCurrency.js'; + +export default class WinLotto extends Lotto { + constructor(...lotto) { + super(...lotto); + } + + set(...lotto) { + const validator = createValidator(LottoValidator); + const normalizedLotto = Lotto.normalize(...lotto); + + validator({ common: normalizedLotto, winLotto: normalizedLotto }); + this.lotto = normalizedLotto; + } + + isBonusCorrect(lotto) { + const bonusNumber = this.lotto.at(-1); + + return lotto.includes(bonusNumber); + } + + getRank(lotto) { + const bonusCorrect = this.isBonusCorrect(lotto); + const accordCount = this.accord(lotto) - (bonusCorrect ? 1 : 0); + + for (const rank in LottoRule.winningInfo) { + if (accordCount === LottoRule.winningInfo[rank].accord) { + if (LottoRule.winningInfo[rank].checkBonus === false) { + return rank; + } + if (LottoRule.winningInfo[rank].checkBonus && bonusCorrect) { + return rank; + } + } + } + + return 'none'; + } + + getWinningResult(lottos) { + const winningResult = { + prize: 0, + purchases: lottos.length * LottoRule.lottoPrice, + details: {}, + prizes: {}, + }; + lottos = lottos.map((lotto) => + Array.isArray(lotto) ? lotto : lotto.get(), + ); + + Object.entries(LottoRule.winningInfo).forEach(([rank, rankInfo]) => { + winningResult.details[rank] = 0; + winningResult.prizes[rank + 'Money'] = formatCurrency(rankInfo.prize); + }); + lottos.forEach((lotto) => { + const rank = this.getRank(lotto); + + winningResult.details[rank] += 1; + winningResult.prize += LottoRule.winningInfo[rank].prize; + }); + + return winningResult; + } +} diff --git a/src/main.js b/src/main.js index 96bab59..1adcc5c 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,18 @@ -function main() { - console.log('main의 내용을 채워주세요'); +import View from './View/View.js'; +import Lotto from './domain/Lotto.js'; +import LottoController from './domain/LottoController.js'; +import WinLotto from './domain/WinLotto.js'; + +async function main() { + const lottoController = new LottoController({ + view: View, + lotto: Lotto, + winLotto: WinLotto, + }); + + await lottoController.run(); } main(); + +export default main; diff --git a/src/utils/createValidator.js b/src/utils/createValidator.js new file mode 100644 index 0000000..8d125a9 --- /dev/null +++ b/src/utils/createValidator.js @@ -0,0 +1,25 @@ +const createValidator = (validation) => { + const validateKeyValue = (keyType, value) => { + Object.keys(validation[keyType]).forEach((validationKey) => { + const validate = validation[keyType][validationKey](value); + + if (validate !== true) { + throw new Error(validate); + } + }); + }; + + return (values) => { + Object.entries(values).map(([keyType, value]) => { + if (validation[keyType] === undefined) { + throw new Error( + `${keyType} 가 초기화 시 전달한 validation 내부에 존재하지 않습니다.`, + ); + } + + validateKeyValue(keyType, value); + }); + }; +}; + +export default createValidator; diff --git a/src/utils/formatCurrency.js b/src/utils/formatCurrency.js new file mode 100644 index 0000000..64a5c36 --- /dev/null +++ b/src/utils/formatCurrency.js @@ -0,0 +1,11 @@ +const formatCurrency = (amount, currency = 'ko-KR') => { + const formatter = new Intl.NumberFormat(currency, { + style: 'decimal', + minimumFractionDigits: 0, + maximumFractionDigits: 0, + }); + + return formatter.format(amount); +}; + +export default formatCurrency; diff --git a/src/utils/generateRandomNumber.js b/src/utils/generateRandomNumber.js new file mode 100644 index 0000000..622aae5 --- /dev/null +++ b/src/utils/generateRandomNumber.js @@ -0,0 +1,5 @@ +const generateRandomNumber = (min, max) => { + return Math.floor(Math.random() * (max - min) + min); +}; + +export default generateRandomNumber; diff --git a/src/utils/readline.js b/src/utils/readline.js new file mode 100644 index 0000000..0267157 --- /dev/null +++ b/src/utils/readline.js @@ -0,0 +1,23 @@ +import readline from 'readline'; + +export default function readLineAsync(query) { + return new Promise((resolve, reject) => { + if (arguments.length !== 1) { + reject(new Error('arguments must be 1')); + } + + if (typeof query !== 'string') { + reject(new Error('query must be string')); + } + + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }); + + rl.question(query, (input) => { + rl.close(); + resolve(input); + }); + }); +} diff --git a/src/validator/View/InputValidator.js b/src/validator/View/InputValidator.js new file mode 100644 index 0000000..f76a6af --- /dev/null +++ b/src/validator/View/InputValidator.js @@ -0,0 +1,40 @@ +const InputValidator = { + message: { + checkType: (value) => + typeof value === 'string' || 'message 는 문자열 타입이어야 합니다.', + checkLength: (value) => + value.trim().length >= 1 || 'message 는 1글자 이상이어야 합니다', + }, + options: { + checkType: (value) => + typeof value === 'object' || 'options 는 객체 타입이어야 합니다.', + checkHasPostProcessFn: (value) => + 'postProcessFn' in value || + 'options 는 postProcessFn 프로퍼티를 가지고 있어야 합니다.', + checkHasValidate: (value) => + 'validate' in value || + 'options 는 validation 프로퍼티를 가지고 있어야 합니다.', + }, + postProcessFn: { + checkType: (value) => + value === undefined || + typeof value === 'function' || + 'postProcessFn 는 함수여야 합니다.', + }, + validate: { + checkType: (value) => + value === undefined || + typeof value === 'function' || + 'validate 는 함수여야 합니다.', + }, + restart: { + checkValue: (value) => + value === 'y' || + value === 'Y' || + value === 'n' || + value === 'N' || + '재시작 여부는 영문자 y 혹은 n 의 값이어야 합니다.', + }, +}; + +export default InputValidator; diff --git a/src/validator/View/OutputValidator.js b/src/validator/View/OutputValidator.js new file mode 100644 index 0000000..2f65b4c --- /dev/null +++ b/src/validator/View/OutputValidator.js @@ -0,0 +1,13 @@ +const OutputValidator = { + templateKey: { + checkType: (value) => + typeof value === 'string' || 'templateKey 의 타입이 문자열이 아닙니다.', + }, + templateVariables: { + checkType: (value) => + typeof value === 'object' || + 'templateVariables 의 타입이 객체가 아닙니다.', + }, +}; + +export default OutputValidator; diff --git a/src/validator/domain/LottoValidator.js b/src/validator/domain/LottoValidator.js new file mode 100644 index 0000000..4d45346 --- /dev/null +++ b/src/validator/domain/LottoValidator.js @@ -0,0 +1,47 @@ +import LottoRule from '../../domain/LottoRule.js'; + +const LottoValidator = { + money: { + checkType: (value) => + isNaN(value) === false || + '입력으로 받은 금액은 숫자로 변환가능해야 합니다.', + checkRange: (value) => + LottoRule.lottoPrice <= value || + value <= LottoRule.limitPrice || + `구매 금액은 ${LottoRule.lottoPrice} 원 이상, ${LottoRule.limitPrice} 원 이하만 가능합니다.`, + }, + number: { + checkNumberRange: (value) => + (LottoRule.minNumber <= value && value <= LottoRule.maxNumber) || + `로또 번호는 ${LottoRule.minNumber}~${LottoRule.maxNumber}사이의 숫자여야 합니다.`, + }, + common: { + checkType: (value) => + value.every((number) => !isNaN(number)) || + '숫자로 변환할 수 없는 문자가 포함되어 있습니다.', + checkDuplicate: (value) => { + const set = new Set(value); + + return set.size === value.length || '중복되는 숫자가 포함되어 있습니다.'; + }, + checkNumberRange: (value) => + value.every((number) => + Object.values(LottoValidator.number).every( + (validate) => validate(number) === true, + ), + ) || + `로또번호의 각 번호는 ${LottoRule.minNumber}~${LottoRule.maxNumber} 사이여야 합니다.`, + }, + defaultLotto: { + checkLength: (value) => + value.length === LottoRule.defaultLength || + `로또번호의 개수는 ${LottoRule.defaultLength}개여야 합니다.`, + }, + winLotto: { + checkLength: (value) => + value.length === LottoRule.winLength || + `로또번호의 개수는 ${LottoRule.winLength}개여야 합니다.`, + }, +}; + +export default LottoValidator;