node-i2c icon indicating copy to clipboard operation
node-i2c copied to clipboard

Guidance for returning result from read

Open Toshiba01 opened this issue 2 years ago • 1 comments

Hi,

I need a little bit of guidance:

wire.read(length, function(err, res) { // result contains a buffer of bytes });

taking in consideration this function, how can I return result value to be used in the code outside of this function?

something like: var returnedValue = wire.read(length, function(err, res){ return res})

Thank you!

Toshiba01 avatar Feb 09 '23 20:02 Toshiba01

I'd recommend using Promises if you can't use the callback block.

kelly avatar Feb 10 '23 01:02 kelly