From aabec21f5c2e08484b4d393f0778284759acf78e Mon Sep 17 00:00:00 2001 From: Maksim Shylau Date: Sun, 21 Jan 2024 18:07:31 +0100 Subject: [PATCH 1/6] feat: use node.js 20.x.x version --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 61220743f3..388d0e897e 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,9 @@ "name": "node-nodejs-basics", "version": "1.0.0", "description": "This repository is the part of nodejs-assignments https://github.com/AlreadyBored/nodejs-assignments", + "engines": { + "node": ">=20.0.0" + }, "type": "module", "scripts": { "cli:args": "node src/cli/args.js --some-arg value1 --other 1337 --arg2 42", From d36294fe6967f1b69a9c68879e92d19ec88d4ca3 Mon Sep 17 00:00:00 2001 From: Maksim Shylau <34455330+AlreadyBored@users.noreply.github.com> Date: Thu, 26 Dec 2024 12:35:20 +0100 Subject: [PATCH 2/6] Rename c.js to c.cjs --- src/modules/files/c.cjs | 1 + src/modules/files/c.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 src/modules/files/c.cjs delete mode 100644 src/modules/files/c.js diff --git a/src/modules/files/c.cjs b/src/modules/files/c.cjs new file mode 100644 index 0000000000..f136a5f07d --- /dev/null +++ b/src/modules/files/c.cjs @@ -0,0 +1 @@ +console.log('Hello from c.js!'); diff --git a/src/modules/files/c.js b/src/modules/files/c.js deleted file mode 100644 index ac09fab173..0000000000 --- a/src/modules/files/c.js +++ /dev/null @@ -1 +0,0 @@ -console.log('Hello from c.js!'); \ No newline at end of file From dfbfd0c7cf321ebfec125537cb7b43b9d852d593 Mon Sep 17 00:00:00 2001 From: Maksim Shylau Date: Sat, 19 Apr 2025 12:48:38 +0200 Subject: [PATCH 3/6] feat: update engine --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 388d0e897e..d8478bd3b3 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "This repository is the part of nodejs-assignments https://github.com/AlreadyBored/nodejs-assignments", "engines": { - "node": ">=20.0.0" + "node": ">=22.14.0" }, "type": "module", "scripts": { From aa4d766a523fa45f19e1d2aae5031f1d1dd56eea Mon Sep 17 00:00:00 2001 From: Alexey Koran Date: Fri, 25 Apr 2025 10:01:05 +0400 Subject: [PATCH 4/6] fix: cjsToEsm.cjs, missing extension in require c.cjs, log message typo in c.cjs (#620) --- src/modules/cjsToEsm.cjs | 2 +- src/modules/files/c.cjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/cjsToEsm.cjs b/src/modules/cjsToEsm.cjs index 8b7be2a48b..d7180351e7 100644 --- a/src/modules/cjsToEsm.cjs +++ b/src/modules/cjsToEsm.cjs @@ -1,7 +1,7 @@ const path = require('path'); const { release, version } = require('os'); const { createServer: createServerHttp } = require('http'); -require('./files/c'); +require('./files/c.cjs'); const random = Math.random(); diff --git a/src/modules/files/c.cjs b/src/modules/files/c.cjs index f136a5f07d..df728e1627 100644 --- a/src/modules/files/c.cjs +++ b/src/modules/files/c.cjs @@ -1 +1 @@ -console.log('Hello from c.js!'); +console.log('Hello from c.cjs!'); From 0db83911977a317b8f50621895d29fad1b675530 Mon Sep 17 00:00:00 2001 From: Alexey Koran Date: Mon, 5 May 2025 17:49:33 +0400 Subject: [PATCH 5/6] Minor tasks refactor (CP, WT, cjsToEsm) (#693) * style: set indentation to 2 spaces, add EOL to each file * refactor: `cp script.js`, use EOL instead of `\n` * refactor: `cp script.js`, import argv, stdout, stdin, exit from `node:process` * refactor: `cjsToEsm`, add `node:` protocol to imports * refactor: `cjsToEsm`, unknownObject import * refactor: `wt/worker.js`, improve nthFibonacci function * refactor: add missing semicolon * style: remove empty line between imports * Revert "refactor: `wt/worker.js`, improve nthFibonacci function" This reverts commit b025c0fd143a68f8f9de4566ebf39ba3fe891057. --- src/cli/args.js | 4 ++-- src/cli/env.js | 4 ++-- src/cp/cp.js | 2 +- src/cp/files/script.js | 19 +++++++++++++------ src/fs/copy.js | 2 +- src/fs/create.js | 4 ++-- src/fs/delete.js | 4 ++-- src/fs/list.js | 4 ++-- src/fs/read.js | 4 ++-- src/fs/rename.js | 4 ++-- src/hash/calcHash.js | 4 ++-- src/modules/cjsToEsm.cjs | 26 ++++++++++---------------- src/modules/files/a.json | 8 ++++---- src/modules/files/b.json | 8 ++++---- src/streams/read.js | 4 ++-- src/streams/transform.js | 4 ++-- src/streams/write.js | 4 ++-- src/wt/main.js | 4 ++-- src/wt/worker.js | 4 ++-- src/zip/compress.js | 4 ++-- src/zip/decompress.js | 4 ++-- 21 files changed, 63 insertions(+), 62 deletions(-) diff --git a/src/cli/args.js b/src/cli/args.js index 8283f7f7aa..9e3622f791 100644 --- a/src/cli/args.js +++ b/src/cli/args.js @@ -1,5 +1,5 @@ const parseArgs = () => { - // Write your code here + // Write your code here }; -parseArgs(); \ No newline at end of file +parseArgs(); diff --git a/src/cli/env.js b/src/cli/env.js index fe4aa4a8df..e3616dc8e7 100644 --- a/src/cli/env.js +++ b/src/cli/env.js @@ -1,5 +1,5 @@ const parseEnv = () => { - // Write your code here + // Write your code here }; -parseEnv(); \ No newline at end of file +parseEnv(); diff --git a/src/cp/cp.js b/src/cp/cp.js index 4a87b98c55..72c6addc9c 100644 --- a/src/cp/cp.js +++ b/src/cp/cp.js @@ -1,5 +1,5 @@ const spawnChildProcess = async (args) => { - // Write your code here + // Write your code here }; // Put your arguments in function call to test this functionality diff --git a/src/cp/files/script.js b/src/cp/files/script.js index 44a0622fbc..0c6654f12f 100644 --- a/src/cp/files/script.js +++ b/src/cp/files/script.js @@ -1,12 +1,19 @@ -const args = process.argv.slice(2); +import { EOL } from 'node:os'; +import { argv, stdout, stdin, exit } from 'node:process'; + +const args = argv.slice(2); console.log(`Total number of arguments is ${args.length}`); -console.log(`Arguments: ${JSON.stringify(args)}`); +console.log(`Arguments: ${JSON.stringify(args)}${EOL}`); const echoInput = (chunk) => { - const chunkStringified = chunk.toString(); - if (chunkStringified.includes('CLOSE')) process.exit(0); - process.stdout.write(`Received from master process: ${chunk.toString()}\n`) + const chunkStringified = chunk.toString(); + + if (chunkStringified.includes('CLOSE')) { + exit(0); + } + + stdout.write(`Received from master process: ${chunk.toString()}${EOL}`); }; -process.stdin.on('data', echoInput); +stdin.on('data', echoInput); diff --git a/src/fs/copy.js b/src/fs/copy.js index bd17fe3991..e226075b4c 100644 --- a/src/fs/copy.js +++ b/src/fs/copy.js @@ -1,5 +1,5 @@ const copy = async () => { - // Write your code here + // Write your code here }; await copy(); diff --git a/src/fs/create.js b/src/fs/create.js index 8d18cf9fc2..6ede285599 100644 --- a/src/fs/create.js +++ b/src/fs/create.js @@ -1,5 +1,5 @@ const create = async () => { - // Write your code here + // Write your code here }; -await create(); \ No newline at end of file +await create(); diff --git a/src/fs/delete.js b/src/fs/delete.js index 4718dbc4c5..a70b13766c 100644 --- a/src/fs/delete.js +++ b/src/fs/delete.js @@ -1,5 +1,5 @@ const remove = async () => { - // Write your code here + // Write your code here }; -await remove(); \ No newline at end of file +await remove(); diff --git a/src/fs/list.js b/src/fs/list.js index c0a83dea15..0c0fa21f7e 100644 --- a/src/fs/list.js +++ b/src/fs/list.js @@ -1,5 +1,5 @@ const list = async () => { - // Write your code here + // Write your code here }; -await list(); \ No newline at end of file +await list(); diff --git a/src/fs/read.js b/src/fs/read.js index 52c78cc6ee..e3938be563 100644 --- a/src/fs/read.js +++ b/src/fs/read.js @@ -1,5 +1,5 @@ const read = async () => { - // Write your code here + // Write your code here }; -await read(); \ No newline at end of file +await read(); diff --git a/src/fs/rename.js b/src/fs/rename.js index 2bb99ecdb5..b1d65b0c86 100644 --- a/src/fs/rename.js +++ b/src/fs/rename.js @@ -1,5 +1,5 @@ const rename = async () => { - // Write your code here + // Write your code here }; -await rename(); \ No newline at end of file +await rename(); diff --git a/src/hash/calcHash.js b/src/hash/calcHash.js index 450f8f72e2..e37c17ed62 100644 --- a/src/hash/calcHash.js +++ b/src/hash/calcHash.js @@ -1,5 +1,5 @@ const calculateHash = async () => { - // Write your code here + // Write your code here }; -await calculateHash(); \ No newline at end of file +await calculateHash(); diff --git a/src/modules/cjsToEsm.cjs b/src/modules/cjsToEsm.cjs index d7180351e7..089bd2db13 100644 --- a/src/modules/cjsToEsm.cjs +++ b/src/modules/cjsToEsm.cjs @@ -1,17 +1,12 @@ -const path = require('path'); -const { release, version } = require('os'); -const { createServer: createServerHttp } = require('http'); +const path = require('node:path'); +const { release, version } = require('node:os'); +const { createServer: createServerHttp } = require('node:http'); + require('./files/c.cjs'); const random = Math.random(); -let unknownObject; - -if (random > 0.5) { - unknownObject = require('./files/a.json'); -} else { - unknownObject = require('./files/b.json'); -} +const unknownObject = random > 0.5 ? require('./files/a.json') : require('./files/b.json'); console.log(`Release ${release()}`); console.log(`Version ${version()}`); @@ -21,7 +16,7 @@ console.log(`Path to current file is ${__filename}`); console.log(`Path to current directory is ${__dirname}`); const myServer = createServerHttp((_, res) => { - res.end('Request accepted'); + res.end('Request accepted'); }); const PORT = 3000; @@ -29,12 +24,11 @@ const PORT = 3000; console.log(unknownObject); myServer.listen(PORT, () => { - console.log(`Server is listening on port ${PORT}`); - console.log('To terminate it, use Ctrl+C combination'); + console.log(`Server is listening on port ${PORT}`); + console.log('To terminate it, use Ctrl+C combination'); }); module.exports = { - unknownObject, - myServer, + unknownObject, + myServer, }; - diff --git a/src/modules/files/a.json b/src/modules/files/a.json index 7878a209f6..d1f6dac48a 100644 --- a/src/modules/files/a.json +++ b/src/modules/files/a.json @@ -1,5 +1,5 @@ { - "a": 1, - "b": 2, - "c": 3 -} \ No newline at end of file + "a": 1, + "b": 2, + "c": 3 +} diff --git a/src/modules/files/b.json b/src/modules/files/b.json index 5214b8c93d..e442128649 100644 --- a/src/modules/files/b.json +++ b/src/modules/files/b.json @@ -1,5 +1,5 @@ { - "a": 11, - "b": 22, - "c": 33 -} \ No newline at end of file + "a": 11, + "b": 22, + "c": 33 +} diff --git a/src/streams/read.js b/src/streams/read.js index 52c78cc6ee..e3938be563 100644 --- a/src/streams/read.js +++ b/src/streams/read.js @@ -1,5 +1,5 @@ const read = async () => { - // Write your code here + // Write your code here }; -await read(); \ No newline at end of file +await read(); diff --git a/src/streams/transform.js b/src/streams/transform.js index 315fc6597f..9e6c15fe84 100644 --- a/src/streams/transform.js +++ b/src/streams/transform.js @@ -1,5 +1,5 @@ const transform = async () => { - // Write your code here + // Write your code here }; -await transform(); \ No newline at end of file +await transform(); diff --git a/src/streams/write.js b/src/streams/write.js index fc917160a2..84aa11e7cb 100644 --- a/src/streams/write.js +++ b/src/streams/write.js @@ -1,5 +1,5 @@ const write = async () => { - // Write your code here + // Write your code here }; -await write(); \ No newline at end of file +await write(); diff --git a/src/wt/main.js b/src/wt/main.js index 37d80484ec..e2ef054d41 100644 --- a/src/wt/main.js +++ b/src/wt/main.js @@ -1,5 +1,5 @@ const performCalculations = async () => { - // Write your code here + // Write your code here }; -await performCalculations(); \ No newline at end of file +await performCalculations(); diff --git a/src/wt/worker.js b/src/wt/worker.js index 441b2154f8..405595394d 100644 --- a/src/wt/worker.js +++ b/src/wt/worker.js @@ -2,7 +2,7 @@ const nthFibonacci = (n) => n < 2 ? n : nthFibonacci(n - 1) + nthFibonacci(n - 2); const sendResult = () => { - // This function sends result of nthFibonacci computations to main thread + // This function sends result of nthFibonacci computations to main thread }; -sendResult(); \ No newline at end of file +sendResult(); diff --git a/src/zip/compress.js b/src/zip/compress.js index bb328f43c6..d55209587e 100644 --- a/src/zip/compress.js +++ b/src/zip/compress.js @@ -1,5 +1,5 @@ const compress = async () => { - // Write your code here + // Write your code here }; -await compress(); \ No newline at end of file +await compress(); diff --git a/src/zip/decompress.js b/src/zip/decompress.js index 69f6c345f8..8aaf26c8a4 100644 --- a/src/zip/decompress.js +++ b/src/zip/decompress.js @@ -1,5 +1,5 @@ const decompress = async () => { - // Write your code here + // Write your code here }; -await decompress(); \ No newline at end of file +await decompress(); From a881f83015866acd905a2aa9317f2f27f0569adc Mon Sep 17 00:00:00 2001 From: Maksim Shylau <34455330+AlreadyBored@users.noreply.github.com> Date: Mon, 20 Oct 2025 17:35:10 +0200 Subject: [PATCH 6/6] feat: update node.js version (#697) --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d8478bd3b3..3108c6c969 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "version": "1.0.0", "description": "This repository is the part of nodejs-assignments https://github.com/AlreadyBored/nodejs-assignments", "engines": { - "node": ">=22.14.0" + "node": ">=24.10.0", + "npm": ">=10.9.2" }, "type": "module", "scripts": {