You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4,27 +4,27 @@ While users can [define their own unit system](unit-systems.html), Safe Units al
4
4
5
5
All quantities provided are generic and of the form `type Quantity<N = number>` so all quantity types will default to using `number` as the numeric type but may be passed another numeric type.
6
6
7
-
## Base Units
7
+
## Dimensions
8
8
9
9
The built-in units include the standard set of SI base dimension and corresponding units:
10
10
11
-
*`Length` / `meters`
12
-
*`Mass` / `kilograms`
13
-
*`Time` / `seconds`
14
-
*`ElectricCurrent` / `amperes`
15
-
*`Temperature` / `kelvin`
16
-
*`AmountOfSubstance` / `moles`
17
-
*`LuminousIntensity` / `candelas`
11
+
*`Length` / `meters` (m)
12
+
*`Mass` / `kilograms` (kg)
13
+
*`Time` / `seconds` (s)
14
+
*`ElectricCurrent` / `amperes` (A)
15
+
*`Temperature` / `kelvin` (K)
16
+
*`AmountOfSubstance` / `moles` (mol)
17
+
*`LuminousIntensity` / `candelas` (cd)
18
18
19
19
In addition, several extra dimensions are defined:
20
20
21
-
*`PlaneAngle` / `radians`
22
-
*`SolidAngle` / `steradians`
23
-
*`Memory` / `bits`
21
+
*`PlaneAngle` / `radians` (rd)
22
+
*`SolidAngle` / `steradians` (sr)
23
+
*`Memory` / `bits` (b)
24
24
25
25
While plane and solid angles are defined as dimensionless in the SI specification, they are defined here in case users want to be more rigorous with their angles. If not, then these can be safely ignored.
26
26
27
-
## Generic Base Units
27
+
###Generic Base Units
28
28
29
29
The base units are only provided for `number` measures, but users can create the base units for a given measure type through:
30
30
@@ -34,13 +34,220 @@ builtinBaseUnits.ts
34
34
35
35
These versions of `meters`, `kilograms`, etc. will all operate on measures whose numeric types are `BigNumber`.
36
36
37
-
## Provided Units
37
+
## Derived Units
38
38
39
-
A large number of built in quantities (e.g. distance, velocity, force and magnetic flux density) are provided. See [here](https://github.com/jscheiny/safe-units/blob/master/src/unit/quantities.ts) for a full list.
39
+
The following is a list of the provided quantities and measures given by the library. Units are grouped by their type (also referred to as a quantity). Some quanties do not have a corresponding unit. US customary units and imperial units are placed into `US` and `Imperial` namespaces respectively to avoid name clashes.
40
40
41
-
Many units are provided from the SI, Imperial and U.S. customary unit systems. See [here](https://github.com/jscheiny/safe-units/tree/master/src/unit) for all of the units.
41
+
-`Length` - m
42
+
-`meters` (m) _[base unit]_
43
+
-`inches` (in)
44
+
-`thous` (th)
45
+
-`feet` (ft)
46
+
-`yards` (yd)
47
+
-`chains` (ch)
48
+
-`furlongs` (fur)
49
+
-`miles` (mi)
50
+
-`leagues` (lea)
51
+
-`fathoms` (ftm)
52
+
-`cables` (cable)
53
+
-`nauticalMiles` (nmi)
54
+
-`links` (li)
55
+
-`rods` (rd)
56
+
-`angstroms` (Å)
57
+
-`US.points` (p)
58
+
-`US.picas` (pica)
59
+
-`Mass` - kg
60
+
-`kilograms` (kg) _[base unit]_
61
+
-`grams` (g)
62
+
-`pounds` (lb)
63
+
-`grains` (gr)
64
+
-`ounces` (oz)
65
+
-`carats` (ct)
66
+
-`Imperial.drachms` (dr)
67
+
-`Imperial.stone` (st)
68
+
-`Imperial.quarters` (qtr)
69
+
-`Imperial.hundredweights` (cwd)
70
+
-`Imperial.tons` (t)
71
+
-`US.drams` (dr)
72
+
-`US.pennyweights` (dwt)
73
+
-`US.hundredweights` (cwd)
74
+
-`US.tons` (ton)
75
+
-`Time` - s
76
+
-`seconds` (s) _[base unit]_
77
+
-`minutes` (min)
78
+
-`hours` (hr)
79
+
-`days` (d)
80
+
-`ElectricCurrent` - A
81
+
-`amperes` (A) _[base unit]_
82
+
-`Temperature` - K
83
+
-`kelvin` (K) _[base unit]_
84
+
-`AmountOfSubstance` - mol
85
+
-`moles` (mol) _[base unit]_
86
+
-`LuminousIntesity` - cd
87
+
-`candelas` (cd) _[base unit]_
88
+
-`PlaneAngle` - rad
89
+
-`radians` (rad) _[base unit]_
90
+
-`piRadians` (pi rad)
91
+
-`tauRadians` (tau rad)
92
+
-`arcSeconds` (arcsec)
93
+
-`arcMinutes` (arcmin)
94
+
-`degrees` (deg)
95
+
-`SolidAngle` - sr
96
+
-`steradians` (sr) _[base unit]_
97
+
-`Memory` - b
98
+
-`bits` (b) _[base unit]_
99
+
-`bytes` (B)
100
+
-`Frequency` - 1 / s
101
+
-`hertz` (Hz)
102
+
-`FrequencyDrift` - 1 / s²
103
+
-`FuelEfficiency` - 1 / m²
104
+
-`Wavenumber` - 1 / m
105
+
-`Area` - m²
106
+
-`perches` (perch)
107
+
-`roods` (rood)
108
+
-`acres` (acre)
109
+
-`ares` (a)
110
+
-`hectares` (ha)
111
+
-`Volume` - m³
112
+
-`liters` (L)
113
+
-`Imperial.fluidOunces` (fl oz);
114
+
-`Imperial.gills` (gi)
115
+
-`Imperial.pints` (pt)
116
+
-`Imperial.quarts` (qt)
117
+
-`Imperial.gallons` (gal)
118
+
-`US.minims` (min)
119
+
-`US.fluidDrams` (fl dr)
120
+
-`US.teaspoons` (tsp)
121
+
-`US.tablespoons` (Tbsp)
122
+
-`US.fluidOunces` (fl oz)
123
+
-`US.shots` (jig)
124
+
-`US.gills` (gi)
125
+
-`US.cups` (cp)
126
+
-`US.pints` (pt)
127
+
-`US.quarts` (qt)
128
+
-`US.gallons` (gal)
129
+
-`US.barrels` (liq bbl)
130
+
-`US.oilBarrels` (bbl)
131
+
-`US.hogsheads` (hogshead)
132
+
-`US.dryPints` (dry pt)
133
+
-`US.dryQuarts` (dry qt)
134
+
-`US.dryGallons` (dry gal)
135
+
-`US.pecks` (pk)
136
+
-`US.bushels` (bu)
137
+
-`US.dryBarrels` (dry bbl)
138
+
-`Absement` - m ⋅ s
139
+
-`Velocity` - m / s
140
+
-`speedOfLight` (C)
141
+
-`Acceleration` - m / s²
142
+
-`Jerk` - m / s³
143
+
-`Jounce` - m / s⁴
144
+
-`Crackle` - m / s⁵
145
+
-`Pop` - m / s⁶
146
+
-`VolumetricFlow` - m³ / s
147
+
-`MassFlowRate` - kg / s
148
+
-`LinearDensity` - kg / m
149
+
-`AreaDensity` - kg / m²
150
+
-`VolumeDensity` - kg / m³
151
+
-`Force` - kg ⋅ m / s²
152
+
-`newtons` (N)
153
+
-`Yank` - km ⋅ m / s³
154
+
-`Pressure` - kg / (m ⋅ s²)
155
+
-`pascals` (Pa)
156
+
-`bars` (bar)
157
+
-`atmospheres` (atm)
158
+
-`torrs` (Torr)
159
+
-`Compressibility` - m ⋅ s² / kg
160
+
-`DynamicViscosity` - kg / (m ⋅ s)
161
+
-`SurfaceTension` - kg / s²
162
+
-`Momentum` - kg ⋅ m / s
163
+
-`MomentOfInertia` - kg ⋅ m²
164
+
-`Energy` - kg ⋅ m² / s²
165
+
-`joules` (J)
166
+
-`Power` - kg ⋅ m² / s³
167
+
-`watts` (W)
168
+
-`PowerDensity` - kg / (m ⋅ s³)
169
+
-`Voltage` - kg ⋅ m² / (s³ ⋅ A)
170
+
-`volts` (V)
171
+
-`ElectricCharge` - s ⋅ A
172
+
-`coulombs` (C)
173
+
-`ElectricChargeDensity` - s ⋅ A / m³
174
+
-`ElectricCurrentDensity` - A / m²
175
+
-`ElectricDisplacement` - s ⋅ A / m²
176
+
-`EletricFieldStrength` - kg ⋅ m / (s³ ⋅ A)
177
+
-`ElectricalCapacitance` - s⁴ ⋅ A² / (kg ⋅ m²)
178
+
-`farads` (F)
179
+
-`ElectricalConductance` - s³ ⋅ A / (kg ⋅ m²)
180
+
-`siemens` (S)
181
+
-`ElectricalConductivity` - s³ ⋅ A² / (kg ⋅ m³)
182
+
-`ElectricalResistance` - kg ⋅ m² / (s³ ⋅ A²)
183
+
-`ohms` (Ω)
184
+
-`ElectricalResistivity` - kg ⋅ m³ / (s³ ⋅ A²)
185
+
-`ElectricalInductance` - kg ⋅ m² / (s² ⋅ A²)
186
+
-`henrys` (H)
187
+
-`LinearChargeDensity` - s ⋅ A / m
188
+
-`Permittivity` - s⁴ ⋅ A² / (kg ⋅ m³)
189
+
-`MagneticFlux` - kg ⋅ m² / (s² ⋅ A)
190
+
-`webers` (Wb)
191
+
-`MagneticFluxDensity` - kg / (s² ⋅ A)
192
+
-`teslas` (T)
193
+
-`MagneticPermeability` - kg ⋅ m / (s² ⋅ A²)
194
+
-`Magnetization` - A / m
195
+
-`MagneticReluctance` - s² ⋅ A² / (kg ⋅ m²)
196
+
-`MagneticMoment` - kg ⋅ m³ / (s² ⋅ A)
197
+
-`MagneticRigidity` - kg ⋅ m / (s² ⋅ A)
198
+
-`MagneticDipoleMoment` - m² ⋅ A
199
+
-`MagneticSusceptibility` - s² ⋅ A² / (kg ⋅ m)
200
+
-`Irradiance` - kg / s³
201
+
-`Entropy` - kg ⋅ m / (s² ⋅ K)
202
+
-`SpecificHeat` - m² / (s² ⋅ K)
203
+
-`SpecificVolume` - m³ / kg
204
+
-`ThermalConductivity` - kg ⋅ m / (s³ ⋅ K)
205
+
-`ThermalResistance` - s³ ⋅ K / (kg ⋅ m²)
206
+
-`ThermalExpansionCoefficient` - 1 / K
207
+
-`ThermalGradient` - K / m
208
+
-`MolarEntropy` - kg ⋅ m² / (s² ⋅ K ⋅ mol)
209
+
-`MolarEnergy` - kg ⋅ m² / (s² ⋅ mol)
210
+
-`Molarity` - mol / m³
211
+
-`MolarVolume` - m³ / mol
212
+
-`Molality` - mol / kg
213
+
-`MolarMass` - kg / mol
214
+
-`MolarConductivity` - s³ ⋅ A² / (kg ⋅ mol)
215
+
-`CatalyticActivity` - mol / s
216
+
-`katals` (kat)
217
+
-`CatalyticEfficiency` - m³ / (s ⋅ mol)
218
+
-`ReactionRate` - mol / (m³ ⋅ s)
219
+
-`RadiationDose` - m² / s²
220
+
-`sieverts` (Sv)
221
+
-`RadiationDoseRate` - m² / s³
222
+
-`ElectronMobility` - s² ⋅ A / kg
223
+
-`AngularMomentum` - kg ⋅ m² / s
224
+
-`SpecificAngularMomentum` - m² / s
225
+
-`Luminance` - cd / m²
226
+
-`LuminousFlux` - cd ⋅ sr
227
+
-`lumens` (lm)
228
+
-`Illuminance` - cd ⋅ sr / m²
229
+
-`luxes` (lx)
230
+
-`LuminousEnergy` - s ⋅ cd ⋅ sr
231
+
-`LuminousExposure` - s ⋅ cd ⋅ sr / m²
232
+
-`LuminousEfficiency` - s³ ⋅ cd ⋅ sr / (kg ⋅ m²)
233
+
-`RadiantIntensity` - kg ⋅ m² / (s³ ⋅ sr)
234
+
-`SpectralIntensity` - kg ⋅ m / (s³ ⋅ sr)
235
+
-`Radiance` - kg / (s³ ⋅ sr)
236
+
-`SpectralRadiance` - kg / (m ⋅ s³ ⋅ sr)
237
+
-`AngularVelocity` - rad / s
238
+
-`AngularAcceleration` - rad / s²
42
239
43
-
Prefix functions are provided for both standard [SI prefixes](https://github.com/jscheiny/safe-units/blob/master/src/unit/metric.ts) and for [memory prefixes](https://github.com/jscheiny/safe-units/blob/master/src/unit/memory.ts).
240
+
## Prefixes
241
+
242
+
You may notice that some commonly used units, such as kilometers, are absent from the list above. Instead of creating all the different combinations of prefix and unit pairs, Safe Units instead provides prefix functions. These are functions which operate on measures to construct a new measure with a corresponding symbol. For example:
243
+
244
+
```example
245
+
builtinPrefixes.ts
246
+
```
247
+
248
+
Prefix functions are provided for all of the [SI prefixes](https://en.wikipedia.org/wiki/Metric_prefix) and all of the [binary prefixes](https://en.wikipedia.org/wiki/Binary_prefix) for memory.
249
+
250
+
## Trigonometry
44
251
45
252
Trigonometric functions are provided in the `Trig` namespace for converting between plane angles and dimensionless values, the signatures are as follows:
- The `Measure.dimension` and `Measure.dimensionless` functions now require a unit system as their first parameter. The `Measure.dimension` function can no longer arbitrarily produce new dimensions. To add new dimensions, create a new `UnitSystem`.
7
+
- Changed the way in which unit exponents are represented. Exponents are now numbers instead of strings and units contain every dimension in their unit system even if the exponent is zero.
8
+
- Removed the ability to arbitrarily perform exponentiation on measures. The `measure.toThe` and `Measure.pow` functions have been removed.
9
+
- Removed the ability to perform roots of measures. The `Measure.sqrt` and `Measure.cbrt` functions have been removed.
10
+
11
+
**New features**
12
+
- Introduced the concept of a [unit system](unit-systems.html). Unit systems define a fixed set of dimensions and their corresponding base units. Measures of a given unit system are not assignable to measures of other unit systems. Safe units ships with a default implementation of the SI unit system as `SIUnitSystem`.
13
+
- Removed the limitations on exponents. Previously, exponents of dimensions had to be between -5 and +5. Now the limit on exponents is much larger and should no longer present any issues.
14
+
- Added a new `valueIn` method to the `Measure` class. Calling `measure.valueIn(unit)` is syntactic sugar for `measure.div(unit).value`.
15
+
16
+
**Fixes**
17
+
- Fixed an issue where measures could be assigned to measures of different unit types if they contained a superset of the other measure's dimensions. In order to fix this, the concept of unit systems was introduced.
18
+
- Fixed incorrect symbols for the `joules` and `watts` units.
19
+
3
20
## v1.1.1
4
21
22
+
**Fixes**
5
23
- Fixed an issue where `wrapRootFn` would allow non-positive values as the root parameter.
6
24
7
25
## v1.1.0
8
26
27
+
**Improvements**
9
28
- Added a custom formatter argument that can be passed into the `Measure.in` and `Measure.toString` methods.
10
29
11
30
## v1.0.0
12
31
32
+
**Breaking changes**
13
33
- Changed all interface names to no longer be I- prefixed.
0 commit comments