node緩衝区bufferの基本操作
862 ワード
Buffer(バッファ)
Buffer , ,
Buffer
Buffer " ",
Buffer 00 - ff
00000000 - 11111111
Buffer
1 bit ( )
8 bit = 1 byte( )
1024 byte = 1 kb
1024 kb = 1 mb
1024 mb = 1 gb
1024 gb = 1 tb
バッファを作成var str='gzl';
// str Buffer
var buf=Buffer.from(str);
//length buf
console.log(buf.length);
//toString() buffer
consol.log(buf.toString());
// Buffer, Buffer.alloc(); Buffer
var buf=Bufffer.alloc(1);
// Buffer, Buffer.allocUnsafe(size),
var buf=Buffer.allocUnsafe(1);
要素を追加
buf[0]=10;
buf[1]=100;
buf[2]=200;
//buffer
//buffer
buf[3]=300; //44 101100 300 100101100