Node.js Buffer slice() get sub buffer

Description

Node.js Buffer slice() get sub buffer


//Buffer slice// w  w  w .  jav  a2s.c om
var buffer1 = Buffer.from('sample buffer1');
var buffer2 = buffer1.slice(5, 10);
console.log(buffer2.toString());
//Buffer length
console.log('buffer1 length:' + ' ' + buffer1.length);
console.log('buffer2 length:' + ' ' + buffer2.length);



PreviousNext

Related