HubSpot / humanize

A simple utility library for making the web more humane. #hubspot-open-source
MIT License
915 stars 75 forks source link

Make it possible to customize the arguments of formatNumber #74

Open philipgiuliani opened 8 years ago

philipgiuliani commented 8 years ago

In german we write "1,53 MB" instead of "1.53 MB". I have added the same arguments we have in formatNumber and i'm passing them.

I think for the next major version it would be the best to switch to an options object. That makes it very flexible and will not break the api in future releases in case we change something.

fileSize(fileSize, options = {}) {
    // assign default options
    options = Object.assign({ precision: 2, thousand: ".", decimal: "," }, options);

    // do the rest here
}

// call with:
Humanize.fileSize(1024, { decimal: "." });