From 74a14da64a8e6d0ac70e69da5a06b4a85c35bb02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=91=E6=80=95?= <2371019234@qq.com> Date: Wed, 15 Feb 2023 03:21:45 +0000 Subject: [PATCH 1/5] =?UTF-8?q?2/15=E8=AE=A1=E7=AE=97=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黑怕 <2371019234@qq.com> --- .../add.js" | 4 ++++ .../div.js" | 4 ++++ .../index.js" | 7 +++++++ .../mul.js" | 4 ++++ .../sub.js" | 4 ++++ .../test.js" | 6 ++++++ 6 files changed, 29 insertions(+) create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/add.js" create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/div.js" create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/index.js" create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/mul.js" create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/sub.js" create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/test.js" diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/add.js" "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/add.js" new file mode 100644 index 0000000..06fbed9 --- /dev/null +++ "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/add.js" @@ -0,0 +1,4 @@ +//加法 +module.exports = function (x, y) { + return parseInt(x) + parseInt(y); + } \ No newline at end of file diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/div.js" "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/div.js" new file mode 100644 index 0000000..2027c97 --- /dev/null +++ "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/div.js" @@ -0,0 +1,4 @@ +//除法 +module.exports = function (x, y) { + return parseInt (x) / parseInt (y); +} \ No newline at end of file diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/index.js" "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/index.js" new file mode 100644 index 0000000..cb059c2 --- /dev/null +++ "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/index.js" @@ -0,0 +1,7 @@ + //入口模块 + module.exports={ + add:require('./add'), + subtraot:require('./sub'), + multiply:require('./mul'), + divide:require('./div') + }; \ No newline at end of file diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/mul.js" "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/mul.js" new file mode 100644 index 0000000..3cb67f3 --- /dev/null +++ "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/mul.js" @@ -0,0 +1,4 @@ +//乘法 +module.exports = function(x, y) { + return parseInt(x)* parseInt(y); +} \ No newline at end of file diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/sub.js" "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/sub.js" new file mode 100644 index 0000000..d7d5aaf --- /dev/null +++ "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/sub.js" @@ -0,0 +1,4 @@ +//减法 +module.exports = function(x, y) { + return parseInt (x) - parseInt (y); + } \ No newline at end of file diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/test.js" "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/test.js" new file mode 100644 index 0000000..cf11728 --- /dev/null +++ "b/\351\231\210\351\221\253\351\225\2222\346\234\21015\346\250\241\345\235\227\344\275\234\344\270\232/test.js" @@ -0,0 +1,6 @@ + //测试计算器功能 + var cal = require ('./index'); + console.log(cal.add(1, 2)); // => 3 + console.log(cal.subtraot(1, 2)); // => -1 + console.log(cal.multiply(1, 2)); // => 2 + console.log(cal.divide(1, 2)) ; // => 0.5 \ No newline at end of file -- Gitee From d7dce17a1529f5437cfc74aa723d080ccb94a301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=91=E6=80=95?= <2371019234@qq.com> Date: Thu, 16 Feb 2023 09:30:48 +0000 Subject: [PATCH 2/5] =?UTF-8?q?2=E6=9C=8816=E6=97=A5nodefs=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=94=9F=E6=88=90=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黑怕 <2371019234@qq.com> --- .../jjj.js" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21016nodefs\347\224\237\346\210\220\346\226\207\344\273\266/jjj.js" diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21016nodefs\347\224\237\346\210\220\346\226\207\344\273\266/jjj.js" "b/\351\231\210\351\221\253\351\225\2222\346\234\21016nodefs\347\224\237\346\210\220\346\226\207\344\273\266/jjj.js" new file mode 100644 index 0000000..21169a7 --- /dev/null +++ "b/\351\231\210\351\221\253\351\225\2222\346\234\21016nodefs\347\224\237\346\210\220\346\226\207\344\273\266/jjj.js" @@ -0,0 +1,24 @@ +let fs = require("fs"); + let shuzu=[]; + let max=0; + let maxwj=0; + let min=1001; + let minwj=0; + for(let i=1;i<101;i++){ +let shu=Math.ceil(Math.random()*1000); + +fs.writeFileSync("./"+i+".txt",""+shu+""); + +shuzu[i]=(fs.readFileSync("./"+i+".txt").toString()); + +if(Number(shuzu[i])>max){ + max=Number(shuzu[i]); + maxwj=i; +} +if(Number(shuzu[i]) Date: Sat, 18 Feb 2023 03:28:29 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E9=99=88=E9=91=AB?= =?UTF-8?q?=E9=95=922=E6=9C=8818=E6=96=87=E4=BB=B6=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/.keep" diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/.keep" "b/\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From d4a8aa23e4ce013ce7b9ae40d0db97e2a3074be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=91=E6=80=95?= <2371019234@qq.com> Date: Sat, 18 Feb 2023 03:29:19 +0000 Subject: [PATCH 4/5] =?UTF-8?q?2=E6=9C=8818=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黑怕 <2371019234@qq.com> --- .../cxy/files1" | 0 .../cxy/files2" | 0 .../cxy/homework.js" | 22 +++++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/cxy/files1" create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/cxy/files2" create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/cxy/homework.js" diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/cxy/files1" "b/\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/cxy/files1" new file mode 100644 index 0000000..e69de29 diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/cxy/files2" "b/\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/cxy/files2" new file mode 100644 index 0000000..e69de29 diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/cxy/homework.js" "b/\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/cxy/homework.js" new file mode 100644 index 0000000..0b64ee8 --- /dev/null +++ "b/\351\231\210\351\221\253\351\225\2222\346\234\21018\346\226\207\344\273\266\344\275\234\344\270\232/cxy/homework.js" @@ -0,0 +1,22 @@ +let fs=require("fs"); +//同步写入 +var time1=new Date().getTime(); + +for(i=1;i<=1000;i++){ + fs.writeFileSync("./files1"+i+".txt","我是美女"); + +} +var time2=new Date().getTime(); +console.log( "同步写入:"+(time2-time1)+"毫秒"); + +//异步写入 +var time3=new Date().getTime(); + +for(i=1;i<=1000;i++){ + + fs.writeFile("./files2/"+i+".txt","我是帅哥",function(err){ + + }); +} +var time4=new Date().getTime(); +console.log( "异步写入:"+(time4-time3)+"毫秒"); \ No newline at end of file -- Gitee From 2f15d4d715d322c1b7b7ac4f1736bfdbe8c9b036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=91=E6=80=95?= <2371019234@qq.com> Date: Mon, 20 Feb 2023 09:29:50 +0000 Subject: [PATCH 5/5] =?UTF-8?q?2=E6=9C=8820node=E6=B5=81=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黑怕 <2371019234@qq.com> --- .../zuoye.js" | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 "\351\231\210\351\221\253\351\225\2222\346\234\21020node\346\265\201\344\275\234\344\270\232/zuoye.js" diff --git "a/\351\231\210\351\221\253\351\225\2222\346\234\21020node\346\265\201\344\275\234\344\270\232/zuoye.js" "b/\351\231\210\351\221\253\351\225\2222\346\234\21020node\346\265\201\344\275\234\344\270\232/zuoye.js" new file mode 100644 index 0000000..c04ca81 --- /dev/null +++ "b/\351\231\210\351\221\253\351\225\2222\346\234\21020node\346\265\201\344\275\234\344\270\232/zuoye.js" @@ -0,0 +1,52 @@ +// 作业1:使用open write close的形式去创建一个大文件,内容从指定的文本中随机取一些(每次取得长度内容可以不一样),计算出这个大文件出现最多的字符(要使用流的形式). + + +let str="hdsajkhd登记卡收到卡萨花洒借款单哈市核对撒谎大家卡死回到家开完会尽快带把伞uidhasjkdh还能进销差价萨克不能出现阿珂大数据看到撒gsdajhv打撒很简单跟我讲"; + +let fs=require("fs"); +let fd=fs.openSync('./big.txt','w'); +for(let i=0;i<10000;i++){ + + let size=Math.ceil(Math.random()*30); + + + let rq=''; + + for(let i=0;i{ + console.log(chunk); +}); +rs.on("end",()=>{ + console.log("结束了") + let neir=fs.readFileSync('./big.txt').toString(); + let shuzu=[]; + for(let j=0;jmax){ + max=shuzu[key]; + zhi=key; + } + } + console.log(shuzu); + console.log("此次文本中出现最多的字符是:"+zhi+",共出现了"+max+"次") +}) \ No newline at end of file -- Gitee