From a8f8b1fe272e6b0d9d5ed016b5e95e8c35a6c14c Mon Sep 17 00:00:00 2001 From: Wuliang <2593879575@qq.com> Date: Mon, 13 Feb 2023 10:20:49 +0800 Subject: [PATCH 1/7] 'haha' --- demo/one.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 demo/one.js diff --git a/demo/one.js b/demo/one.js new file mode 100644 index 0000000..f926349 --- /dev/null +++ b/demo/one.js @@ -0,0 +1 @@ +console.log("Hello node.js") \ No newline at end of file -- Gitee From 0d182d944eb32b50579f04fb7e686544e81e9e06 Mon Sep 17 00:00:00 2001 From: Wuliang <2593879575@qq.com> Date: Mon, 13 Feb 2023 10:36:29 +0800 Subject: [PATCH 2/7] 'haha' --- demo/one.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/one.js b/demo/one.js index f926349..a2ff19b 100644 --- a/demo/one.js +++ b/demo/one.js @@ -1 +1 @@ -console.log("Hello node.js") \ No newline at end of file +console.log("Hello node.js"); \ No newline at end of file -- Gitee From c4ec84d25ef42436d29a63ccf4472802b38988ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E9=87=8F?= <2593879575@qq.com> Date: Mon, 13 Feb 2023 10:54:56 +0800 Subject: [PATCH 3/7] 'haha' --- demo/one.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/one.js b/demo/one.js index a2ff19b..64b1418 100644 --- a/demo/one.js +++ b/demo/one.js @@ -1 +1 @@ -console.log("Hello node.js"); \ No newline at end of file +console.log("Hello11 node.js"); \ No newline at end of file -- Gitee From aae37662a8e8d318c136a91db6661e133b37e798 Mon Sep 17 00:00:00 2001 From: wuliang <2593879575@qq.com> Date: Tue, 14 Feb 2023 16:44:04 +0800 Subject: [PATCH 4/7] '1' --- "\344\275\234\344\270\232/2023.2.14/obj.js" | 19 +++++++++++++++++++ "\344\275\234\344\270\232/2023.2.14/one.js" | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 "\344\275\234\344\270\232/2023.2.14/obj.js" create mode 100644 "\344\275\234\344\270\232/2023.2.14/one.js" diff --git "a/\344\275\234\344\270\232/2023.2.14/obj.js" "b/\344\275\234\344\270\232/2023.2.14/obj.js" new file mode 100644 index 0000000..595f398 --- /dev/null +++ "b/\344\275\234\344\270\232/2023.2.14/obj.js" @@ -0,0 +1,19 @@ +let obj = { + "addition":function(num1,num2){ + return num1+num2; + }, + "subtraction":function(num1,num2){ + return num1-num2; + }, + "multiplication":function(num1,num2){ + return num1*num2; + }, + "division":function(num1,num2){ + return num1/num2; + }, + "go":function(num1,num2){ + console.log(num1+"+"+num2+"="+this.addition(num1,num2)+"\n"+num1+"-"+num2+"="+this.subtraction(num1,num2)+"\n"+num1+"*"+num2+"="+this.multiplication(num1,num2)+"\n"+num1+"/"+num2+"="+this.division(num1,num2)); + } +} + +module.exports = obj; \ No newline at end of file diff --git "a/\344\275\234\344\270\232/2023.2.14/one.js" "b/\344\275\234\344\270\232/2023.2.14/one.js" new file mode 100644 index 0000000..7384d3d --- /dev/null +++ "b/\344\275\234\344\270\232/2023.2.14/one.js" @@ -0,0 +1,3 @@ +let obj = require('./obj.js'); + obj.go(1,2) + -- Gitee From 59609ffda6fbaf649c8bae7b56b9d258a49a4ff1 Mon Sep 17 00:00:00 2001 From: wuliang <2593879575@qq.com> Date: Tue, 14 Feb 2023 16:51:08 +0800 Subject: [PATCH 5/7] '1' --- demo/one.js | 1 - .../obj.js" => "\345\220\264\351\207\217/2023.2.14/obj.js" | 0 .../one.js" => "\345\220\264\351\207\217/2023.2.14/one.js" | 0 3 files changed, 1 deletion(-) delete mode 100644 demo/one.js rename "\344\275\234\344\270\232/2023.2.14/obj.js" => "\345\220\264\351\207\217/2023.2.14/obj.js" (100%) rename "\344\275\234\344\270\232/2023.2.14/one.js" => "\345\220\264\351\207\217/2023.2.14/one.js" (100%) diff --git a/demo/one.js b/demo/one.js deleted file mode 100644 index 64b1418..0000000 --- a/demo/one.js +++ /dev/null @@ -1 +0,0 @@ -console.log("Hello11 node.js"); \ No newline at end of file diff --git "a/\344\275\234\344\270\232/2023.2.14/obj.js" "b/\345\220\264\351\207\217/2023.2.14/obj.js" similarity index 100% rename from "\344\275\234\344\270\232/2023.2.14/obj.js" rename to "\345\220\264\351\207\217/2023.2.14/obj.js" diff --git "a/\344\275\234\344\270\232/2023.2.14/one.js" "b/\345\220\264\351\207\217/2023.2.14/one.js" similarity index 100% rename from "\344\275\234\344\270\232/2023.2.14/one.js" rename to "\345\220\264\351\207\217/2023.2.14/one.js" -- Gitee From e720ac485456d26c68c6f2548ad806f6f7d9d659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E9=87=8F?= <2593879575@qq.com> Date: Thu, 16 Feb 2023 11:43:35 +0800 Subject: [PATCH 6/7] '1' --- "\345\220\264\351\207\217/2023.2.16/read.js" | 23 +++++++++++++++++++ "\345\220\264\351\207\217/2023.2.16/write.js" | 15 ++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 "\345\220\264\351\207\217/2023.2.16/read.js" create mode 100644 "\345\220\264\351\207\217/2023.2.16/write.js" diff --git "a/\345\220\264\351\207\217/2023.2.16/read.js" "b/\345\220\264\351\207\217/2023.2.16/read.js" new file mode 100644 index 0000000..620dc49 --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/read.js" @@ -0,0 +1,23 @@ +var fs = require('fs'); +var max ={name:'',num:0}; +for(i=1;i<=10;i++){ + fs.readFile( + "./"+i+".txt", + "utf8", + (err,data)=>{ + if(err){ + console.log(err) + return false; + } + console.log(data) + + if (Number(data)>=max.num){ + max.name = "./"+i+".txt"; + max.num = data; + } + } + ) +} +setTimeout(function() { + console.log(max) +},3000) diff --git "a/\345\220\264\351\207\217/2023.2.16/write.js" "b/\345\220\264\351\207\217/2023.2.16/write.js" new file mode 100644 index 0000000..379145c --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/write.js" @@ -0,0 +1,15 @@ +var fs = require('fs'); +var arr = []; +for (let i = 1; i <=10; i++) { + arr[i] = Math.floor(Math.random()*1000) + fs.writeFile( + i+'.txt', + ''+arr[i], + (err)=>{ + if(err){ + console.log(err) + } + } + ) +} + -- Gitee From 0e0d620e14bb8ac24cba4158ce9921de344145cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E9=87=8F?= <2593879575@qq.com> Date: Thu, 16 Feb 2023 15:47:19 +0800 Subject: [PATCH 7/7] '1' --- "\345\220\264\351\207\217/2023.2.16/1.txt" | 1 + "\345\220\264\351\207\217/2023.2.16/10.txt" | 1 + "\345\220\264\351\207\217/2023.2.16/2.txt" | 1 + "\345\220\264\351\207\217/2023.2.16/3.txt" | 1 + "\345\220\264\351\207\217/2023.2.16/4.txt" | 1 + "\345\220\264\351\207\217/2023.2.16/5.txt" | 1 + "\345\220\264\351\207\217/2023.2.16/6.txt" | 1 + "\345\220\264\351\207\217/2023.2.16/7.txt" | 1 + "\345\220\264\351\207\217/2023.2.16/8.txt" | 1 + "\345\220\264\351\207\217/2023.2.16/9.txt" | 1 + "\345\220\264\351\207\217/2023.2.16/read.js" | 42 +++++++++------ "\345\220\264\351\207\217/2023.2.16/write.js" | 54 +++++++++++++++---- 12 files changed, 79 insertions(+), 27 deletions(-) create mode 100644 "\345\220\264\351\207\217/2023.2.16/1.txt" create mode 100644 "\345\220\264\351\207\217/2023.2.16/10.txt" create mode 100644 "\345\220\264\351\207\217/2023.2.16/2.txt" create mode 100644 "\345\220\264\351\207\217/2023.2.16/3.txt" create mode 100644 "\345\220\264\351\207\217/2023.2.16/4.txt" create mode 100644 "\345\220\264\351\207\217/2023.2.16/5.txt" create mode 100644 "\345\220\264\351\207\217/2023.2.16/6.txt" create mode 100644 "\345\220\264\351\207\217/2023.2.16/7.txt" create mode 100644 "\345\220\264\351\207\217/2023.2.16/8.txt" create mode 100644 "\345\220\264\351\207\217/2023.2.16/9.txt" diff --git "a/\345\220\264\351\207\217/2023.2.16/1.txt" "b/\345\220\264\351\207\217/2023.2.16/1.txt" new file mode 100644 index 0000000..bccc87b --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/1.txt" @@ -0,0 +1 @@ +581 \ No newline at end of file diff --git "a/\345\220\264\351\207\217/2023.2.16/10.txt" "b/\345\220\264\351\207\217/2023.2.16/10.txt" new file mode 100644 index 0000000..8db1e5f --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/10.txt" @@ -0,0 +1 @@ +522 \ No newline at end of file diff --git "a/\345\220\264\351\207\217/2023.2.16/2.txt" "b/\345\220\264\351\207\217/2023.2.16/2.txt" new file mode 100644 index 0000000..06e8971 --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/2.txt" @@ -0,0 +1 @@ +540 \ No newline at end of file diff --git "a/\345\220\264\351\207\217/2023.2.16/3.txt" "b/\345\220\264\351\207\217/2023.2.16/3.txt" new file mode 100644 index 0000000..fb32aea --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/3.txt" @@ -0,0 +1 @@ +296 \ No newline at end of file diff --git "a/\345\220\264\351\207\217/2023.2.16/4.txt" "b/\345\220\264\351\207\217/2023.2.16/4.txt" new file mode 100644 index 0000000..8d0003f --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/4.txt" @@ -0,0 +1 @@ +245 \ No newline at end of file diff --git "a/\345\220\264\351\207\217/2023.2.16/5.txt" "b/\345\220\264\351\207\217/2023.2.16/5.txt" new file mode 100644 index 0000000..fc72547 --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/5.txt" @@ -0,0 +1 @@ +344 \ No newline at end of file diff --git "a/\345\220\264\351\207\217/2023.2.16/6.txt" "b/\345\220\264\351\207\217/2023.2.16/6.txt" new file mode 100644 index 0000000..cb37cb5 --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/6.txt" @@ -0,0 +1 @@ +186 \ No newline at end of file diff --git "a/\345\220\264\351\207\217/2023.2.16/7.txt" "b/\345\220\264\351\207\217/2023.2.16/7.txt" new file mode 100644 index 0000000..09bd682 --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/7.txt" @@ -0,0 +1 @@ +611 \ No newline at end of file diff --git "a/\345\220\264\351\207\217/2023.2.16/8.txt" "b/\345\220\264\351\207\217/2023.2.16/8.txt" new file mode 100644 index 0000000..cf5106d --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/8.txt" @@ -0,0 +1 @@ +999 \ No newline at end of file diff --git "a/\345\220\264\351\207\217/2023.2.16/9.txt" "b/\345\220\264\351\207\217/2023.2.16/9.txt" new file mode 100644 index 0000000..d7b14a6 --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/9.txt" @@ -0,0 +1 @@ +476 \ No newline at end of file diff --git "a/\345\220\264\351\207\217/2023.2.16/read.js" "b/\345\220\264\351\207\217/2023.2.16/read.js" index 620dc49..a6baf6e 100644 --- "a/\345\220\264\351\207\217/2023.2.16/read.js" +++ "b/\345\220\264\351\207\217/2023.2.16/read.js" @@ -1,23 +1,31 @@ var fs = require('fs'); +var arr = require('./write'); var max ={name:'',num:0}; -for(i=1;i<=10;i++){ - fs.readFile( - "./"+i+".txt", - "utf8", - (err,data)=>{ - if(err){ - console.log(err) - return false; + +setTimeout(() => { + console.log(arr.arr) + console.log("-----------------------------------------------------------------------") + console.log("正在查找最大值所在文件.....") + for(i=1;i<=10;i++){ + fs.readFile( + "./"+i+".txt", + "utf8", + (err,data)=>{ + if(err){ + return console.log("错误信息2"+err); + } + if (Number(data)>=max.num){ + max.name = "./"+arr.arr.indexOf(Number(data))+".txt"; + max.num = data; + } } - console.log(data) - - if (Number(data)>=max.num){ - max.name = "./"+i+".txt"; - max.num = data; - } - } - ) -} + ) + } +}, 1000); + setTimeout(function() { + console.log("最大值文件已找到") + console.log("------------------------------------") console.log(max) + console.log("------------------------------------") },3000) diff --git "a/\345\220\264\351\207\217/2023.2.16/write.js" "b/\345\220\264\351\207\217/2023.2.16/write.js" index 379145c..9c00828 100644 --- "a/\345\220\264\351\207\217/2023.2.16/write.js" +++ "b/\345\220\264\351\207\217/2023.2.16/write.js" @@ -1,15 +1,49 @@ var fs = require('fs'); var arr = []; -for (let i = 1; i <=10; i++) { - arr[i] = Math.floor(Math.random()*1000) - fs.writeFile( - i+'.txt', - ''+arr[i], - (err)=>{ - if(err){ - console.log(err) +console.log("正在生成随机数组.....") +//查询是否已经存在文件,存在则删除 +console.log("正在查找是否已存在生成文件") +fs.stat( + "./1.txt", + (err,stats)=>{ + if(err){ + return console.log("未找到已存在生成文件"); + } + if(stats.isFile()){ + console.log("查找到已存在生成文件,清除中........") + for (let i = 1; i <= 10; i++) { + fs.unlink( + "./"+i+".txt", + (err)=>{ + if(err){ + return false + } + + } + ) } } - ) -} + console.log("文件已清除完成") + console.log("------------------------------------") + } + +) +setTimeout(() => { + for (let i = 1; i <=10; i++) { + arr[i] = Math.floor(Math.random()*1000) + fs.writeFile( + i+'.txt', + ''+arr[i], + (err)=>{ + if(err){ + return console.log("错误信息"+err); + } + } + ) + } +}, 1000); + +console.log("随机数组已生成") +console.log("-----------------------------------------------------------------------") +module.exports.arr = arr; -- Gitee