do you think my approach of using Date.now()-timePast>100 for sampling rate is efficient or you recommend any other way?
That'll be ok but it wouldn't give exactly 10Hz since you're sampling only when the delay is 100ms or more - but the HRM by default runs at 25Hz, so you might get steadier readings by just averaging two readings. It'd give you 12.5Hz but it'd be better to stay at that than to drop samples and get 10ish Hz.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
That'll be ok but it wouldn't give exactly 10Hz since you're sampling only when the delay is 100ms or more - but the HRM by default runs at 25Hz, so you might get steadier readings by just averaging two readings. It'd give you 12.5Hz but it'd be better to stay at that than to drop samples and get 10ish Hz.