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

@dusky/ts-def

v1.0.5

Published

typescript defines extension

Downloads

14

Readme

项目作用

为typescript编程添加常用到的类型扩展和泛型工具。 该工程用于编写、测试、文档和发布功能。

如何使用

  1. npm install -D @dusky/ts-def
  2. 以下方式均可:
  • dist/index.d.ts文件放到ts项目工程中任意位置。
  • 在需要使用定义扩展的地方import "@dusky/ds-def"

项目结构

  • docs 生成文档工程
  • res API导图等资源
  • src 源码...
  • base 基础...
  • adv 高级...
  • candidates 候选暂存
  • tests 测试用例合集
  • dist 发布(index.d.ts)

api列表

基础扩展

Primitive 原生类型扩展
  • bool 布尔类型别名
  • time 时间类型别名
  • num 数值类型别名
  • char 数值类型别名
  • str 字符串类型别名
  • primitive 原生类型
  • nullish 空值类型
  • falsy 否值类型
  • empty 内容空值类型
Type 常用类型扩展
  • IVec2 二维向量、点接口
  • IVec3 三维向量、点接口
  • IVec4 四维向量、点接口
  • Class 类类型
  • Constructor 构造函数类型
  • Decorator 装饰器类型
  • DecoratorFactory 装饰器工厂类型
  • DecoratorSwapper 装饰包装器类型
  • Dictionary 字典对象类型
  • IsAny 判断目标类型是否为any类型
  • IsNever 判断目标类型是否为never类型
  • IsUnion 判断目标类型是否为联合类型
  • JsonObjectJson 对象类型
  • NonEmpty 保留目标类型中的内容非空类型
  • NonEmptyArr 保留目标类型中的内容非空数组类型
  • NumberArray 内置数值数组类型
  • Promised Promise返回的数据类型
  • point
  • vec2 二维向量、点
  • vec3 三维向量、点
  • vec4 四维向量、点
Function 函数工具扩展
  • Append 为已知函数(从后)追加参数(列表)
  • Handler (一般处理)函数类型
  • Lambda 箭头函数类型
  • Listener (不关心返回值的)监听函数类型
  • Prepend 为已知函数(从前)追加参数(列表)
  • Validator (返回布尔值的)校验函数类型
Array 数组工具扩展
  • Contains 判断类型数组(元组)中是否含有指定类型
  • Elem 获得类型数组(元组)的元素类型
  • Every 判断目标数组类型内元素是否全部满足要求
  • EveryEquals 判断目标数组类型内元素是否全部是具体类型
  • Fill 填充一个数组类型
  • Filter 过滤数组类型中符合要求的所有类型
  • Head 获得类型数组(元组)的第一个类型
  • Heads 获得类型数组(元组)的前多个类型的元组
  • Length 获取类型数组或元组所含类型的数量
  • None 判断目标数组类型内元素是否不存在满足要求
  • NotContains 判断类型数组(元组)中是否不含指定类型
  • Pop 移除类型数组(元组)最后一个类型
  • Push 从尾部向类型数组(元组)加入一个或多个类型
  • Reverse 反转类型数组(元组)
  • Shift 移除类型数组(元组)第一个类型
  • Some 判断目标数组类型内元素是否存在满足要求
  • Tail 获得类型数组(元组)的最后一个类型
  • Tails 获得类型数组(元组)的后多个类型的元组
  • Unshift 从头部向类型数组(元组)加入一个或多个类型
String 字符串工具扩展
  • CutEnd 从尾部截取目标字符类型指定长度
  • CutStart 从头部截取目标字符类型指定长度
  • EndsWith 判断字符串类型是否以指定的子串结尾
  • Join 将给定字符串数组连接为字符串
  • Repeat 重复字符串类型
  • Replace 替代字符串类型中的首个子串
  • ReplaceAll 替代字符串类型中的所有子串
  • Revert 反转字符串类型
  • Split 将给定字符串类型拆解为数组
  • StartsWith 判断字符串类型是否以指定的子串开头
  • StringToNumber 将数值型字符串类型转成数值类型
  • SubString 截取目标字符类型指定开始和结束下标的子串
  • Trim 剪裁给定字符串两侧部分(空格)
  • TrimLeft 剪裁给定字符串左侧部分(空格)
  • TrimRight 剪裁给定字符串右侧部分(空格)

高阶扩展

Entry 提取工具扩展

...

Mapping 映射工具扩展

...

Infer 推断工具扩展

...

Recurse 递归工具扩展

...

Set 集合类工具扩展

...

API全景图

API全景图

查看文档

打开docs/index.html即可。

测试用例

测试用例在/tests的对应文件夹下。 测试用例无需运行,静态编译不报错即可。