engineering-unit-converter 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ engineering-unit-converter
2
+ =============
3
+
4
+ A light and simple library for make all type measures conversions and manipulations.
5
+ Used [convert-units](https://github.com/ben-ng/convert-units) as a reference.
6
+
7
+ Installation
8
+ -----
9
+
10
+ ```bash
11
+ npm engineering-unit-converter --save
12
+ ```
13
+
14
+ Usage
15
+ -----
16
+
17
+ `engineering-unit-converter` uses TypeScript to infer the avalaible units, I strongly recommend to use TypeScript for make the dev experience better.
18
+
19
+ Using this library is simple, the above snippet shows a example:
20
+
21
+
22
+ ```js
23
+ import { massFlow } from 'engineering-unit-converter'
24
+ const newValue = massFlow(65000).from('lb/day').to('kg/h')
25
+ console.log(newValue) //1.2284783333333333
26
+ ```
27
+
28
+ Available units
29
+ -----
30
+
31
+ - acceleration
32
+ - area
33
+ - density
34
+ - electricCharge
35
+ - electricCurrent
36
+ - energy
37
+ - force
38
+ - length
39
+ - massFlow
40
+ - mass
41
+ - power
42
+ - pressureManometric
43
+ - pressure
44
+ - speed
45
+ - standardVolumetricFlow
46
+ - surfaceTension
47
+ - time
48
+ - viscosity
49
+ - voltage
50
+ - volume
51
+ - volumetricFlow
@@ -0,0 +1,13 @@
1
+ import { type MeasurementUnits, type Measurement } from './types';
2
+ declare class Converter<T extends Measurement> {
3
+ readonly _definitions: T;
4
+ readonly _val: number;
5
+ _fromUnit: MeasurementUnits<T> | null;
6
+ constructor(numerator: number, _definitions: T);
7
+ from<U extends MeasurementUnits<T>>(fromUnit: U): Converter<T>;
8
+ to<U extends MeasurementUnits<T>>(toUnit: U): number;
9
+ _getUnit(unit: MeasurementUnits<T>): number;
10
+ _checkUnit(unit: MeasurementUnits<T>): void;
11
+ }
12
+ declare const createConverter: <T extends Measurement>(definitions: T) => (val: number) => Converter<T>;
13
+ export default createConverter;