Comments (3)
Would it be possible to make the function return
null
orfalse
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.
@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.
@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)
- Incorrect conversion for cubic meters to cubic feet HOT 1
- Cannot convert from square millimeter to square feet HOT 2
- Inaccurate conversion from meters to ft. HOT 1
- proposal: add light year to length HOT 1
- US Legal Cup conversion error HOT 1
- Cannot get KB, MB, etc. units when using "best" for data conversion HOT 2
- Duplicated code and Failure to expand tonnes in mass.ts HOT 1
- Typings can't be found on TypeScript 5 HOT 3
- Library can't handle ASCII char for "micro" (ยต) HOT 2
- [Feature Request]: Support for units of speed and acceleration HOT 2
- Export is not a function in UMD build HOT 1
- The automated release is failing ๐จ HOT 83
- Unexpected result using your example of converting 36 hours to "best" units HOT 2
- Precision error during floating-point conversion HOT 2
- How to Use this library with Ember HOT 1
- meters to feet ratio is wrong HOT 1
- Us feet (ft-us) (U.S. Survey Feet) is not supported
- BTU support HOT 2
- use 'm' for minutes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from convert.