Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove element from node.js Buffer

Tags:

arrays

node.js

I have a node.js buffer declared in this way;

var buffer_bin;
buffer_bin = new Buffer("ABCDEF", "hex");

Contents of buffer_bin is "ab cd ef" in binary bytes.

I want to remove the first byte ab from buffer_bin such that the contents of buffer_bin becomes "cd ef".


1 Answers

Use the slice method in Buffer object.

 var new_buffer_bin = buffer_bin.slice(1);
like image 51
guagay_wk Avatar answered Feb 27 '26 11:02

guagay_wk