-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(NumberBetween): use
MinMax
interface and add possibility t…
…o set the number type, update jsdoc.
- Loading branch information
1 parent
98a2722
commit 1263a2e
Showing
1 changed file
with
10 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
// Type. | ||
import { AnyNumber } from './any-number.type'; | ||
// Interface. | ||
import { MinMax } from '../interface/min-max.interface'; | ||
/** | ||
* A `number` type or an instance of a `Number` with the specified range. | ||
* Generic variables `Min` and `Max` are constrained with the `number` type. | ||
* A generic type `NumberBetween` that takes generic type variable `Min` and `Max` constrained by `number` type as range, and takes generic | ||
* type variable `Type` constrained by `AnyNumber` as the type by default `number` or an instance of `Number`. | ||
*/ | ||
export type NumberBetween<Min extends number, Max extends number> = | ||
AnyNumber & { | ||
min: Min; | ||
max: Max; | ||
}; | ||
export type NumberBetween< | ||
Min extends number, | ||
Max extends number, | ||
Type extends AnyNumber = number | ||
> = Type & MinMax<Min, Max>; |