mathiasbynens / jsesc

Given some data, jsesc returns the shortest possible stringified & ASCII-safe representation of that data.
https://mths.be/jsesc
MIT License
716 stars 53 forks source link

Add an option to use numeric literal separators per thousands #67

Open mathiasbynens opened 1 year ago

mathiasbynens commented 1 year ago

For integers we could use something like this:

const string = '1234567890';
string.replace(/(.(?=(.{3})+$))/g, '$1_');
// -> '1_234_567_890'