- re-wrote in typescript (#10)