uom-types 4.1.1 → 5.0.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,25 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file. Dates are displayed in UTC.
3
3
 
4
+ # [5.0.0](https://github.com/RebeccaStevens/uom-types/compare/v4.1.2...v5.0.0) (2024-11-27)
5
+
6
+
7
+ ### Features
8
+
9
+ * drop support for node 16 ([c701cf3](https://github.com/RebeccaStevens/uom-types/commit/c701cf37a8b433bf5daa3269a6c5c00a66f8361a))
10
+
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * drop support for node 16
15
+
16
+ ## [4.1.2](https://github.com/RebeccaStevens/uom-types/compare/v4.1.1...v4.1.2) (2024-10-18)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * extend branding interface to unit-keys-value ([165603c](https://github.com/RebeccaStevens/uom-types/commit/165603c1fe9beaf2c523218e78778ee152fc7c87))
22
+
4
23
  ## [4.1.1](https://github.com/RebeccaStevens/uom-types/compare/v4.1.0...v4.1.1) (2024-10-18)
5
24
 
6
25
 
package/dist/index.d.cts CHANGED
@@ -70,6 +70,15 @@ export type BrandUnitClassType = Brand & {
70
70
  unitClassType: true;
71
71
  };
72
72
  };
73
+ /**
74
+ * Brand with the unit keys and value.
75
+ */
76
+ export type BrandUnitKeyValues<K, V> = Brand & Readonly<{
77
+ __uom_types: {
78
+ keys: K;
79
+ value: V;
80
+ };
81
+ }>;
73
82
  /**
74
83
  * Remove all key from the object that are `never`.
75
84
  */
@@ -192,14 +201,14 @@ export type UnknownUnitClass = UnknownUnitKeyValues & BrandUnitClassType;
192
201
  export type UnknownUnitMeta = UnknownUnitKeyValues & Readonly<{
193
202
  __uno_types__unit_meta_type: true;
194
203
  }>;
195
- export type UnitKeyValues<T extends UnitSubvalues> = Readonly<{
196
- __uom_types__keys: keyof ExcludeUnitZeroSubvalues<T> extends string ? keyof ExcludeUnitZeroSubvalues<T> : never;
197
- __uom_types__value: RemoveNeverValues<T>;
198
- }>;
199
- export type UnknownUnitKeyValues = Readonly<{
200
- __uom_types__keys: string;
201
- __uom_types__value: {};
202
- }>;
204
+ /**
205
+ * @internal
206
+ */
207
+ export type UnitKeyValues<T extends UnitSubvalues> = BrandUnitKeyValues<keyof ExcludeUnitZeroSubvalues<T> extends string ? keyof ExcludeUnitZeroSubvalues<T> : never, RemoveNeverValues<T>>;
208
+ /**
209
+ * @internal
210
+ */
211
+ export type UnknownUnitKeyValues = BrandUnitKeyValues<string, {}>;
203
212
  /**
204
213
  * A mapping of subvalue of a unit its magnitude.
205
214
  *
@@ -300,9 +309,7 @@ export type SiUnitKeys = "Second" | "Meter" | "Kilogram" | "Mole" | "Ampere" | "
300
309
  * @group Unit Classes
301
310
  */
302
311
  export type BaseUnitClass<T extends Exactify<SiUnitConfig, T>> = UnitClass<T>;
303
- export type SiUnitConfig = {
304
- [K in SiUnitKeys]?: Exponent;
305
- };
312
+ export type SiUnitConfig = Partial<Record<SiUnitKeys, Exponent>>;
306
313
  /**
307
314
  * @group Unit Classes
308
315
  * @category Angle (Plane)
@@ -1231,7 +1238,7 @@ export type HenryPerMeter = MagneticPermeabilityUnit<{}>;
1231
1238
  * @see {@link Pow}
1232
1239
  * @see {@link Cubic}
1233
1240
  */
1234
- export type Square<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Pow<T, 2> : T extends UnknownUnitClass ? UnitClass<PowUnitSubvalues<T["__uom_types__value"], 2>> : T extends UnknownUnitMeta ? UnitMeta<PowUnitSubvalues<T["__uom_types__value"], 2>> : never;
1241
+ export type Square<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Pow<T, 2> : T extends UnknownUnitClass ? UnitClass<PowUnitSubvalues<T["__uom_types"]["value"], 2>> : T extends UnknownUnitMeta ? UnitMeta<PowUnitSubvalues<T["__uom_types"]["value"], 2>> : never;
1235
1242
  /**
1236
1243
  * Put the given {@link Unit} to the power of 3.
1237
1244
  *
@@ -1240,7 +1247,7 @@ export type Square<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConv
1240
1247
  * @see {@link Pow}
1241
1248
  * @see {@link Square}
1242
1249
  */
1243
- export type Cubic<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Pow<T, 3> : T extends UnknownUnitClass ? UnitClass<PowUnitSubvalues<T["__uom_types__value"], 3>> : T extends UnknownUnitMeta ? UnitMeta<PowUnitSubvalues<T["__uom_types__value"], 3>> : never;
1250
+ export type Cubic<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Pow<T, 3> : T extends UnknownUnitClass ? UnitClass<PowUnitSubvalues<T["__uom_types"]["value"], 3>> : T extends UnknownUnitMeta ? UnitMeta<PowUnitSubvalues<T["__uom_types"]["value"], 3>> : never;
1244
1251
  /**
1245
1252
  * Binary prefix denoting an order of magnitude of 10^1.
1246
1253
  *
@@ -1355,7 +1362,7 @@ export type Pico<T extends UnknownUnit> = Multiply<T, UnitConversionRate<{
1355
1362
  * @group Modifiers
1356
1363
  * @category General
1357
1364
  */
1358
- export type Reciprocal<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Inverse<T> : T extends UnknownUnitClass ? UnitClass<InverseUnitSubvalues<T["__uom_types__value"]>> : T extends UnknownUnitMeta ? UnitMeta<InverseUnitSubvalues<T["__uom_types__value"]>> : never;
1365
+ export type Reciprocal<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Inverse<T> : T extends UnknownUnitClass ? UnitClass<InverseUnitSubvalues<T["__uom_types"]["value"]>> : T extends UnknownUnitMeta ? UnitMeta<InverseUnitSubvalues<T["__uom_types"]["value"]>> : never;
1359
1366
  /**
1360
1367
  * @group Unit Classes
1361
1368
  * @category Electromagnetic
package/dist/index.d.mts CHANGED
@@ -70,6 +70,15 @@ export type BrandUnitClassType = Brand & {
70
70
  unitClassType: true;
71
71
  };
72
72
  };
73
+ /**
74
+ * Brand with the unit keys and value.
75
+ */
76
+ export type BrandUnitKeyValues<K, V> = Brand & Readonly<{
77
+ __uom_types: {
78
+ keys: K;
79
+ value: V;
80
+ };
81
+ }>;
73
82
  /**
74
83
  * Remove all key from the object that are `never`.
75
84
  */
@@ -192,14 +201,14 @@ export type UnknownUnitClass = UnknownUnitKeyValues & BrandUnitClassType;
192
201
  export type UnknownUnitMeta = UnknownUnitKeyValues & Readonly<{
193
202
  __uno_types__unit_meta_type: true;
194
203
  }>;
195
- export type UnitKeyValues<T extends UnitSubvalues> = Readonly<{
196
- __uom_types__keys: keyof ExcludeUnitZeroSubvalues<T> extends string ? keyof ExcludeUnitZeroSubvalues<T> : never;
197
- __uom_types__value: RemoveNeverValues<T>;
198
- }>;
199
- export type UnknownUnitKeyValues = Readonly<{
200
- __uom_types__keys: string;
201
- __uom_types__value: {};
202
- }>;
204
+ /**
205
+ * @internal
206
+ */
207
+ export type UnitKeyValues<T extends UnitSubvalues> = BrandUnitKeyValues<keyof ExcludeUnitZeroSubvalues<T> extends string ? keyof ExcludeUnitZeroSubvalues<T> : never, RemoveNeverValues<T>>;
208
+ /**
209
+ * @internal
210
+ */
211
+ export type UnknownUnitKeyValues = BrandUnitKeyValues<string, {}>;
203
212
  /**
204
213
  * A mapping of subvalue of a unit its magnitude.
205
214
  *
@@ -300,9 +309,7 @@ export type SiUnitKeys = "Second" | "Meter" | "Kilogram" | "Mole" | "Ampere" | "
300
309
  * @group Unit Classes
301
310
  */
302
311
  export type BaseUnitClass<T extends Exactify<SiUnitConfig, T>> = UnitClass<T>;
303
- export type SiUnitConfig = {
304
- [K in SiUnitKeys]?: Exponent;
305
- };
312
+ export type SiUnitConfig = Partial<Record<SiUnitKeys, Exponent>>;
306
313
  /**
307
314
  * @group Unit Classes
308
315
  * @category Angle (Plane)
@@ -1231,7 +1238,7 @@ export type HenryPerMeter = MagneticPermeabilityUnit<{}>;
1231
1238
  * @see {@link Pow}
1232
1239
  * @see {@link Cubic}
1233
1240
  */
1234
- export type Square<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Pow<T, 2> : T extends UnknownUnitClass ? UnitClass<PowUnitSubvalues<T["__uom_types__value"], 2>> : T extends UnknownUnitMeta ? UnitMeta<PowUnitSubvalues<T["__uom_types__value"], 2>> : never;
1241
+ export type Square<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Pow<T, 2> : T extends UnknownUnitClass ? UnitClass<PowUnitSubvalues<T["__uom_types"]["value"], 2>> : T extends UnknownUnitMeta ? UnitMeta<PowUnitSubvalues<T["__uom_types"]["value"], 2>> : never;
1235
1242
  /**
1236
1243
  * Put the given {@link Unit} to the power of 3.
1237
1244
  *
@@ -1240,7 +1247,7 @@ export type Square<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConv
1240
1247
  * @see {@link Pow}
1241
1248
  * @see {@link Square}
1242
1249
  */
1243
- export type Cubic<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Pow<T, 3> : T extends UnknownUnitClass ? UnitClass<PowUnitSubvalues<T["__uom_types__value"], 3>> : T extends UnknownUnitMeta ? UnitMeta<PowUnitSubvalues<T["__uom_types__value"], 3>> : never;
1250
+ export type Cubic<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Pow<T, 3> : T extends UnknownUnitClass ? UnitClass<PowUnitSubvalues<T["__uom_types"]["value"], 3>> : T extends UnknownUnitMeta ? UnitMeta<PowUnitSubvalues<T["__uom_types"]["value"], 3>> : never;
1244
1251
  /**
1245
1252
  * Binary prefix denoting an order of magnitude of 10^1.
1246
1253
  *
@@ -1355,7 +1362,7 @@ export type Pico<T extends UnknownUnit> = Multiply<T, UnitConversionRate<{
1355
1362
  * @group Modifiers
1356
1363
  * @category General
1357
1364
  */
1358
- export type Reciprocal<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Inverse<T> : T extends UnknownUnitClass ? UnitClass<InverseUnitSubvalues<T["__uom_types__value"]>> : T extends UnknownUnitMeta ? UnitMeta<InverseUnitSubvalues<T["__uom_types__value"]>> : never;
1365
+ export type Reciprocal<T extends UnknownUnit | UnknownAbstractUnit | UnknownUnitConversionRate | UnknownUnitClass | UnknownUnitMeta> = T extends number ? Inverse<T> : T extends UnknownUnitClass ? UnitClass<InverseUnitSubvalues<T["__uom_types"]["value"]>> : T extends UnknownUnitMeta ? UnitMeta<InverseUnitSubvalues<T["__uom_types"]["value"]>> : never;
1359
1366
  /**
1360
1367
  * @group Unit Classes
1361
1368
  * @category Electromagnetic
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uom-types",
3
- "version": "4.1.1",
3
+ "version": "5.0.0",
4
4
  "description": "Typesafe units with no runtime overhead.",
5
5
  "keywords": [
6
6
  "uom",
@@ -77,83 +77,79 @@
77
77
  "test": "pnpm run test:js-run && pnpm run test:types",
78
78
  "test:js": "vitest --coverage",
79
79
  "test:js-run": "vitest run --coverage",
80
- "test:types": "pnpm run test:types-pre && tsd -t './dist/index.d.mts' -f 'tests/**/*.test-d.ts'",
80
+ "test:types": "pnpm run test:types-pre && tsd -t './dist/index.d.mts' -f 'src/**/*.test-d.ts'",
81
81
  "test:types-pre": "pnpm run build",
82
82
  "typecheck": "tsc -p tsconfig.build.json --noEmit"
83
83
  },
84
- "resolutions": {
85
- "dts-bundle-generator": "9.5.1"
86
- },
87
84
  "devDependencies": {
88
- "@commitlint/cli": "19.5.0",
89
- "@commitlint/config-conventional": "19.5.0",
85
+ "@commitlint/cli": "19.6.0",
86
+ "@commitlint/config-conventional": "19.6.0",
90
87
  "@cspell/dict-cryptocurrencies": "5.0.3",
91
- "@eslint/compat": "1.2.0",
92
- "@rebeccastevens/eslint-config": "3.3.2",
93
- "@rollup/plugin-replace": "6.0.1",
94
- "@rollup/plugin-typescript": "12.1.0",
95
- "@sebbo2002/semantic-release-jsr": "2.0.1",
88
+ "@eslint/compat": "1.2.3",
89
+ "@rebeccastevens/eslint-config": "3.3.3",
90
+ "@rollup/plugin-typescript": "12.1.1",
91
+ "@sebbo2002/semantic-release-jsr": "2.0.2",
96
92
  "@semantic-release/changelog": "6.0.3",
97
93
  "@semantic-release/commit-analyzer": "13.0.0",
98
94
  "@semantic-release/git": "10.0.1",
99
- "@semantic-release/github": "11.0.0",
95
+ "@semantic-release/github": "11.0.1",
100
96
  "@semantic-release/npm": "12.0.1",
101
97
  "@semantic-release/release-notes-generator": "14.0.1",
102
- "@stylistic/eslint-plugin": "2.9.0",
103
- "@types/node": "16.18.113",
104
- "@typescript-eslint/eslint-plugin": "8.9.0",
105
- "@typescript-eslint/parser": "8.9.0",
106
- "@vitest/coverage-v8": "2.1.2",
107
- "@vitest/eslint-plugin": "1.1.7",
98
+ "@stylistic/eslint-plugin": "2.11.0",
99
+ "@types/node": "18.19.66",
100
+ "@typescript-eslint/eslint-plugin": "8.16.0",
101
+ "@typescript-eslint/parser": "8.16.0",
102
+ "@vitest/coverage-v8": "2.1.6",
103
+ "@vitest/eslint-plugin": "1.1.11",
108
104
  "commitizen": "4.3.1",
109
- "cspell": "8.15.3",
105
+ "cspell": "8.16.1",
110
106
  "cz-conventional-changelog": "3.3.0",
111
- "eslint": "9.12.0",
107
+ "eslint": "9.15.0",
112
108
  "eslint-config-prettier": "9.1.0",
113
109
  "eslint-flat-config-utils": "0.4.0",
114
110
  "eslint-import-resolver-typescript": "3.6.3",
115
111
  "eslint-merge-processors": "0.1.0",
116
112
  "eslint-plugin-eslint-comments": "3.2.0",
117
113
  "eslint-plugin-format": "0.1.2",
118
- "eslint-plugin-functional": "7.0.2",
119
- "eslint-plugin-import-x": "4.3.1",
120
- "eslint-plugin-jsdoc": "50.4.1",
121
- "eslint-plugin-jsonc": "2.16.0",
114
+ "eslint-plugin-functional": "7.1.0",
115
+ "eslint-plugin-import-x": "4.4.3",
116
+ "eslint-plugin-jsdoc": "50.6.0",
117
+ "eslint-plugin-jsonc": "2.18.2",
122
118
  "eslint-plugin-markdown": "5.1.0",
123
- "eslint-plugin-n": "17.11.1",
119
+ "eslint-plugin-n": "17.14.0",
124
120
  "eslint-plugin-no-only-tests": "3.3.0",
125
121
  "eslint-plugin-optimize-regex": "1.2.1",
126
122
  "eslint-plugin-prettier": "5.2.1",
127
- "eslint-plugin-promise": "7.1.0",
128
- "eslint-plugin-regexp": "2.6.0",
129
- "eslint-plugin-sonarjs": "2.0.3",
130
- "eslint-plugin-unicorn": "56.0.0",
131
- "eslint-plugin-yml": "1.14.0",
123
+ "eslint-plugin-promise": "7.2.1",
124
+ "eslint-plugin-regexp": "2.7.0",
125
+ "eslint-plugin-sonarjs": "2.0.4",
126
+ "eslint-plugin-unicorn": "56.0.1",
127
+ "eslint-plugin-yml": "1.15.0",
132
128
  "http-serve": "1.0.1",
133
- "husky": "9.1.6",
129
+ "husky": "9.1.7",
134
130
  "jsonc-eslint-parser": "2.4.0",
135
- "knip": "5.33.3",
131
+ "knip": "5.38.1",
136
132
  "lint-staged": "15.2.10",
137
- "markdownlint-cli2": "0.14.0",
138
- "prettier": "3.3.3",
133
+ "markdownlint-cli2": "0.15.0",
134
+ "prettier": "3.4.1",
139
135
  "rimraf": "6.0.1",
140
- "rollup": "4.24.0",
136
+ "rollup": "4.27.4",
141
137
  "rollup-plugin-deassert": "1.3.0",
142
- "rollup-plugin-dts-bundle-generator": "1.4.0",
143
- "semantic-release": "24.1.2",
144
- "tsafe": "1.7.5",
138
+ "rollup-plugin-dts-bundle-generator-2": "1.0.2",
139
+ "semantic-release": "24.2.0",
140
+ "tsafe": "1.8.5",
145
141
  "tsc-files": "1.1.4",
146
142
  "tsd": "0.31.2",
147
- "tsx": "4.19.1",
148
- "typedoc": "0.26.9",
149
- "typedoc-plugin-coverage": "3.3.0",
150
- "typescript": "5.6.3",
151
- "vite-tsconfig-paths": "5.0.1",
152
- "vitest": "2.1.2",
143
+ "tsx": "4.19.2",
144
+ "typedoc": "0.26.11",
145
+ "typedoc-plugin-coverage": "3.4.0",
146
+ "typescript": "5.7.2",
147
+ "vite-tsconfig-paths": "5.1.3",
148
+ "vitest": "2.1.6",
153
149
  "yaml-eslint-parser": "1.2.3"
154
150
  },
155
- "packageManager": "pnpm@9.12.1",
151
+ "packageManager": "pnpm@9.14.2",
156
152
  "engines": {
157
- "node": ">=16.0.0"
153
+ "node": ">=18.0.0"
158
154
  }
159
155
  }