Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

JSON.stringify() function converts buffers into objects. The raw data is encoded as an array of bytes that you can pass in to Buffer.from().

let buf = Buffer.from('Hello, World', 'utf8');

let obj = { buffer: buf };
obj = JSON.parse(JSON.stringify(obj));

// { type: 'Buffer',
//   data: [ 72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100 ] }
obj.buffer;

// To convert from JSON representation back to a buffer, use `Buffer.from()`
obj.buffer = Buffer.from(obj.buffer);
obj.buffer.toString('utf8'); // 'Hello, World'
Comment

PREVIOUS NEXT
Code Example
Javascript :: Get async: false 
Javascript :: emergency food meme 
Javascript :: javascript this Inside Constructor Function 
Javascript :: null is not an object clipboard rn 
Javascript :: remove all chars from string and leave only numbers javascript and leav space betwin numbers 
Javascript :: javascript array erstellen 
Javascript :: index and id together angularjs 
Javascript :: .env file example react native 
Javascript :: Substring in Javascript using slice 
Javascript :: string filter javascript 
Javascript :: Material-ui aircon icon 
Javascript :: document.queryselector scrolltop 
Javascript :: get data firebase 
Javascript :: vue js data bind 
Javascript :: remove array value by index js 
Javascript :: check unique object in array javascript site:stackoverflow.com 
Javascript :: javascript typed array 
Javascript :: angular debug chrome launch.json 
Javascript :: asynchronous in javascript 
Javascript :: date difference without weekends using moment js 
Javascript :: how to copy all elements in an array except for the first one in javascript 
Javascript :: sequelize findall 2 attributes 
Javascript :: decapitalize javascript string 
Javascript :: ajax 
Javascript :: script defer attribute 
Javascript :: ondragover js 
Javascript :: jquery connection reset 
Javascript :: to do list app react code 
Javascript :: yarn create react app in current directory 
Javascript :: js get path from url string 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =