refactors & documents js.