Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/susisu/ts-dimensional
PoC: Dimensional Quantities in TypeScript
https://github.com/susisu/ts-dimensional
Last synced: 1 day ago
JSON representation
PoC: Dimensional Quantities in TypeScript
- Host: GitHub
- URL: https://github.com/susisu/ts-dimensional
- Owner: susisu
- License: mit
- Created: 2020-08-13T11:08:42.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-06T12:07:21.000Z (about 4 years ago)
- Last Synced: 2024-10-31T05:03:58.406Z (7 days ago)
- Language: TypeScript
- Homepage:
- Size: 172 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @susisu/ts-dimensional
[![CI](https://github.com/susisu/ts-dimensional/workflows/CI/badge.svg)](https://github.com/susisu/ts-dimensional/actions?query=workflow%3ACI)PoC: Dimensional Quantities in TypeScript
**NOTE: This is an experimental package and not suitable for production use.**
``` shell
npm i @susisu/ts-dimensional
# or
yarn add @susisu/ts-dimensional
```TypeScript 4.0+ is required.
## Example
``` typescript
import { mass, length, mks, cgs, add, mul, conv } from "@susisu/ts-dimensional";const m1 = mass(1, mks);
const m2 = mass(2, mks);
const m3 = mass(3, cgs);const l1 = length(1, mks);
const l2 = length(2, mks);
const l3 = length(3, cgs);add(m1, m2); // ok
add(m1, l1); // error: dimensions mismatch
add(m1, m3); // error: unit systems mismatchmul(m1, l1); // ok
add(mul(m1, l1), mul(m2, l2)); // ok
mul(m1, l3); // error: unit systems mismatchconst m4 = conv(m1, cgs);
add(m3, m4); // ok
```## License
[MIT License](http://opensource.org/licenses/mit-license.php)
## Author
Susisu ([GitHub](https://github.com/susisu), [Twitter](https://twitter.com/susisu2413))