npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

t2t-tools

v0.1.2

Published

type conversion tool of typescript

Downloads

12

Readme

t2t-tools

t2t-tools is type conversion tool of typescript.

Install

npm install t2t-tools -D

Usage

Add to a d.ts declaration file

/// <reference types="t2t-tools" />

OR

add t2t-tools to compilerOptions.types inside tsconfig.json

{
  "compilerOptions": {
    "types": ["t2t-tools"]
  }
}

Example

import { Merge } from 't2t-tools'

type A = Merge<{ a: number; c: boolean }, { a: string; b: number }>

// A = { a: string; b: number; c: boolean }

API

| 方法名 | 解释 | | :-------------------: | :---------------------------------------------------: | | ConstructorParameters | 获取一个构造函数的参数类型,返回一个元组 | | DeepNonNullable | 深度去除null和undefined | | DeepPartial | 深度设置为可选 | | DeepReadonly | 深度设置readonly | | DeepRequired | 全部设置为必选 | | Diff | 找出T类型中,与U类型不相同的属性 | | EnhancedRequired | 增强的必选,可以指定哪些key需要必选 | | Equals | 判断2个类型是否相等 | | Exclude | 从联合类型T中排除与联合类型U相同的部分 | | Extract | 从联合类型T中获取与联合类型U相同的部分 | | GetComplement | 获取联合类型T与其子类型中不同的部分 | | GetDifference | 获取联合类型T与联合类型U不同的类型 | | GetIntersection | 获取联合类型T与联合类型U的交叉类型 | | InstanceType | 获取一个构造函数的实例的类型 | | Intersection | 取出T中的属性,此属性同样存在于U | | Merge | 合并类型T与类型U | | MutableFunctionKeys | 获取一个类型中,属性为可选同时属性值的类型为函数的key | | MutableKeys | 返回非readonly的类型 | | NonFunction | 取出没有包含函数类型的参数组成一个新类型 | | NonFunctionKeys | 取出没有包含函数类型的参数的联合类型 | | NonNullable | 从联合类型T中排除null类型 | | NonNullAndUndefined | 去除联合类型T中的undefined和null类型 | | NonUndefined | 去除联合类型T中的undefined类型 | | Omit | 从类型T中,排除联合类型U中的属性 | | OmitByValue | 通过属性值的类型来排除属性 | | OmitByValueExact | 通过属性值的类型来精确排除属性 | | Optional | 可配置的设置可选属性 | | OptionalKeys | 取出所有可选的key | | OverWrite | 取出所有可选的key | | Parameters | 获取一个函数类型中,参数的元祖类型 | | Partial | 将T中的所有属性变为可选 | | Pick | 从类型T中获取一组,以联合类型K为基础的新类型 | | PickByValue | 通过类型值获取类型 | | Pop | 删除元祖中的最后一个类型 | | Primitive | 原始值 | | PromiseType | 获取Promise的resolve的值类型 | | Readonly | 将T中所有的属性,转变为readonly | | ReadonlyKeys | 获取readonly的类型 | | Record | 返回以联合类型K为属性,以T为属性值类型的新类型 | | Replace | 替换类型中一部分内容 | | Required | 将T中的所有类型变为必选 | | RequiredKeys | 取出所有必须的key | | ReturnType | 获取函数类型中,返回值的类型 | | Shift | 删除元祖中的第一个类型 | | Subtract | 获取子集中的差异 | | SymmetricDifference | 获取T类型中与U类型两者中不同的部分 | | Trim | 去除字符串两边的空格 | | TrimLeft | 去除字符串左边的空格 | | TrimRight | 去除字符串右边的空格 | | Unionize | 将类型T拆解为联合类型 | | UnionToIntersection | 联合类型转交叉类型 | | ValuesType | 获取对象、数组、类数组中的值的类型组成联合类型 | | GetArrayValue | 获取数组元素的类型 |