Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typescript-union

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-union - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

48

index.d.ts

@@ -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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc