@thi.ng/units 0.1.1 → 0.2.0

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/README.md +86 -14
  3. package/api.d.ts +4 -0
  4. package/api.js +9 -0
  5. package/constants/din-sizes.d.ts +10 -0
  6. package/constants/din-sizes.js +11 -0
  7. package/constants/din.d.ts +10 -0
  8. package/constants/din.js +11 -0
  9. package/constants/velocities.d.ts +10 -0
  10. package/constants/velocities.js +11 -0
  11. package/index.d.ts +22 -19
  12. package/index.js +22 -19
  13. package/package.json +64 -45
  14. package/unit.d.ts +103 -21
  15. package/unit.js +113 -58
  16. package/units/accel.d.ts +5 -0
  17. package/{accel.js → units/accel.js} +1 -1
  18. package/units/angle.d.ts +8 -0
  19. package/{angle.js → units/angle.js} +1 -1
  20. package/units/area.d.ts +10 -0
  21. package/{area.js → units/area.js} +1 -1
  22. package/units/data.d.ts +25 -0
  23. package/{data.js → units/data.js} +1 -1
  24. package/units/density.d.ts +3 -0
  25. package/units/density.js +6 -0
  26. package/units/electric.d.ts +24 -0
  27. package/{electric.js → units/electric.js} +1 -1
  28. package/units/energy.d.ts +7 -0
  29. package/{energy.js → units/energy.js} +1 -1
  30. package/units/force.d.ts +2 -0
  31. package/{force.js → units/force.js} +1 -1
  32. package/units/frequency.d.ts +9 -0
  33. package/{frequency.js → units/frequency.js} +1 -1
  34. package/units/length.d.ts +20 -0
  35. package/{length.js → units/length.js} +1 -1
  36. package/units/luminous.d.ts +4 -0
  37. package/{luminous.js → units/luminous.js} +1 -1
  38. package/units/mass.d.ts +11 -0
  39. package/{mass.js → units/mass.js} +1 -1
  40. package/units/parts.d.ts +8 -0
  41. package/{parts.js → units/parts.js} +1 -1
  42. package/units/power.d.ts +9 -0
  43. package/{power.js → units/power.js} +1 -1
  44. package/units/pressure.d.ts +9 -0
  45. package/{pressure.js → units/pressure.js} +1 -1
  46. package/units/speed.d.ts +6 -0
  47. package/{speed.js → units/speed.js} +1 -1
  48. package/units/substance.d.ts +2 -0
  49. package/{substance.js → units/substance.js} +1 -1
  50. package/units/temperature.d.ts +4 -0
  51. package/{temperature.js → units/temperature.js} +1 -1
  52. package/units/time.d.ts +11 -0
  53. package/{time.js → units/time.js} +1 -1
  54. package/units/velocity.d.ts +6 -0
  55. package/units/velocity.js +8 -0
  56. package/units/volume.d.ts +15 -0
  57. package/{volume.js → units/volume.js} +1 -1
  58. package/accel.d.ts +0 -5
  59. package/angle.d.ts +0 -8
  60. package/area.d.ts +0 -10
  61. package/data.d.ts +0 -25
  62. package/electric.d.ts +0 -24
  63. package/energy.d.ts +0 -7
  64. package/force.d.ts +0 -2
  65. package/frequency.d.ts +0 -9
  66. package/length.d.ts +0 -20
  67. package/luminous.d.ts +0 -4
  68. package/mass.d.ts +0 -11
  69. package/parts.d.ts +0 -8
  70. package/power.d.ts +0 -9
  71. package/pressure.d.ts +0 -9
  72. package/speed.d.ts +0 -6
  73. package/substance.d.ts +0 -2
  74. package/temperature.d.ts +0 -4
  75. package/time.d.ts +0 -11
  76. package/volume.d.ts +0 -15
package/unit.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { IDeref } from "@thi.ng/api";
1
2
  import { Dimensions, MaybeUnit, NamedUnit, Prefix, Unit } from "./api.js";
2
3
  /**
3
4
  * Cache/registry for all units defined via {@link defUnit}.
@@ -68,31 +69,99 @@ export declare const asUnit: (id: string) => Unit;
68
69
  * @param coherent
69
70
  */
70
71
  export declare const prefix: (id: Prefix, unit: MaybeUnit, coherent?: boolean) => Unit;
72
+ type QUnit<T extends number | number[]> = T extends number ? Unit : Unit[];
71
73
  /**
72
- * Derives a new unit as the product of the given units. If `coherent` is true
73
- * (default: false), the new unit itself is considered coherent and can be
74
- * prefixed later.
74
+ * Wrapper for scalar or vector quantities. See {@link quantity}.
75
+ */
76
+ export declare class Quantity<T extends number | number[]> implements IDeref<T> {
77
+ readonly value: QUnit<T>;
78
+ constructor(value: QUnit<T>);
79
+ deref(): T;
80
+ }
81
+ /**
82
+ * Creates a new {@link Quantity}, i.e. a certain finite amount of a given unit.
83
+ * `value` can be a number or vector.
84
+ *
85
+ * @remarks
86
+ * The quantities can then be used for calculations & conversions using the
87
+ * polymorphic functions: {@link div}, {@link mul}, {@link reciprocal} and
88
+ * {@link convert}.
89
+ *
90
+ * The {@link Quantity} class also implements the standard [`IDeref`]()
91
+ * interface to obtain unwrapped amount (though only should be used for
92
+ * dimensionless quantities). Use {@link convert} otherwise!
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const speedOfLight = quantity(299792458, "m/s");
97
+ *
98
+ * // compute wavelength of a WiFi signal in millimeters
99
+ * convert(div(speedOfLight, quantity(2.4,"GHz")), "mm");
100
+ * // 124.9135
101
+ *
102
+ * // DIN A4 paper size
103
+ * const A4 = quantity([210, 297], "mm");
104
+ *
105
+ * // convert paper size to inches
106
+ * convert(A4, "in");
107
+ * // [ 8.2677, 11.6929 ]
108
+ *
109
+ * // or calculate pixel dimensions @ 300 dpi
110
+ * // the result of the product is dimensionless so we use NONE as target unit
111
+ * convert(mul(A4, quantity(300, "dpi")), NONE)
112
+ * // [ 2480.314960629921, 3507.8740157480315 ]
113
+ *
114
+ * // alternatively dimensionless units can be deref'd directly
115
+ * mul(A4, quantity(300, "dpi")).deref()
116
+ * // [ 2480.314960629921, 3507.8740157480315 ]
117
+ * ```
118
+ *
119
+ * @param value
120
+ * @param unit
121
+ */
122
+ export declare const quantity: <T extends number | number[]>(value: T, unit: MaybeUnit) => Quantity<T>;
123
+ /**
124
+ * Polymorphic function. Derives a new quantity or unit as the product of the
125
+ * given quantities/units.
126
+ *
127
+ * @remarks
128
+ * If given units and if `coherent` is true (default: false), the new unit
129
+ * itself is considered coherent and can be prefixed later.
75
130
  *
76
131
  * @param a
77
132
  * @param b
78
133
  * @param coherent
79
134
  */
80
- export declare const mul: (a: MaybeUnit, b: MaybeUnit | number, coherent?: boolean) => Unit;
135
+ export declare function mul(a: Quantity<number>, b: Quantity<number>): Quantity<number>;
136
+ export declare function mul(a: Quantity<number>, b: Quantity<number[]>): Quantity<number[]>;
137
+ export declare function mul(a: Quantity<number[]>, b: Quantity<number>): Quantity<number[]>;
138
+ export declare function mul(a: Quantity<number[]>, b: Quantity<number[]>): Quantity<number[]>;
139
+ export declare function mul(a: MaybeUnit, b: MaybeUnit | number, coherent?: boolean): Unit;
81
140
  /**
82
- * Derives a new unit via the division of the given units. If `coherent` is true
83
- * (default: false), the new unit itself is considered coherent and can be
84
- * prefixed later.
141
+ * Polymorphic function. Derives a new quantity or unit via the division of the
142
+ * given quantities/units.
143
+ *
144
+ * @remarks
145
+ * If given units and if `coherent` is true (default: false), the new unit
146
+ * itself is considered coherent and can be prefixed later.
85
147
  *
86
148
  * @param a
87
149
  * @param b
88
150
  * @param coherent
89
151
  */
90
- export declare const div: (a: MaybeUnit, b: MaybeUnit | number, coherent?: boolean) => Unit;
152
+ export declare function div(a: Quantity<number>, b: Quantity<number>): Quantity<number>;
153
+ export declare function div(a: Quantity<number>, b: Quantity<number[]>): Quantity<number[]>;
154
+ export declare function div(a: Quantity<number[]>, b: Quantity<number>): Quantity<number[]>;
155
+ export declare function div(a: Quantity<number[]>, b: Quantity<number[]>): Quantity<number[]>;
156
+ export declare function div(a: MaybeUnit, b: MaybeUnit | number, coherent?: boolean): Unit;
91
157
  /**
92
- * Creates the reciprocal version of given unit (i.e. all SI dimensions will
93
- * flip sign) and the scale factor of the new unit will be `1/scale`. If
94
- * `coherent` is true (default: false), the new unit itself is considered
95
- * coherent and can be prefixed later.
158
+ * Polymorphic function. Creates the reciprocal version of given quantity or
159
+ * unit (i.e. all SI dimensions will flip sign) and the scale factor of the new
160
+ * unit will be `1/scale`.
161
+ *
162
+ * @remarks
163
+ * If given a unit and if `coherent` is true (default: false), the new unit
164
+ * itself is considered coherent and can be prefixed later.
96
165
  *
97
166
  * @example
98
167
  * ```ts
@@ -102,7 +171,9 @@ export declare const div: (a: MaybeUnit, b: MaybeUnit | number, coherent?: boole
102
171
  * @param u
103
172
  * @param coherent
104
173
  */
105
- export declare const reciprocal: (u: MaybeUnit, coherent?: boolean) => Unit;
174
+ export declare function reciprocal(u: Quantity<number>): Quantity<number>;
175
+ export declare function reciprocal(u: Quantity<number[]>): Quantity<number[]>;
176
+ export declare function reciprocal(u: MaybeUnit, coherent?: boolean): Unit;
106
177
  /**
107
178
  * Raises given unit to power `k`. If `coherent` is true (default: false), the
108
179
  * new unit itself is considered coherent and can be prefixed later.
@@ -121,8 +192,11 @@ export declare const reciprocal: (u: MaybeUnit, coherent?: boolean) => Unit;
121
192
  */
122
193
  export declare const pow: (u: MaybeUnit, k: number, coherent?: boolean) => Unit;
123
194
  /**
124
- * Attempts to convert `x` from `src` unit into `dest` unit. Throws an error if
125
- * units are incompatible.
195
+ * Polymorphic function. If given a {@link Quantity}, attempts to convert it to
196
+ * given `dest` unit and returns result as raw/unwrapped value (or vector).
197
+ * Otherwise, attempts to convert `x` amount from `src` unit into `dest` unit
198
+ * and returns result. In all cases an error is thrown if units are
199
+ * incompatible.
126
200
  *
127
201
  * @remarks
128
202
  * Units can only be converted if their SI dimensions are compatible. See
@@ -132,20 +206,21 @@ export declare const pow: (u: MaybeUnit, k: number, coherent?: boolean) => Unit;
132
206
  * @param src
133
207
  * @param dest
134
208
  */
135
- export declare const convert: (x: number, src: MaybeUnit, dest: MaybeUnit) => number;
209
+ export declare function convert<T extends number | number[]>(x: Quantity<T>, dest: MaybeUnit): T;
210
+ export declare function convert(x: number, src: MaybeUnit, dest: MaybeUnit): number;
136
211
  /**
137
- * Returns true if `src` unit is convertible to `dest`.
212
+ * Returns true if `src` quantity or unit is convertible to `dest` unit.
138
213
  *
139
214
  * @param src
140
215
  * @param dest
141
216
  */
142
- export declare const isConvertible: (src: MaybeUnit, dest: MaybeUnit) => boolean;
217
+ export declare const isConvertible: (src: Quantity<any> | MaybeUnit, dest: MaybeUnit) => boolean;
143
218
  /**
144
- * Returns true, if `u` is a dimensionless unit.
219
+ * Returns true, if `u` is a dimensionless quantity or unit.
145
220
  *
146
221
  * @param u
147
222
  */
148
- export declare const isDimensionless: (u: MaybeUnit) => boolean;
223
+ export declare const isDimensionless: (u: Quantity<any> | MaybeUnit) => boolean;
149
224
  /**
150
225
  * Returns true if the two given units are reciprocal to each other (and
151
226
  * therefore can be used for conversion).
@@ -154,5 +229,12 @@ export declare const isDimensionless: (u: MaybeUnit) => boolean;
154
229
  * @param b
155
230
  */
156
231
  export declare const isReciprocal: (a: MaybeUnit, b: MaybeUnit) => boolean;
157
- export declare const formatSI: (u: MaybeUnit) => string;
232
+ /**
233
+ * Polymorphic function. Returns formatted version of given quantity's or unit's
234
+ * SI dimension vector.
235
+ *
236
+ * @param u
237
+ */
238
+ export declare const formatSI: (u: Quantity<any> | MaybeUnit) => string;
239
+ export {};
158
240
  //# sourceMappingURL=unit.d.ts.map
package/unit.js CHANGED
@@ -1,9 +1,10 @@
1
+ import { isArray } from "@thi.ng/checks";
1
2
  import { isNumber } from "@thi.ng/checks/is-number";
2
3
  import { isString } from "@thi.ng/checks/is-string";
3
4
  import { equivArrayLike } from "@thi.ng/equiv";
4
5
  import { assert } from "@thi.ng/errors/assert";
