sm: Refactor $$async$$ and $$done$$
sm: Refactor $$async$$ and $$done$$

* Moved function done() into function formatResult()
* Let global.$$done$$() accept a result
* Removed ranOnce
* Used `delete global.$$done$$` to flag that global.$$done$$() has
  already been run once
* TODO: Server dies if an exception is thrown asynchronously

kebot/ijavascript,srounce/ijavascript,srounce/ijavascript,kebot/ijavascript