Skip to content

Commit

Permalink
fix: remove old types
Browse files Browse the repository at this point in the history
  • Loading branch information
unional committed Oct 4, 2023
1 parent dc6dba4 commit 25b5d31
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 610 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-rabbits-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"type-plus": major
---

Remove `Positive`, `Negative`, `NumericType`, `NotNumericType`,
146 changes: 118 additions & 28 deletions type-plus/ts/array/array_plus.index_at.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { GreaterThan } from '../math/greater_than.js'
import type { Subtract } from '../math/subtract.js'
import type { IsNever } from '../never/is_never.js'
import type { IsStrictNumber } from '../number/is_strict_number.js'
import type { Integer } from '../numeric/integer.js'
import type { Negative } from '../numeric/negative.js'
import type { IsInteger } from '../numeric/is_integer.js'
import type { IsNegative } from '../numeric/is_negative.js'
import type { $Else, $SelectionBranch, $Then } from '../type_plus/branch/selection.js'

/**
Expand Down Expand Up @@ -47,33 +47,123 @@ export namespace IndexAt {
A['length'],
0,
Fail,
Integer<
IsInteger<
N,
IsStrictNumber<
A['length'],
IsStrictNumber.$Branch
> extends infer R
// A: array
? R extends $Then ? N
// A: tuple
: R extends $Else ? Negative<
N,
GreaterThan<Abs<N>, A['length']> extends true ? Lower : Subtract<A['length'], Abs<N>>,
GreaterThan<A['length'], N> extends true ? N : Upper
>
: never : never,
// N: number or float
IsAny<
N,
{
$then: number,
$else: IsStrictNumber<
N,
IsStrictNumber.$Branch
> extends infer R
? R extends $Then ? N : never : never
}
>
{
$then: IsStrictNumber<
A['length'],
IsStrictNumber.$Branch
> extends infer R
// A: array
? R extends $Then ? N
// A: tuple
: R extends $Else ? IsNegative<
N,
{
$then: GreaterThan<Abs<N>, A['length']> extends true ? Lower : Subtract<A['length'], Abs<N>>,
$else: GreaterThan<A['length'], N> extends true ? N : Upper
}
>
: never : never,
// N: number or float
$else: IsAny<
N,
{
$then: number,
$else: IsStrictNumber<
N,
IsStrictNumber.$Branch
> extends infer R
? R extends $Then ? N : never : never
}
>
}
>
>
}


// import type { IsAny } from '../any/is_any.js'
// import type { IsEqual } from '../equal/equal.js'
// import type { Abs } from '../math/abs.js'
// import type { GreaterThan } from '../math/greater_than.js'
// import type { Subtract } from '../math/subtract.js'
// import type { IsNever } from '../never/is_never.js'
// import type { IsStrictNumber } from '../number/is_strict_number.js'
// import type { IsInteger } from '../numeric/is_integer.js'
// import type { IsNegative } from '../numeric/is_negative.js'
// import type { $Else, $SelectionBranch, $Then } from '../type_plus/branch/selection.js'

// /**
// * 🦴 *utilities*
// *
// * Gets the normalized index to access the element of an array or tuple.
// *
// * @example
// * ```ts
// * type R = IndexAt<['a', 'b', 'c'], 2> // 2
// * type R = IndexAt<['a', 'b', 'c'], -2> // 1
// *
// * type R = IndexAt<['a', 'b', 'c'], 3> // never
// * type R = IndexAt<['a', 'b', 'c'], -4> // never
// * ```
// */
// export type IndexAt<
// A extends readonly unknown[],
// N extends number,
// Fail = never,
// Upper = A['length'],
// Lower = 0
// > = IsNever<
// A,
// $SelectionBranch> extends infer R
// ? R extends $Then ? Fail
// : R extends $Else ? IndexAt._<A, N, Fail, Upper, Lower>
// : never : never

// export namespace IndexAt {
// export type _<
// A extends readonly unknown[],
// N extends number,
// Fail = never,
// Upper = A['length'],
// Lower = 0
// > = IsEqual<
// A['length'],
// 0,
// Fail,
// IsInteger<
// N,
// IsInteger.$Branch
// > extends infer R
// ? R extends $Then
// ? IsStrictNumber<
// A['length'],
// IsStrictNumber.$Branch
// > extends infer R
// // A: array
// ? R extends $Then ? N
// // A: tuple
// : R extends $Else ? IsNegative<
// N,
// IsNegative.$Branch
// > extends infer R
// ? R extends $Then ? GreaterThan<Abs<N>, A['length']> extends true ? Lower : Subtract<A['length'], Abs<N>>
// : GreaterThan<A['length'], N> extends true ? N : Upper
// : never
// : never : never
// // N: number or float
// : IsAny<
// N,
// {
// $then: number,
// $else: IsStrictNumber<
// N,
// IsStrictNumber.$Branch
// > extends infer R
// ? R extends $Then ? N : never : never
// }
// >
// : never
// >
// }
10 changes: 1 addition & 9 deletions type-plus/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export type * from './number/is_number.js'
export type * from './number/is_strict_number.js'
export * as NumberPlus from './number/number_plus.js'
export type { NumericToString, StringToNumeric } from './numeric/cast.js'
export type { Integer, IsWhole, NotInteger } from './numeric/integer.js'
export type * from './numeric/is_integer.js'
export type * from './numeric/is_negative.js'
export type * from './numeric/is_not_integer.js'
Expand All @@ -74,15 +73,8 @@ export type * from './numeric/is_not_numeric.js'
export type * from './numeric/is_not_positive.js'
export type * from './numeric/is_numeric.js'
export type * from './numeric/is_positive.js'
export type { Negative, NotNegative } from './numeric/negative.js'
export * as NumericPlus from './numeric/numeric_plus.js'
export type {
NotNumericType,
Numeric,
NumericType,
Zero
} from './numeric/numeric_type.js'
export type { NonPositive, Positive } from './numeric/positive.js'
export type * from './numeric/numeric_type.js'
export type { Required, RequiredExcept, RequiredPick } from './object/Required.js'
export * from './object/index.js'
export type * from './object/is_strict_object.js'
Expand Down
10 changes: 1 addition & 9 deletions type-plus/ts/number/number_plus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export type { Integer, IsWhole, NotInteger } from '../numeric/integer.js'
export type * from '../numeric/is_integer.js'
export type * from '../numeric/is_negative.js'
export type * from '../numeric/is_not_integer.js'
Expand All @@ -7,14 +6,7 @@ export type * from '../numeric/is_not_numeric.js'
export type * from '../numeric/is_not_positive.js'
export type * from '../numeric/is_numeric.js'
export type * from '../numeric/is_positive.js'
export type { Negative, NotNegative } from '../numeric/negative.js'
export type {
NotNumericType,
Numeric,
NumericType,
Zero
} from '../numeric/numeric_type.js'
export type { NonPositive, Positive } from '../numeric/positive.js'
export type * from '../numeric/numeric_type.js'
export type * from './is_not_number.js'
export type * from './is_not_strict_number.js'
export type * from './is_number.js'
Expand Down
24 changes: 0 additions & 24 deletions type-plus/ts/numeric/integer.is_whole.spec.ts

This file was deleted.

82 changes: 0 additions & 82 deletions type-plus/ts/numeric/integer.spec.ts

This file was deleted.

49 changes: 0 additions & 49 deletions type-plus/ts/numeric/integer.ts

This file was deleted.

Loading

0 comments on commit 25b5d31

Please sign in to comment.