
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Construction in America relies a lot on the imperial mesuring system (which makes me extremely sad). I wanted a way to easily convert units on my website for readers that are only comfortable with one format. You can see the package at work at karelledru.com.
DISCLAMER: This package is not really production ready. There is still quite some work needed. Use at your own risk but feel free to open tickets or PRs if you want to use/contribute.
1/2"
(half an inch)6ft 4in
1.94m
Limitations:
'
and "
are respectively the shorthands for foot and inch, you cannot use these to separate thousands (like 1'000)Install via yarn/npm:
yarn global add measures
And start using:
Measures = require('measures')
new Measures().from('6ft 4in 1/2').to('m')
from(string)
Measures can parse single units:
10cm
28 m
6 inches
As well as combined units and fractions:
6' 4"
5" 1/2
5 1/2 "
The supported units are:
m
, meter
, meters
km
, kilometer
, kilometers
cm
, centimeter
, centimeters
mm
, millimeter
, millimeters
'
, ft
, foot
, feet
"
, in
, inch
, inches
yd
, yard
, yards
mi
, mile
, miles
to(stringOrArray)
Measures can convert a string to a single unit or multiple ones. You can use any of the units listed above. You can also add a precision (replace * with the unit you want):
*-round
will return the rounded value*-floor
will return the rounded value downwards to the closest integer*-ceil
will return the rounded value upwards to the closest integer*-n
where n
is an integer (like *-2
) will allow n decimal digitFor inches, you might want to format it as a fraction. You can do that with the precision:
*-/n
where n
is an integer in [2, 4, 8, 16, 32, 64]. So *-/8
will return fraction where the denominator is 8 or less.Measures can parse any fraction you input but only returns an irreducible fraction up to a /64
precision.
Do what you want with this. Feel free to contribute, fork, love, hate...
IMPORTANT: I will not merge a PR without proper testing and documentation.
0.2.0 - latest
package.json
FAQs
Convert metric to imperial and vice versa
The npm package measures receives a total of 60 weekly downloads. As such, measures popularity was classified as not popular.
We found that measures demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.