Implement Connection::decode in JavaScript

Connection::decode is one of the top offenders, it's also used a lot (basically for each FileConnection call).

I've used a basic approach here, just commenting out the body of the function and reimplementing it in JS.