I've implemented a peaks/troughs feature extraction in Javascript a few years ago as a basis for some larger analysis project. It works at O(n) of the number of data points. You can play with a demo here:<p><a href="http://nocurve.com/2014/01/12/finding-peaks-and-troughs-in-a-noisy-curve/" rel="nofollow">http://nocurve.com/2014/01/12/finding-peaks-and-troughs-in-a...</a>