diff --git "a/\345\220\264\351\207\217/2023.2.14/obj.js" "b/\345\220\264\351\207\217/2023.2.14/obj.js" new file mode 100644 index 0000000000000000000000000000000000000000..595f3984684c540f8cd51882540d15b8c3550f14 --- /dev/null +++ "b/\345\220\264\351\207\217/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/\345\220\264\351\207\217/2023.2.14/one.js" "b/\345\220\264\351\207\217/2023.2.14/one.js" new file mode 100644 index 0000000000000000000000000000000000000000..7384d3dda16865de5eb45835128b544534fdbb39 --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.14/one.js" @@ -0,0 +1,3 @@ +let obj = require('./obj.js'); + obj.go(1,2) + 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 0000000000000000000000000000000000000000..bccc87b80ef7af97083b3cda3f315937e89f1673 --- /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 0000000000000000000000000000000000000000..8db1e5f188b2ca253fa389047f6da965ac5f52b9 --- /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 0000000000000000000000000000000000000000..06e8971dc662a94702e1d094b4c2ba640351f945 --- /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 0000000000000000000000000000000000000000..fb32aea383e655b7d4efaaa01ce7f262de6bea83 --- /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 0000000000000000000000000000000000000000..8d0003f4668834ef1138cf7df42f663fce94ead0 --- /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 0000000000000000000000000000000000000000..fc72547e33638e38bf14b4f33418739eef2dcd3a --- /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 0000000000000000000000000000000000000000..cb37cb5c1fb749a2eaad380460a926969564408e --- /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 0000000000000000000000000000000000000000..09bd682e66b027f08ea6e0b72278cab363b2a83a --- /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 0000000000000000000000000000000000000000..cf5106d72affa73ca65e0f046ee86a98e01f3a83 --- /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 0000000000000000000000000000000000000000..d7b14a6c47450ae9b84d7ccecc7de768a95042d9 --- /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" new file mode 100644 index 0000000000000000000000000000000000000000..a6baf6efbab2cf83ec1a032c878c5186243c38f8 --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/read.js" @@ -0,0 +1,31 @@ +var fs = require('fs'); +var arr = require('./write'); +var max ={name:'',num:0}; + +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; + } + } + ) + } +}, 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" new file mode 100644 index 0000000000000000000000000000000000000000..9c0082883e02c28a2bd294cd030f5c8c19f76aa9 --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.16/write.js" @@ -0,0 +1,49 @@ +var fs = require('fs'); +var arr = []; +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; + diff --git "a/\345\220\264\351\207\217/2023.2.17/go.js" "b/\345\220\264\351\207\217/2023.2.17/go.js" new file mode 100644 index 0000000000000000000000000000000000000000..bb942b65565140ed04be31a982933dbf39244114 --- /dev/null +++ "b/\345\220\264\351\207\217/2023.2.17/go.js" @@ -0,0 +1,69 @@ +var fs = require("fs"); +var Foldername = 'as';//创建文件夹名 +var Fileacount = 10;//创建文件的数量 +let obj = { + //创建文件 + 'createFile':function(Filename,content){ + fs.writeFileSync(Filename,content) + }, + //创建文件夹 + 'createFolder':function(Foldername){ + //判断是否已存在该文件 + if(fs.existsSync('./'+Foldername)&&fs.existsSync('./'+Foldername+'/1.txt')){ + //存在删除 + console.log("已存在文件,清除中.....") + for(i=1;i<=Fileacount;i++){ + fs.unlinkSync('./'+Foldername+'/'+i+'.txt') + console.log('删除文件'+i+'.txt') + } + // fs.rmdirSync('./'+Foldername) + // console.log('删除文件夹'+Foldername) + } + //不存在文件夹,创建 + if(!fs.existsSync('./'+Foldername)){ + fs.mkdirSync(Foldername); + } + + }, + //随机数 + 'createrandom':function(Maxrandom){ + return Math.floor(Math.random()*Maxrandom)+1 + }, + //读取文件 + 'readFile':function(Filename,cod){ + return fs.readFileSync(Filename,cod) + }, + init:function(){ + console.time('同步时间') + var max = {name:'',val:0}; + //创建文件夹 + this.createFolder(Foldername) + //创建文件 + for(i=1;i<=Fileacount;i++){ + this.createFile('./'+Foldername+'/'+i+'.txt',this.createrandom(1000)+'哈哈哈哈'); + }; + //读取文件 + console.log('-----------------'+'utf8编码-----------------') + for(i=1;i<=Fileacount;i++){ + let Filecontent = this.readFile('./'+Foldername+'/'+i+'.txt','utf8') + console.log(Filecontent) + // if(Filecontent>max.val){ + // max.name = './'+i+'.txt' + // max.val = Filecontent + // } + } + console.log('-----------------'+'ascii编码-----------------') + for(i=1;i<=Fileacount;i++){ + let Filecontent2 = this.readFile('./'+Foldername+'/'+i+'.txt','ascii') + console.log(Filecontent2) + // if(Filecontent>max.val){ + // max.name = './'+i+'.txt' + // max.val = Filecontent + // } + } + // console.log(max) + console.timeEnd('同步时间') + } +} + +obj.init()