Rewrite in JS to use JSDoc