Use 'switch' instead of 'if-else' and improve JsDoc a bit.