🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

todash

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

todash - npm Package Compare versions

Comparing version
1.0.4
to
1.0.5
+89
dist/index.d.ts
import * as Utils from './utils';
import * as Tuple from './tuple';
export * from './utils';
export * from './tuple';
/**
* TypeScript 类型辅助工具
* 类型 之于 Todash,数组之于 lodash
* */
declare namespace Todash {
/**
* 用来替换需要 extends any 类型的场景
* @doc [TypeScript 3.9: Type Parameters That Extend any No Longer Act as any](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#type-parameters-that-extend-any-no-longer-act-as-any)
*/
type AnyObject = Utils.AnyObject;
/**
* 将 union 转换成 intersection
*/
type CombineUnion<T> = Utils.CombineUnion<T>;
/**
* 将 union 转换成 intersection
* 与 CombineUnion 区别在于: PureCombineUnion 让合并之后的类型更加整洁
*/
type PureCombineUnion<T extends object> = Utils.PureCombineUnion<T>;
/**
* 将 union类型 转换为 类型重载
*/
type OverloadUnion<T> = Utils.OverloadUnion<T>;
/**
* 将 union 类型的最后一项弹出
*/
type PopUnion<T> = Utils.PopUnion<T>;
/**
* 将 union 类型的最后一项弹出后,将剩余的部分返回
*/
type UnionByPop<T> = Utils.UnionByPop<T>;
/**
* 把自身(source)已有的属性 用 目标(target)的同名属性覆盖
*/
type AssignByOwnKey<S, T> = Utils.AssignByOwnKey<S, T>;
/**
* 将 union 转化为 元组
*/
type Union2Tuple<T> = Tuple.Union2Tuple<T>;
/**
* 从对象中删除指定值类型的字段
*/
type OmitBy<T, V> = Utils.OmitBy<T, V>;
/**
* 从对象中删除可选字段
*/
type OmitOptional<T> = Utils.OmitOptional<T>;
/**
* 从对象中删除非指定值类型的字段
*/
type FilterBy<T, V> = Utils.FilterBy<T, V>;
/**
* 返回元组的第一项
*/
type ShiftTuple<T extends any[]> = Tuple.ShiftTuple<T>;
/**
* 删除元组的第一项,并返回被删除后的元组
*/
type TupleByShift<T extends any[]> = Tuple.TupleByShift<T>;
/**
* 将一个类型添加元组的开头,并返回元组
*/
type TupleByUnshift<T extends any[], E> = Tuple.TupleByUnshift<T, E>;
/**
* 返回元组的第最后一项
*/
type PopTuple<T extends any[]> = Tuple.PopTuple<T>;
/**
* 删除元组的最后一项,并返回被删除后的元组
*/
type TupleByPop<T extends any[]> = Tuple.TupleByPop<T>;
/**
* 将一个类型添加元组的末尾,并返回元组
*/
type TupleByPush<T extends any[], E> = Tuple.TupleByPush<T, E>;
/**
* 将元组的顺序反转,并返回
*/
type TupleByReverse<T extends any[]> = Tuple.TupleByReverse<T>;
/**
* 将指定的两个元组首尾相接
*/
type TupleByConcat<T extends any[], E extends any[]> = Tuple.TupleByConcat<T, E>;
}
export default Todash;
import { UnionByPop, PopUnion, AssignByOwnKey, EnsureArray } from './utils';
/**
* 返回元组的第一项
*/
export declare type ShiftTuple<T extends any[]> = T[0];
/**
* 删除元组的第一项,并返回被删除后的元组
*/
export declare type TupleByShift<T extends any[]> = ((...params: T) => any) extends ((param1: any, ...rest: infer P) => any) ? P : never;
/**
* 将一个类型添加元组的开头,并返回元组
*/
export declare type TupleByUnshift<T extends any[], E> = ((param1: E, ...params: T) => any) extends ((...params: infer P) => any) ? P : never;
/**
* 【递归地】删除元组的第最后一项,并返回
*/
declare type _PopTupleRecursion<T extends any[], R = never> = {
0: R;
1: _PopTupleRecursion<TupleByShift<T>, ShiftTuple<T>>;
}[T extends [] ? 0 : 1];
/**
* 返回元组的第最后一项
*/
export declare type PopTuple<T extends any[]> = _PopTupleRecursion<T>;
/**
* 删除元组的最后一项,并返回被删除后的元组
*/
export declare type TupleByPop<T extends any[]> = AssignByOwnKey<TupleByShift<T>, T>;
/**
* 将一个类型添加元组的末尾,并返回元组
*/
export declare type TupleByPush<T extends any[], E> = AssignByOwnKey<TupleByUnshift<T, any>, T & {
[K: string]: E;
}>;
/**
* 【递归地】将元组的顺序反转,并返回
*/
declare type _ReverseTupleRecursion<T extends any[], R = []> = {
0: R;
1: _ReverseTupleRecursion<TupleByShift<T>, TupleByUnshift<EnsureArray<R>, ShiftTuple<T>>>;
}[T extends [] ? 0 : 1];
/**
* 将元组的顺序反转,并返回
*/
export declare type TupleByReverse<T extends any[]> = _ReverseTupleRecursion<T>;
/**
* 【递归地】将元组的顺序反转,并返回
*/
declare type _TupleByConcatRecursion<T extends any[], E extends any[], R = T> = {
0: R;
1: _TupleByConcatRecursion<T, TupleByShift<E>, EnsureArray<TupleByPush<EnsureArray<R>, ShiftTuple<E>>>>;
}[E extends [] ? 0 : 1];
/**
* 将指定的两个元组首尾相接
*/
export declare type TupleByConcat<T extends any[], E extends any[]> = _TupleByConcatRecursion<T, E>;
/**
* 【递归地】 将 union 转化为 元组
* */
declare type _Union2TupleRecursion<T, R extends any[] = []> = {
0: R;
1: _Union2TupleRecursion<UnionByPop<T>, EnsureArray<TupleByUnshift<R, PopUnion<T>>>>;
}[[T] extends [never] ? 0 : 1];
/**
* 将 union 转化为 元组
* */
export declare type Union2Tuple<T> = _Union2TupleRecursion<T>;
export {};
/**
* 用来替换需要 extends any 类型的场景
* @doc [TypeScript 3.9: Type Parameters That Extend any No Longer Act as any](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#type-parameters-that-extend-any-no-longer-act-as-any)
*/
export declare type AnyObject = {
[K in keyof any]: any;
};
/**
* 将 union 转换成 intersection
*/
export declare type CombineUnion<T> = (T extends any ? (param: T) => any : never) extends (param: infer P) => any ? P : never;
/**
* 将 union 转换成 intersection
* 与 CombineUnion 区别在于: PureCombineUnion 让合并之后的类型更加整洁
*/
export declare type PureCombineUnion<T extends object> = Pick<CombineUnion<T>, keyof CombineUnion<T>>;
/**
* 将 union类型 转换为 类型重载
*/
export declare type OverloadUnion<T> = CombineUnion<T extends any ? {
(param: T): any;
} : never>;
/**
* 将 union 类型的最后一项弹出
*/
export declare type PopUnion<T> = OverloadUnion<T> extends (param: infer P) => any ? P : never;
/**
* 将 union 类型的最后一项弹出后,将剩余的部分返回
*/
export declare type UnionByPop<T> = Exclude<T, PopUnion<T>>;
/**
* 把自身(source)已有的属性 用 目标(target)的同名属性覆盖
*/
export declare type AssignByOwnKey<S, T extends AnyObject> = {
[K in keyof S]: T[K];
};
/**
* 将 数组/元组 转化为 union
* */
export declare type Array2Union<T extends any[]> = T[number];
/**
* 从对象中删除指定值类型的字段
*/
export declare type OmitBy<T, V> = Omit<T, {
[K in keyof T]: T[K] extends V ? K : never;
}[keyof T]>;
/**
* 从对象中删除非指定值类型的字段
*/
export declare type FilterBy<T, V> = Omit<T, {
[K in keyof T]: T[K] extends V ? never : K;
}[keyof T]>;
/**
* 从对象中删除可选字段
*/
export declare type OmitOptional<T> = Pick<T, {
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
}[keyof T]>;
/**
* 确保指定类型一定是 数组/元组
*/
export declare type EnsureArray<T> = T extends any[] ? T : [];
+1
-1
{
"name": "todash",
"version": "1.0.4",
"version": "1.0.5",
"description": "Todash 是一个类型推导工具库,旨在帮助你快速方便的编写具备类型推导的 TypeScript 代码。",

@@ -5,0 +5,0 @@ "main": "index.js",