A small library for really easy, totally type-safe unit conversions in JavaScript & TypeScript.
It's not ready for production release*, but all the groundwork for adding in new conversions is done.
* Some conversions are just totally wrong. Please don't use this (yet).
yarn add convert
# or
npm install convert
- Full build time and runtime checks of conversions
- Treeshake-able builds available
- 0 dependencies
- Out of the box ES5 backwards-compatibility
- Works in browsers and Node.js
import {convert} from 'convert';
// 360 seconds into minutes
convert(360)
.from('seconds')
.to('minutes'); // 6
Below is a list of commands you will probably find useful.
Runs the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.
Your library will be rebuilt if you make edits.
Bundles the package to the dist
folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
Runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.
Big thanks to @Jdender, @TheAkio, @iCrawl, @p7g, @aequasi, and the TypeScript Discord server for their help in getting the typesafety working.