Metrick is a Babel-powered unit conversion library (v0.2.0) that leverages the ES7 function bind syntax (::) for human-readable unit expressions. It supports duration (milliseconds, seconds, minutes, hours, years) and data (bits, bytes, kilobytes, megabytes, gigabytes, etc.) conversions with explicit (unit::unit.in(target)) and implicit (number::unit) syntax. The library requires the Babel plugin transform-function-bind and is designed for Node.js and browser environments. Alternatives like js-quantities or convert-units offer more units or simpler syntax but lack the syntactic sugar of the bind operator. Release cadence is low; last release was 2017.
npm install metrickVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing units, explicit conversion with ::x.in(y), implicit conversion to base unit, and creating custom units.
Replace 'transform-function-bind' with '@babel/plugin-proposal-function-bind' in .babelrc.
Always transpile code with Babel and the function bind plugin before running.
Use correct subpath imports: import { seconds } from 'metrick/duration'.Use 'metrick/data' for data units; note that megabyte = 1e6 bytes, not 2^20.
Install and configure Babel with @babel/plugin-proposal-function-bind.
Import from subpaths like 'metrick/duration' for unit functions.
Use the :: operator: 30::seconds.in(milliseconds) instead of 30.seconds.in(milliseconds).