Coder Social home page Coder Social logo

Comments (3)

jonahsnider avatar jonahsnider commented on May 27, 2024 1

Would it be possible to make the function return null or false when a conversion fails?

Yes, but I don't want to support this. Users should just use the correct units. Forcing everyone to explicitly handle graceful failures because of misspelling the name of a unit is silly, and harms the UX for the vast majority of users. Also, this is only a problem that affects JavaScript users, since TypeScript users will just get a compile-time error if they make the same mistake.

will output the whole library code.

Throwing an error will print the stacktrace of the code where the error occurred. That's built-in JavaScript behavior.

Convert-Units does this already

convert-units is no longer maintained, the last update was more than 5 years ago. If you want functionality to be added you should make a new issue on this repository and request the feature there.

from convert.

MarketingPip avatar MarketingPip commented on May 27, 2024

@MrAmericanMike - agreed! Just found this library pretty well same time this was opened & first thing I thought!

It would be very nice if @jonahsnider can think about merging / talking to the owner owner of the package / library convert-units to merge these libraries together so they can be used to return the human phrases of the conversion. > Convert-Units does this already, but does not have support for converting via ["seconds", "secs"] etc.. and only one format which is not ideal.

If these libraries merged both of their great features - it would be amazing ๐Ÿ”ฅ.

from convert.

MarketingPip avatar MarketingPip commented on May 27, 2024

@jonahsnider - sorry to convert / not trying to deter but I highly suggest you look at contributing your project into the Math.JS library (better than my last recommendation!)

from convert.

Related Issues (20)

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.