Skip to content

Commit

Permalink
refactor(NumberBetween): use MinMax interface and add possibility t…
Browse files Browse the repository at this point in the history
…o set the number type, update jsdoc.
  • Loading branch information
sciborrudnicki committed Sep 20, 2021
1 parent 98a2722 commit 1263a2e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/type/number-between.type.ts
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>;

0 comments on commit 1263a2e

Please sign in to comment.