Use this.emit(‘error’) in streams

Also prettify the js file.
There was a mix between spaces and tabs.
We probably should have more test.