/*Stringbuff NODE其中一个模块*/
/*第一种构造方式*/
var buf1=Buffer.alloc(10,16);
console.log(buf1);//十六进制
var buf2=Buffer.alloc(10,"a");
console.log(buf2);//a:97 a:67=^*16+1
/*第一种构造方式*/
var buf3=Buffer.allocUnsafe(10);
buf3.write("aa");//写入
buf3.fill();//清空
console.log(buf3);
/*第三种构造方式*/
var buf4=Buffer.from([1,2,,3,5]);
console.log(buf4);//把数组转化成Buff类型
var buf=new Buffer.alloc(10);
buf.write("课工场");//中文占3个字符
console.log(buf);//打印内存
console.log(buf.toString());//打印内容
/*buffer变JSON*/
var buf=Buffer.from([1,2,3,5]);
console.log(buf.toJSON());//变json
console.log(JSON.stringify(buf));//变json
/*buffer concat*/
var buf1=Buffer.from("课工场");
var buf2=Buffer.from("NODEJS");
var buf3=Buffer.concat([buf1,buf2]);
console.log(buf3.toString);//查看拼接后