Completely refactor JS string completion

Eliminates all repeated code & prepares for new function completions