jscheiny / safe-units Goto Github PK
View Code? Open in Web Editor NEWType-safe TypeScript units of measure ๐ท๐
Home Page: https://jscheiny.github.io/safe-units
License: MIT License
Type-safe TypeScript units of measure ๐ท๐
Home Page: https://jscheiny.github.io/safe-units
License: MIT License
Hi,
first: thank you for your great work!
Using your library I discovered that:
Measure.of(1, radians.per(seconds)).in(degrees.per(seconds)).toString() returns "1 rad / s"
I expected it to return ~"57 deg / s"
Did I do something wrong?
Best regards
Michael
Is this really of the included features? Isn't there a typo?
Hello!
From the readme, I expected:
console.log(Measure.of(72, bytes).toString());
to print 72 B
but, the result is 576 b
as the underlying value created by Measure.of
is in bits.
This is a bit confusing as other higher order units behave as I would expect them to, e.g.:
console.log(Measure.of(72, kilograms).toString());
yields 72 kg
rather than 72000 g
.
Using v1.1.0
with Typescript v4.3.5
.
The following, taken from the documentation
const error: Velocity = length.times(time);
// ERROR: A measure of m*s isn't assignable to a measure of m/s.
Gives a compile-time error.
But removing the times
operation, making it just
const error: Velocity = length
Does not give a compile-time error, although the measures are clearly incompatible
Am I missing something? I have strict
turned on in my tsconfig file.
Thanks otherwise for a fantastic library
Hello!
Would appreciate an escape-hatch to get the value in a particular unit, e.g.
Measure.of(8, furlongs).valueIn(miles)
returns numeric 1
.
This seams like a very useful library and I've been toying with it a bit.
I was wondering if there are more formatting options, corresponding to toFixed and toPrecision. I was using the lib in a react application and wanted to some simple unit conversion for display, but I got this, which is not really suitable for display.
<span>{distance.in(kilo(meters))}</span> // "29.023945563497445 km"
Is there another way to do this or is it a limitation?
Somehow windows paths ended up in the dist folder.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.