comma.js 201 Bytes
Newer Older
fukai committed
1 2 3 4 5
export default function (source, length = 3) {
  source = String(source).split(".");
  source[0] = source[0].replace(new RegExp('(\\d)(?=(\\d{'+length+'})+$)','ig'),"$1,");
  return source.join(".");
}