TypeScriptified XHRFS.

Breaking out util functions into a separate module.

I forgot to commit file_flag before; adding now.