GithubHelp home page GithubHelp logo

human-format's People

Contributors

byscripts avatar djulien avatar fbeauchamp avatar greenkeeper[bot] avatar greenkeeperio-bot avatar itay289 avatar julien-f avatar qrohlf avatar sweetpi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

human-format's Issues

Rounding issue with limiting decimals for numbers near 100 million

I found some cases where human-format breaks, it seems to have an internal rounding error somewhere and it outputs the wrong number of digits:

humanFormat(111111111, { decimals: 1 })

returns: 111.09999999999998 M
expected: 111.1 M

humanFormat(100000001, { decimals: 1 })

returns: 99.99999999999999 M
expected: 100.0 M

Exponent formatting

Hi @JsCommunity!

Awesome util, solves many tacky nuances. I am thinking to use it in plot-grid.

Though there is one thought related to this. As far as the util tries to represent values in human-oriented format, would it make sense to display exponent part as ten to the power?

E.g. 10e+2010²⁰, or 7.2973525664e-37.297 352 5664×10⁻³? Wikipedia does so, and that is what I’ve been taught in school :)

Or is it better to delegate to a separate package?

Thanks!

Convert JSON to ARFF?

hello ... I can not convert a json file to ARFF using your example. The result is that I have this: [ '\n', '@DaTa', '\n' ]

I can use the parse, but not the format.

thanks for help

unstable decimals when specifying decimal

I had to do the following custom post-processing to get the decimals to be stable (always present)

  const raw = humanFormat.raw(n, { scale: frogScale, decimals: 3 });
  return `${raw.value.toFixed(3)} ${raw.prefix}`;

So I'm quite glad there's a raw version, but I also wonder if most people want the behaviour of .toFixed() when specifying decimals? (in eg. games where numbers climb rapidly, there is quite a bit of jittering when numbers jump between number of decimal places eg. 0.2 vs 0.21

Is there a way to always floor the result?

Hello,
Is there an option to specify the library should always floor the rounding?
Currently 1390 gets displayed as 1.4k, I would like for it to show 1.3k while the input value is strictly less than 1400.

In other words, I'd like to never show a value actually higher than the input.

Just for reference, the options I'm currently using are { maxDecimals: 'auto', separator: '' }.

Thank you.

Cannot parse str

Hi, I', trying to parse string like '100K', but it returns error:

Error: cannot parse str

const humanFormat = require('human-format')
const parsed = humanFormat.parse('100K')

An in-range update of standard is breaking the build 🚨

Version 8.6.0 of standard just got published.

Branch Build failing 🚨
Dependency standard
Current Version 8.5.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As standard is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details
Commits

The new version differs by 10 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

humanFormat(1) == '1000mB' ?

I would expect humanFormat(1) to return 1B, not 1000mB... which makes no sense. The format should scale down only when values are less than 1.

time scales and formats

I am wondering how I can use time format ( or scale) effectively. Actually I want to output system uptime (seconds since boot) as (days) hh:mm, for example: 4 days, 22:32

I have tried the example included in the README which gives me the following:

var humanFormat = require("human-format");
var timeScale = new humanFormat.Scale({
    seconds: 0,
    minutes: 60,
    hours: 3600,
    days: 86400,
    months: 2592000,
})
console.log(humanFormat(425348, { scale: timeScale }));

which gives me 4.92 days

@julien-f @sweetpi How can I get the desired output format?

Incomplete typing for custom scales

In the readme there is example how to use custom scales

var timeScale = new humanFormat.Scale({
  seconds: 1,
  minutes: 60,
  hours: 3600,
  days: 86400,
  months: 2592000,
});
humanFormat(26729235, { scale: timeScale });

which is incomplete. You can use also second way

var customScale = humanFormat.Scale.create(['a', 'b', 'c', 'd'], 1000);
humanFormat(26729235, { scale: customScale });

The other thing is if you want to use custom scale in TypeScript code there is completly missing typings for this use case. There is not defined Scale at all.

Parse errors

humanFormat.parse('8.3M') -> 8300000.000000001

Hyphenate ISBN

Hey. Just curious if you guys want to include additional feature of formatting ISBN. If so, you can use beautify-isbn, which I crafted for my library software project. So the ISBN agency ranges are up-to-date all the time. :)

Feature request: Support for dimensions

Thank you for a great library!

It would be useful if the library supported higher dimensions for cases such as "m²" or "m³". An example would be:

humanFormat(1_000_000, { unit: "m²" });
//=> 1 km²

Or alternatively:

humanFormat(1_000_000_000, { unit: "m³" });
//=> 1 km³

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.