generated from RebeccaStevens/template-typescript-node-package
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26f3df5
commit 6f15ac9
Showing
5 changed files
with
70 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { type Unit, type UnitValue, type UnknownUnit } from "./core"; | ||
import { | ||
type DivideExponents, | ||
type Exponent, | ||
type MultiplyExponents, | ||
} from "./exponents"; | ||
import { | ||
type FlatternAlias, | ||
type GetUnitConfig, | ||
type GetUnitValues, | ||
} from "./utils"; | ||
|
||
export type MultiplyUnitExponents< | ||
A extends number, | ||
B extends 2, | ||
> = A extends UnknownUnit | ||
? MultiplyUnitExponentsCore<A, B> extends Record<string, UnitValue> | ||
? Unit<FlatternAlias<MultiplyUnitExponentsCore<A, B>>> | ||
: never | ||
: number; | ||
|
||
type MultiplyUnitExponentsCore<A extends UnknownUnit, B extends 2> = { | ||
[U in keyof GetUnitConfig<A>]: { | ||
[E in keyof GetUnitConfig<A>[U]]: MultiplyExponents< | ||
E extends keyof GetUnitValues<GetUnitConfig<A>, U> | ||
? GetUnitValues<GetUnitConfig<A>, U>[E] extends Exponent | ||
? GetUnitValues<GetUnitConfig<A>, U>[E] | ||
: 0 | ||
: 0, | ||
B | ||
>; | ||
}; | ||
}; | ||
|
||
export type DivideUnitExponents< | ||
A extends number, | ||
B extends 2, | ||
> = A extends UnknownUnit | ||
? DivideUnitExponentsCore<A, B> extends Record<string, UnitValue> | ||
? Unit<FlatternAlias<DivideUnitExponentsCore<A, B>>> | ||
: never | ||
: number; | ||
|
||
type DivideUnitExponentsCore<A extends UnknownUnit, B extends 2> = { | ||
[U in keyof GetUnitConfig<A>]: { | ||
[E in keyof GetUnitConfig<A>[U]]: DivideExponents< | ||
E extends keyof GetUnitValues<GetUnitConfig<A>, U> | ||
? GetUnitValues<GetUnitConfig<A>, U>[E] extends Exponent | ||
? GetUnitValues<GetUnitConfig<A>, U>[E] | ||
: 0 | ||
: 0, | ||
B | ||
>; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters