Header Ads Widget

BCA Information

Slip no.5

 Slip no-5

Create node js application that perform following operations on buffer data copy ,concat,compare

Slip5.js


var buf1 = Buffer.from('abcdefghijkl');
var buf2 = Buffer.from('HELLO');

buf2.copy(buf1, 2);

console.log(buf1.toString());

//Concat operation
var buf1 = Buffer.from('a');
var buf2 = Buffer.from('b');
var buf3 = Buffer.from('c');
var arr = [buf1, buf2, buf3];

//Join the array into one buffer object:
var buf = Buffer.concat(arr);
console.log(buf);

//Compare operation

var buf1 = Buffer.from('abc');
var buf2 = Buffer.from('abc');
var x = Buffer.compare(buf1, buf2);
console.log(x);

Run 
C:User/node_program:node slip5.js

Post a Comment

0 Comments

Popular Posts

OOSE Notes
Data Mining And Data Science