From 10f38855f68b201b8f1d232e52f380e3574eb5e2 Mon Sep 17 00:00:00 2001 From: Mikita Date: Fri, 15 Nov 2024 15:49:45 +0300 Subject: [PATCH] refactor: use lodash random --- package-lock.json | 25 ++++++++++++++++--------- package.json | 1 + src/games/evenGame.js | 4 +++- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index bdb2cbe..350126e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@eslint/eslintrc": "^3.1.0", + "lodash-es": "^4.17.21", "readline-sync": "^1.4.10" }, "bin": { @@ -642,9 +643,9 @@ } }, "node_modules/es-abstract": { - "version": "1.23.3", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz", - "integrity": "sha512-e+HfNH61Bj1X9/jLc5v1owaLYuHdeHHSQlkhCBiTK8rBvKaULl/beGMxwrMXjpYrv4pz22BlY570vVePA2ho4A==", + "version": "1.23.5", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.5.tgz", + "integrity": "sha512-vlmniQ0WNPwXqA0BnmwV3Ng7HxiGlh6r5U6JcTMNx8OilcAGqVJBHJcPjqOMaczU9fRuRK5Px2BdVyPRnKMMVQ==", "dev": true, "license": "MIT", "dependencies": { @@ -663,7 +664,7 @@ "function.prototype.name": "^1.1.6", "get-intrinsic": "^1.2.4", "get-symbol-description": "^1.0.2", - "globalthis": "^1.0.3", + "globalthis": "^1.0.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2", "has-proto": "^1.0.3", @@ -679,10 +680,10 @@ "is-string": "^1.0.7", "is-typed-array": "^1.1.13", "is-weakref": "^1.0.2", - "object-inspect": "^1.13.1", + "object-inspect": "^1.13.3", "object-keys": "^1.1.1", "object.assign": "^4.1.5", - "regexp.prototype.flags": "^1.5.2", + "regexp.prototype.flags": "^1.5.3", "safe-array-concat": "^1.1.2", "safe-regex-test": "^1.0.3", "string.prototype.trim": "^1.2.9", @@ -1931,6 +1932,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "license": "MIT" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -1974,9 +1981,9 @@ "license": "MIT" }, "node_modules/object-inspect": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", - "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz", + "integrity": "sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index c926225..808180d 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "license": "ISC", "dependencies": { "@eslint/eslintrc": "^3.1.0", + "lodash-es": "^4.17.21", "readline-sync": "^1.4.10" }, "devDependencies": { diff --git a/src/games/evenGame.js b/src/games/evenGame.js index 68ed7c6..3718189 100644 --- a/src/games/evenGame.js +++ b/src/games/evenGame.js @@ -1,9 +1,11 @@ +import { random } from 'lodash-es'; + import { BOOLEAN_TO_ANSWER_MAP } from '../constants/index.js'; import { askQuestion, getAnswer, getResponseAfterRound } from '../cli.js'; import { isEven } from '../utils/index.js'; export default () => { - const num = Math.round(Math.random() * 1000); + const num = random(10, 1000); askQuestion(num);