lang/node

node.js Buffer

C/H 2018. 1. 11. 10:31

var buf = new Buffer('my buffer content');
// accessing the 10th position of buf
console.log(buf.toString());
my buffer content

var buf = new Buffer(100);
console.log(buf.length);
100

buf.toString();
100

var buf = new Buffer(10);
buf.write("Node.js", "utf8");
buf.toJSON();
{ type: 'Buffer',
  data: [ 78, 111, 100, 101, 46, 106, 115, 0, 0, 0 ] }


반응형