5
6
  import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
6
- import { PREFIXES, } from "./api.js";
7
+ import { NONE, PREFIXES, } from "./api.js";
7
8
  /**
8
9
  * Cache/registry for all units defined via {@link defUnit}.
9
10
  */
@@ -39,7 +40,7 @@ export const coherent = (dim) => unit(dim, 1, 0, true);
39
40
  * @param offset
40
41
  * @param coherent
41
42
  */
42
- export const dimensionless = (scale, offset = 0, coherent = false) => unit([0, 0, 0, 0, 0, 0, 0], scale, offset, coherent);
43
+ export const dimensionless = (scale, offset = 0, coherent = false) => unit(NONE.dim, scale, offset, coherent);
43
44
  /**
44
45
  * Takes a unit symbol, full unit name and pre-defined {@link Unit} impl and
45
46
  * registers it in the {@link UNITS} cache for further lookups by symbol name.
@@ -71,7 +72,9 @@ export const asUnit = (id) => {
71
72
  if (unit) {
72
73
  return PREFIXES[pre] !== undefined
73
74
  ? prefix(pre, unit)
74
- : unit;
75
+ : !pre
76
+ ? unit
77
+ : illegalArgs(`unknown unit: ${id}`);
75
78
  }
76
79
  }
77
80
  for (let u in UNITS) {
@@ -103,54 +106,88 @@ export const prefix = (id, unit, coherent = false) => {
103
106
  : illegalArgs("unit isn't coherent");
104
107
  };
105
108
  /**
106
- * Derives a new unit as the product of the given units. If `coherent` is true
107
- * (default: false), the new unit itself is considered coherent and can be
108
- * prefixed later.
109
+ * Wrapper for scalar or vector quantities. See {@link quantity}.
110
+ */
111
+ export class Quantity {
112
+ constructor(value) {
113
+ this.value = value;
114
+ }
115
+ deref() {
116
+ return ((isArray(this.value)
117
+ ? this.value.map((x) => x.scale)
118
+ : this.value.scale));
119
+ }
120
+ }
121
+ /**
122
+ * Creates a new {@link Quantity}, i.e. a certain finite amount of a given unit.
123
+ * `value` can be a number or vector.
109
124
  *
110
- * @param a
111
- * @param b
112
- * @param coherent
125
+ * @remarks
126
+ * The quantities can then be used for calculations & conversions using the
127
+ * polymorphic functions: {@link div}, {@link mul}, {@link reciprocal} and
128
+ * {@link convert}.
129
+ *
130
+ * The {@link Quantity} class also implements the standard [`IDeref`]()
131
+ * interface to obtain unwrapped amount (though only should be used for
132
+ * dimensionless quantities). Use {@link convert} otherwise!
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * const speedOfLight = quantity(299792458, "m/s");
137
+ *
138
+ * // compute wavelength of a WiFi signal in millimeters
139
+ * convert(div(speedOfLight, quantity(2.4,"GHz")), "mm");
140
+ * // 124.9135
141
+ *
142
+ * // DIN A4 paper size
143
+ * const A4 = quantity([210, 297], "mm");
144
+ *
145
+ * // convert paper size to inches
146
+ * convert(A4, "in");
147
+ * // [ 8.2677, 11.6929 ]
148
+ *
149
+ * // or calculate pixel dimensions @ 300 dpi
150
+ * // the result of the product is dimensionless so we use NONE as target unit
151
+ * convert(mul(A4, quantity(300, "dpi")), NONE)
152
+ * // [ 2480.314960629921, 3507.8740157480315 ]
153
+ *
154
+ * // alternatively dimensionless units can be deref'd directly
155
+ * mul(A4, quantity(300, "dpi")).deref()
156
+ * // [ 2480.314960629921, 3507.8740157480315 ]
157
+ * ```
158
+ *
159
+ * @param value
160
+ * @param unit
113
161
  */
