数字に限定すれば変換用のマップを組まなくても良い。
#コード
お好きなので
const fullnums = '0123456789';
const reFullnums = new RegExp('['+fullnums+']','g');
const toHalfnums = text => text.replace(reFullnums, m=>fullnums.indexOf(m));
console.log(toHalfnums('あ369あ')); // 'あ369あ'
console.log(toHalfnums('7')); // '7'
const fullnums = '0123456789';
const toHalfnums = text => text.replace(/[0-9]/g, m=>fullnums.indexOf(m));
const toHalfnums = text => text.replace(/[0-9]/g, m=>'0123456789'.indexOf(m));
Comments
Let's comment your feelings that are more than good