typescript-union
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,3 +0,4 @@ | ||
import * as ulib from 'utility-types'; | ||
import * as tuple from 'typescript-tuple'; | ||
import * as ulib from 'utility-types' | ||
import * as tuple from 'typescript-tuple' | ||
/** | ||
@@ -9,3 +10,4 @@ * Create a union from tuple's element | ||
*/ | ||
export declare type FromTuple<Tuple extends any[]> = utils.FromTuple<Tuple>; | ||
export type FromTuple<Tuple extends any[]> = utils.FromTuple<Tuple> | ||
/** | ||
@@ -15,3 +17,4 @@ * Create a union of range from 0 to `Max`, excluding `Max` | ||
*/ | ||
export declare type RangeZero<Max extends number> = utils.RangeZero<Max>; | ||
export type RangeZero<Max extends number> = utils.RangeZero<Max> | ||
/** | ||
@@ -21,18 +24,23 @@ * Create a union of range from `Min` to `Max`, including `Min`, excluding `Max` | ||
*/ | ||
export declare type Range<Min extends number, Max extends number> = utils.Range<Min, Max>; | ||
export declare namespace utils { | ||
type FromFiniteTuple<Tuple extends any[]> = { | ||
empty: never; | ||
nonEmpty: ((..._: Tuple) => any) extends ((_: infer First, ..._1: infer Rest) => any) ? First | FromFiniteTuple<Rest> : never; | ||
}[Tuple extends [] ? 'empty' : 'nonEmpty']; | ||
type FromInfiniteTuple<Tuple extends any[], Splitted extends boolean = false, Pair = never> = { | ||
'splitted': Pair extends [infer Finite, infer Infinite] ? Finite extends any[] ? Infinite extends (infer RepeatedElement)[] ? FromFiniteTuple<Finite> | RepeatedElement : never : never : never; | ||
'unsplitted': FromInfiniteTuple<Tuple, true, tuple.SplitInfiniteTuple<Tuple>>; | ||
}[Splitted extends true ? 'splitted' : 'unsplitted']; | ||
type FromTuple<Tuple extends any[]> = tuple.IsFinite<Tuple, FromFiniteTuple<Tuple>, FromInfiniteTuple<Tuple>>; | ||
type RangeZero<Ceiling extends number, Holder extends number = never, Counter extends any[] = []> = { | ||
matched: Holder; | ||
unmatched: RangeZero<Ceiling, Holder | Counter['length'], tuple.Prepend<Counter, any>>; | ||
}[Counter['length'] extends Ceiling ? 'matched' : 'unmatched']; | ||
type Range<Floor extends number, Ceiling extends number> = ulib.SetDifference<RangeZero<Ceiling>, RangeZero<Floor>>; | ||
export type Range<Min extends number, Max extends number> = | ||
// @ts-ignore | ||
utils.Range<Min, Max> | ||
export namespace utils { | ||
export type FromTuple<Tuple extends any[]> = | ||
Tuple extends Iterable<infer X> ? X : never | ||
export type RangeZero< | ||
Ceiling extends number, | ||
Holder extends number = never, | ||
Counter extends any[] = [] | ||
> = { | ||
matched: Holder, | ||
unmatched: RangeZero<Ceiling, Holder | Counter['length'], tuple.Prepend<Counter, any>> | ||
}[ | ||
Counter['length'] extends Ceiling ? 'matched' : 'unmatched' | ||
] | ||
export type Range<Floor extends number, Ceiling extends number> = | ||
ulib.SetDifference<RangeZero<Ceiling>, RangeZero<Floor>> | ||
} |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
Object.defineProperty(exports, '__esModule', { value: true }) |
{ | ||
"name": "typescript-union", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Generics to work with unions in TypeScript", | ||
"main": "index.js", | ||
"scripts": { | ||
"prepublishOnly": "tsc", | ||
"prepublishOnly": "tsc --noEmit", | ||
"test": "tsc --noEmit" | ||
@@ -26,12 +26,9 @@ }, | ||
"dependencies": { | ||
"utility-types": "^2.0.0", | ||
"typescript-tuple": "^1.7.3" | ||
"utility-types": "^3.4.1", | ||
"typescript-tuple": "^2.2.1" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^3.0.3", | ||
"static-type-assert": "^3.0.0" | ||
}, | ||
"engines": { | ||
"typescript": "^3.0.0" | ||
"typescript": "^3.4.1", | ||
"static-type-assert": "^3.0.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3308
4
38
+ Addedtypescript-compare@0.0.2(transitive)
+ Addedtypescript-logic@0.0.0(transitive)
+ Addedtypescript-tuple@2.2.1(transitive)
+ Addedutility-types@3.11.0(transitive)
- Removedtypescript-tuple@1.7.3(transitive)
- Removedutility-types@2.1.0(transitive)
Updatedtypescript-tuple@^2.2.1
Updatedutility-types@^3.4.1