114
- export const mul = (a, b, coherent = false) => {
162
+ export const quantity = (value, unit) => new Quantity(((isNumber(value)
163
+ ? mul(unit, value)
164
+ : value.map((x) => mul(unit, x)))));
165
+ export function mul(a, b, coherent = false) {
166
+ if (a instanceof Quantity)
167
+ return __combineQ(mul, a, b);
115
168
  const $a = __ensureUnit(a);
116
- if (isNumber(b)) {
169
+ if (isNumber(b))
117
170
  return unit($a.dim, $a.scale * b, $a.offset, coherent);
118
- }
119
171
  const $b = __ensureUnit(b);
120
172
  return unit($a.dim.map((x, i) => x + $b.dim[i]), $a.scale * $b.scale, 0, coherent);
121
- };
122
- /**
123
- * Derives a new unit via the division of the given units. If `coherent` is true
124
- * (default: false), the new unit itself is considered coherent and can be
125
- * prefixed later.
126
- *
127
- * @param a
128
- * @param b
129
- * @param coherent
130
- */
131
- export const div = (a, b, coherent = false) => {
173
+ }
174
+ export function div(a, b, coherent = false) {
175
+ if (a instanceof Quantity)
176
+ return __combineQ(div, a, b);
132
177
  const $a = __ensureUnit(a);
133
178
  if (isNumber(b)) {
134
179
  return unit($a.dim, $a.scale / b, $a.offset, coherent);
135
180
  }
136
181
  const $b = __ensureUnit(b);
137
182
  return unit($a.dim.map((x, i) => x - $b.dim[i]), $a.scale / $b.scale, 0, coherent);
138
- };
139
- /**
140
- * Creates the reciprocal version of given unit (i.e. all SI dimensions will
141
- * flip sign) and the scale factor of the new unit will be `1/scale`. If
142
- * `coherent` is true (default: false), the new unit itself is considered
143
- * coherent and can be prefixed later.
144
- *
145
- * @example
146
- * ```ts
147
- * const HZ = reciprocal(S, true);
148
- * ```
149
- *
150
- * @param u
151
- * @param coherent
152
- */
153
- export const reciprocal = (u, coherent = false) => div(dimensionless(1), u, coherent);
183
+ }
184
+ export function reciprocal(u, coherent = false) {
185
+ return u instanceof Quantity
186
+ ? new Quantity(isArray(u.value)
187
+ ? u.value.map((x) => div(NONE, x))
188
+ : div(NONE, u.value))
189
+ : div(NONE, u, coherent);
190
+ }
154
191
  /**
155
192
  * Raises given unit to power `k`. If `coherent` is true (default: false), the
156
193
  * new unit itself is considered coherent and can be prefixed later.
@@ -171,44 +208,41 @@ export const pow = (u, k, coherent = false) => {
171
208
  const $u = __ensureUnit(u);
172
209
  return unit($u.dim.map((x) => x * k), $u.scale ** k, 0, coherent);
173
210
  };
174
- /**
175
- * Attempts to convert `x` from `src` unit into `dest` unit. Throws an error if
176
- * units are incompatible.
177
- *
178
- * @remarks
179
- * Units can only be converted if their SI dimensions are compatible. See
180
- * {@link isConvertible}.
181
- *
182
- * @param x
183
- * @param src
184
- * @param dest
185
- */
186
- export const convert = (x, src, dest) => {
187
- const $src = __ensureUnit(src);
188
- const $dest = __ensureUnit(dest);
211
+ export function convert(x, a, b) {
212
+ const $src = __ensureUnit(a);
213
+ if (x instanceof Quantity) {
214
+ return isArray(x.value)
215
+ ? x.value.map((y) => convert(1, y, $src))
216
+ : convert(1, x.value, $src);
217
+ }
218
+ const $dest = __ensureUnit(b);
189
219
  const xnorm = x * $src.scale + $src.offset;
190
220
  if (isReciprocal($src, $dest))
191
221
  return (1 / xnorm - $dest.offset) / $dest.scale;
192
222
  assert(equivArrayLike($src.dim, $dest.dim), "incompatible dimensions");
193
223
  return (xnorm - $dest.offset) / $dest.scale;
194
- };
224
+ }
195
225
  /**
196
- * Returns true if `src` unit is convertible to `dest`.
226
+ * Returns true if `src` quantity or unit is convertible to `dest` unit.
197
227
  *
198
228
  * @param src
199
229
  * @param dest
200
230
  */
201
231
  export const isConvertible = (src, dest) => {
232
+ if (src instanceof Quantity)
233
+ return isConvertible(__qunit(src), dest);
202
234
  const $src = __ensureUnit(src);
203
235
  const $dest = __ensureUnit(dest);
204
236
  return isReciprocal($src, $dest) || equivArrayLike($src.dim, $dest.dim);
205
237
  };
206
238
  /**
207
- * Returns true, if `u` is a dimensionless unit.
239
+ * Returns true, if `u` is a dimensionless quantity or unit.
208
240
  *
209
241
  * @param u
210
242
  */
211
- export const isDimensionless = (u) => __ensureUnit(u).dim.every((x) => x === 0);
243
+ export const isDimensionless = (u) => u instanceof Quantity
244
+ ? isDimensionless(__qunit(u))
245
+ : __ensureUnit(u).dim.every((x) => x === 0);
212
246
  /**
213
247
  * Returns true if the two given units are reciprocal to each other (and
214
248
  * therefore can be used for conversion).
@@ -231,7 +265,15 @@ export const isReciprocal = (a, b) => {
231
265
  }
232
266
  return ok;
233
267
  };
268
+ /**
269
+ * Polymorphic function. Returns formatted version of given quantity's or unit's
270
+ * SI dimension vector.
271
+ *
272
+ * @param u
273
+ */
234
274
  export const formatSI = (u) => {
275
+ if (u instanceof Quantity)
276
+ return formatSI(__qunit(u));
235
277
  const { dim } = __ensureUnit(u);
236
278
  const SI = ["kg", "m", "s", "A", "K", "mol", "cd"];
237
279
  const acc = [];
@@ -250,3 +292,16 @@ const __oneHot = (x) => {
250
292
  dims[x] = 1;
251
293
  return dims;
252
294
  };
295
+ const __qunit = (q) => (isArray(q.value) ? q.value[0] : q.value);
296
+ const __combineQ = (op, a, b) => {
297
+ const $b = b;
298
+ const vecA = isArray(a.value);
299
+ const vecB = isArray($b.value);
300
+ return new Quantity(vecA
301
+ ? vecB
302
+ ? a.value.map((x, i) => op(x, $b.value[i]))
303
+ : a.value.map((x) => op(x, $b.value))
304
+ : vecB
305
+ ? $b.value.map((x) => op(a.value, x))
306
+ : op(a.value, $b.value));
307
+ };
@@ -0,0 +1,5 @@
1
+ export declare const m_s2: import("../api.js").NamedUnit;
2
+ export declare const ft_s2: import("../api.js").NamedUnit;
3
+ export declare const rad_s2: import("../api.js").NamedUnit;
4
+ export declare const g0: import("../api.js").NamedUnit;
5
+ //# sourceMappingURL=accel.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { rad } from "./angle.js";
2
2
  import { ft, m } from "./length.js";
3
3
  import { s } from "./time.js";
4
- import { defUnit, div, mul, pow } from "./unit.js";
4
+ import { defUnit, div, mul, pow } from "../unit.js";
5
5
  const s2 = pow(s, 2);
6
6
  export const m_s2 = defUnit("m/s2", "meter per second squared", div(m, s2));
7
7
  export const ft_s2 = defUnit("ft/s2", "foot per second squared", div(ft, s2));
@@ -0,0 +1,8 @@
1
+ export declare const rad: import("../api.js").NamedUnit;
2
+ export declare const deg: import("../api.js").NamedUnit;
3
+ export declare const gon: import("../api.js").NamedUnit;
4
+ export declare const turn: import("../api.js").NamedUnit;
5
+ export declare const arcmin: import("../api.js").NamedUnit;
6
+ export declare const arcsec: import("../api.js").NamedUnit;
7
+ export declare const sr: import("../api.js").NamedUnit;
8
+ //# sourceMappingURL=angle.d.ts.map
@@ -1,4 +1,4 @@
1
- import { defUnit, dimensionless, mul } from "./unit.js";
1
+ import { defUnit, dimensionless, mul } from "../unit.js";
2
2
  const PI = Math.PI;
3
3
  export const rad = defUnit("rad", "radian", dimensionless(1, 0, true));
4
4
  export const deg = defUnit("deg", "degree", mul(rad, PI / 180));
@@ -0,0 +1,10 @@
1
+ export declare const m2: import("../api.js").NamedUnit;
2
+ export declare const mm2: import("../api.js").NamedUnit;
3
+ export declare const cm2: import("../api.js").NamedUnit;
4
+ export declare const km2: import("../api.js").NamedUnit;
5
+ export declare const ha: import("../api.js").NamedUnit;
6
+ export declare const ac: import("../api.js").NamedUnit;
7
+ export declare const sqin: import("../api.js").NamedUnit;
8
+ export declare const sqft: import("../api.js").NamedUnit;
9
+ export declare const sqmi: import("../api.js").NamedUnit;
10
+ //# sourceMappingURL=area.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { cm, ft, inch, km, m, mi, mm } from "./length.js";
2
- import { defUnit, mul, pow } from "./unit.js";
2
+ import { defUnit, mul, pow } from "../unit.js";
3
3
  export const m2 = defUnit("m2", "square meter", pow(m, 2));
4
4
  export const mm2 = defUnit("mm2", "square millimeter", pow(mm, 2));
5
5
  export const cm2 = defUnit("cm2", "square centimeter", pow(cm, 2));
@@ -0,0 +1,25 @@
1
+ export declare const bit: import("../api.js").NamedUnit;
2
+ export declare const kbit: import("../api.js").NamedUnit;
3
+ export declare const Mbit: import("../api.js").NamedUnit;
4
+ export declare const Gbit: import("../api.js").NamedUnit;
5
+ export declare const Tbit: import("../api.js").NamedUnit;
6
+ export declare const B: import("../api.js").NamedUnit;
7
+ export declare const kB: import("../api.js").NamedUnit;
8
+ export declare const MB: import("../api.js").NamedUnit;
9
+ export declare const GB: import("../api.js").NamedUnit;
10
+ export declare const TB: import("../api.js").NamedUnit;
11
+ export declare const PB: import("../api.js").NamedUnit;
12
+ export declare const EB: import("../api.js").NamedUnit;
13
+ export declare const Kibit: import("../api.js").NamedUnit;
14
+ export declare const Mibit: import("../api.js").NamedUnit;
15
+ export declare const Gibit: import("../api.js").NamedUnit;
16
+ export declare const Tibit: import("../api.js").NamedUnit;
17
+ export declare const Pibit: import("../api.js").NamedUnit;
18
+ export declare const Eibit: import("../api.js").NamedUnit;
19
+ export declare const KiB: import("../api.js").NamedUnit;
20
+ export declare const MiB: import("../api.js").NamedUnit;
21
+ export declare const GiB: import("../api.js").NamedUnit;
22
+ export declare const TiB: import("../api.js").NamedUnit;
23
+ export declare const PiB: import("../api.js").NamedUnit;
24
+ export declare const EiB: import("../api.js").NamedUnit;
25
+ //# sourceMappingURL=data.d.ts.map
@@ -1,4 +1,4 @@
1
- import { defUnit, dimensionless, mul, prefix } from "./unit.js";
1
+ import { defUnit, dimensionless, mul, prefix } from "../unit.js";
2
2
  export const bit = defUnit("bit", "bit", dimensionless(1, 0, true));
3
3
  export const kbit = defUnit("kbit", "kilobit", prefix("k", bit));
4
4
  export const Mbit = defUnit("Mbit", "megabit", prefix("M", bit));
@@ -0,0 +1,3 @@
1
+ export declare const kg_m3: import("../api.js").NamedUnit;
2
+ export declare const dpi: import("../api.js").NamedUnit;
3
+ //# sourceMappingURL=density.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { inch } from "./length.js";
2
+ import { kg } from "./mass.js";
3
+ import { defUnit, div, reciprocal } from "../unit.js";
4
+ import { m3 } from "./volume.js";
5
+ export const kg_m3 = defUnit("kg/m3", "kilogram per cubic meter", div(kg, m3));
6
+ export const dpi = defUnit("dpi", "dots per inch", reciprocal(inch));
@@ -0,0 +1,24 @@
1
+ export declare const A: import("../api.js").NamedUnit;
2
+ export declare const mA: import("../api.js").NamedUnit;
3
+ export declare const mAh: import("../api.js").NamedUnit;
4
+ export declare const C: import("../api.js").NamedUnit;
5
+ export declare const V: import("../api.js").NamedUnit;
6
+ export declare const mV: import("../api.js").NamedUnit;
7
+ export declare const kV: import("../api.js").NamedUnit;
8
+ export declare const MV: import("../api.js").NamedUnit;
9
+ export declare const F: import("../api.js").NamedUnit;
10
+ export declare const pF: import("../api.js").NamedUnit;
11
+ export declare const µF: import("../api.js").NamedUnit;
12
+ export declare const Ω: import("../api.js").NamedUnit;
13
+ export declare const kΩ: import("../api.js").NamedUnit;
14
+ export declare const MΩ: import("../api.js").NamedUnit;
15
+ export declare const GΩ: import("../api.js").NamedUnit;
16
+ export declare const ohm: import("../api.js").NamedUnit;
17
+ export declare const kohm: import("../api.js").NamedUnit;
18
+ export declare const Mohm: import("../api.js").NamedUnit;
19
+ export declare const Gohm: import("../api.js").NamedUnit;
20
+ export declare const S: import("../api.js").NamedUnit;
21
+ export declare const Wb: import("../api.js").NamedUnit;
22
+ export declare const T: import("../api.js").NamedUnit;
23
+ export declare const H: import("../api.js").NamedUnit;
24
+ //# sourceMappingURL=electric.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { m2 } from "./area.js";
2
2
  import { J } from "./energy.js";
3
3
  import { h, s } from "./time.js";
4
- import { coherent, defUnit, div, mul, prefix } from "./unit.js";
4
+ import { coherent, defUnit, div, mul, prefix } from "../unit.js";
5
5
  export const A = defUnit("A", "ampere", coherent(3));
6
6
  export const mA = defUnit("mA", "milliampere", prefix("m", A));
7
7
  export const mAh = defUnit("mAh", "milliampere-hour", mul(mA, h));
@@ -0,0 +1,7 @@
1
+ export declare const J: import("../api.js").NamedUnit;
2
+ export declare const kJ: import("../api.js").NamedUnit;
3
+ export declare const MJ: import("../api.js").NamedUnit;
4
+ export declare const GJ: import("../api.js").NamedUnit;
5
+ export declare const cal: import("../api.js").NamedUnit;
6
+ export declare const kcal: import("../api.js").NamedUnit;
7
+ //# sourceMappingURL=energy.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { N } from "./force.js";
2
2
  import { m } from "./length.js";
3
- import { defUnit, mul, prefix } from "./unit.js";
3
+ import { defUnit, mul, prefix } from "../unit.js";
4
4
  export const J = defUnit("J", "joule", mul(N, m, true));
5
5
  export const kJ = defUnit("kJ", "kilojoule", prefix("k", J));
6
6
  export const MJ = defUnit("MJ", "megajoule", prefix("M", J));
@@ -0,0 +1,2 @@
1
+ export declare const N: import("../api.js").NamedUnit;
2
+ //# sourceMappingURL=force.d.ts.map
@@ -1,4 +1,4 @@
1
1
  import { m_s2 } from "./accel.js";
2
2
  import { kg } from "./mass.js";
3
- import { defUnit, mul } from "./unit.js";
3
+ import { defUnit, mul } from "../unit.js";
4
4
  export const N = defUnit("N", "newton", mul(kg, m_s2, true));
@@ -0,0 +1,9 @@
1
+ export declare const Hz: import("../api.js").NamedUnit;
2
+ export declare const kHz: import("../api.js").NamedUnit;
3
+ export declare const MHz: import("../api.js").NamedUnit;
4
+ export declare const GHz: import("../api.js").NamedUnit;
5
+ export declare const THz: import("../api.js").NamedUnit;
6
+ export declare const rpm: import("../api.js").NamedUnit;
7
+ export declare const ω: import("../api.js").NamedUnit;
8
+ export declare const omega: import("../api.js").NamedUnit;
9
+ //# sourceMappingURL=frequency.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { s } from "./time.js";
2
- import { defUnit, div, mul, prefix, reciprocal } from "./unit.js";
2
+ import { defUnit, div, mul, prefix, reciprocal } from "../unit.js";
3
3
  export const Hz = defUnit("Hz", "hertz", reciprocal(s, true));
4
4
  export const kHz = defUnit("kHz", "kilohertz", prefix("k", Hz));
5
5
  export const MHz = defUnit("MHz", "megahertz", prefix("M", Hz));
@@ -0,0 +1,20 @@
1
+ export declare const m: import("../api.js").NamedUnit;
2
+ export declare const km: import("../api.js").NamedUnit;
3
+ export declare const cm: import("../api.js").NamedUnit;
4
+ export declare const mm: import("../api.js").NamedUnit;
5
+ export declare const µm: import("../api.js").NamedUnit;
6
+ export declare const nm: import("../api.js").NamedUnit;
7
+ export declare const angstrom: import("../api.js").NamedUnit;
8
+ export declare const au: import("../api.js").NamedUnit;
9
+ export declare const ly: import("../api.js").NamedUnit;
10
+ export declare const pc: import("../api.js").NamedUnit;
11
+ export declare const inch: import("../api.js").NamedUnit;
12
+ export declare const mil: import("../api.js").NamedUnit;
13
+ export declare const thou: import("../api.js").NamedUnit;
14
+ export declare const ft: import("../api.js").NamedUnit;
15
+ export declare const yd: import("../api.js").NamedUnit;
16
+ export declare const mi: import("../api.js").NamedUnit;
17
+ export declare const nmi: import("../api.js").NamedUnit;
18
+ export declare const pica: import("../api.js").NamedUnit;
19
+ export declare const point: import("../api.js").NamedUnit;
20
+ //# sourceMappingURL=length.d.ts.map
@@ -1,4 +1,4 @@
1
- import { coherent, defUnit, mul, prefix } from "./unit.js";
1
+ import { coherent, defUnit, mul, prefix } from "../unit.js";
2
2
  export const m = defUnit("m", "meter", coherent(1));
3
3
  export const km = defUnit("km", "kilometer", prefix("k", m));
4
4
  export const cm = defUnit("cm", "centimeter", prefix("c", m));
@@ -0,0 +1,4 @@
1
+ export declare const cd: import("../api.js").NamedUnit;
2
+ export declare const lm: import("../api.js").NamedUnit;
3
+ export declare const lx: import("../api.js").NamedUnit;
4
+ //# sourceMappingURL=luminous.d.ts.map