Calculates heading based on deviceorientation event. The algorithm is a version proposed in the stackoverflow answer and deviceorientation spec modified for chrome. Check out demo page to see how it works on your device.
$ npm install --save kompasconst kompas = require('kompas'); // start watching and add callback kompas.watch(); kompas.on('heading', function(heading) { console.log('Heading:', heading); }); // stop watching kompas.clear();MIT © Damian Krzeminski