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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@saber2pr/ts-lib

v0.0.5

Published

some ts type tools.

Readme

@saber2pr/ts-lib

npm

Typescript 工具泛型

npm i @saber2pr/ts-lib

git clone https://github.com/Saber2pr/ts-lib.git

API

Split

拆分一个类型

type Test = {
  a: string
  b: number
}

type result = Split<Test> // {a:string} | {b:number}

Guard

守卫一个类型

type Test = {
  a: string
  b: number
}

type result0 = Guard<Test, { a }> // never
type result1 = Guard<Test, { _a }> // Test

UnionToIntersection

并集变交集

type result = UnionToIntersection<'a' | 'b'> // "a" & "b"

Shift

type result = Shift<['a', 'b', 'c']> // ["b", "c"]

Unshift

type result = Unshift<['b', 'c'], 'a'> // ["a", "b", "c"]

AddKey

获取一个类型的所有 key,并增加一个 key

type Test = {
  a: string
  b: number
}

type result = AddKey<Test, 'c'> // "a" | "b" | "c"

Add

给一个类型增加一个 key,并指定其类型

type Test = {
  a: string
  b: number
}

type result0 = Add<Test, 'x'> // {x:any; a:string; b:number}
type result1 = Add<Test, 'x', boolean> // {x:boolean; a:string; b:number}

DeleteKey

获取一个类型的所有 key,并删除一个 key

type Test = {
  a: string
  b: number
}

type result = DeleteKey<Test, 'a'> // "b"

Delete

给一个类型删除一个 key

type Test = {
  a: string
  b: number
}

type result0 = Delete<Test, 'a'> // {b:number}
type result1 = Delete<Test, 'a' | 'b'> // {}

Alter

更改一个类型的指定的 key 为新的类型

type Test = {
  a: string
  b: number
}

type result = Alter<Test, 'a', Function> // {a:Function; b:number}

GetKeys

获取一个类型的所有 key,可设置指定类型

type Test = {
  a: string
  b: number
}

type result0 = GetKeys<Test> // "a" | "b"

type result1 = GetKeys<Test, String> // "a"
type result2 = GetKeys<Test, Number> // "b"

GetFunctionKeys

获取一个类型的所有 Function 类型的 key

GetStringKeys

获取一个类型的所有 string 类型的 key

GetNumberKeys

获取一个类型的所有 number 类型的 key

GetBooleanKeys

获取一个类型的所有 boolean 类型的 key

Author

saber2pr