Comments (5)
That's awesome. The example implementation in C# is basically what we're currently doing, to support a readable API response from our backend. Once your PR completes, we can remove all the bandaid solutions and almost feel like we're using a cross-technology framework for unit handling
from unitsnet-js.
that would be a great change, currently we're holding a custom LengthDto that allows us to parse to/from out c# unitsnet backend.
const LengthToString = (input: { value: number; unit: string }): string => {
const unit = getLengthUnit(input.unit);
const l = new Length(input.value, getLengthUnit(input.unit));
return l.toString(unit);
};
the one usage we're currently not doing is actually converting the data from the backend to a UnitsNetJS Length
, since it's hard to map the "Meter" string coming from the backend to the actual enum value.
Currenlty (as far as I see it) a UnitsNetJS Length has no information about the unit it currently is representing, since it always has Meter
as a base.
from unitsnet-js.
@Shentoza
In your time you can see my new PR #32 with an implementation of this and check it that can improve your use-cases.
In the meantime, I have opened a discussion angularsen/UnitsNet#1378 with the UnitsNet owner to see his opinion about such a cross-language convention.
from unitsnet-js.
Implemented by #32
from unitsnet-js.
@Shentoza After ~ two months of waiting for progress on the UnitNet library discussion, I've decided to merge the changes into the main version. From now on, you can utilize this updated version from both JS #32 & Python (haimkastner/unitsnet-py#18)
Regardless of the final decision made in the UnitNet thread, I'll maintain backward compatibility with this merged API.
from unitsnet-js.
Related Issues (20)
- Implement lazy load for each unit property HOT 1
- Generate all prefixes units HOT 1
- Why ist "Millimeter" Missing in all Units? HOT 1
- Fetch the units definition from the UnitsNet repo HOT 1
- make unit abbreviations used in .toString() accessible HOT 1
- Missing Unit Abbreviations HOT 4
- Full support for units.net features? HOT 2
- Length.multiply() multiplicator HOT 1
- Equally use singular for unit types as in the c# project HOT 10
- Generate 'toString' method for each unit HOT 1
- Math in JS HOT 5
- Allow truncate fraction digits on 'toString' HOT 1
- CORS Error in OpenAPI Spec Example HOT 1
- Check ctor parameter validity HOT 1
- Expose the base value to allows high-performance access to base-value for quick calculation etc. HOT 1
- Add JSDoc from the definition XMLDoc HOT 1
- Generate 'compareTo' and 'equals' for each unit HOT 1
- Generate basic arithmetics methods for each unit HOT 1
- fix 'toString' format of prefixes units HOT 1
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 unitsnet-js.