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

tools4ts

v0.1.3

Published

A utility class using typescript

Downloads

9

Readme

阅读目录

工具

1. 使用typescript重新编写的工具库

依赖列表

暂无

工具目录

/*··引入模块*/
/*····日期时间类接口*/

/*··基础类*/

/*··验证类(Validate)*/
/*····字符串首尾去除空格*/
/*····是否为有效的手机号(isPhone(v: string): boolean)*/
/*····数据字符串是否有非法字符(hasIllegalChar(v: string): boolean)*/
/*····数据是否为Number类型(isNumber(v: any, defaults?: number): number)*/
/*····数组重复元素(ArrayIsRepeat(v: any[]): boolean)*/
/*····数据邮箱格式(CheckEmailFormat(v: string): boolean)*/
/*····链接格式(CheckLinkFormat(v: string): boolean)*/
/*····比较时间戳CompareDate(timestamp: number, compare): number | boolean*/
/*····银行卡号所属银行BankCard(v: string): Promise<any>*/


/*··日期时间类(DateTime)*/
/*····格式化时间戳*/
/*····获取当前日期时间*/
/*····时间戳转换具体日期时间*/
/*····获取当前一周(GetCurrWeek(): Array<string>)*/
/*····获取当前一个月(GetCurrMonth(): Array<string>)*/
/*····获取之前的日期(FormerDay(day: number): Boolean | Array<string>)*/
/*····倒计时(Countdown(obj: { timestamp: number, curr?: number, timer?: number }, callback: object): Function)*/
/*····定时执行(Interval(obj: { value: string | number, timer?: number, function: function(obj) { obj.remaining: number }, afterEnd: function }): Boolean | void)  Interval.close()*/

/*··计算类(Computed)*/
/*····计算localstorage已使用空间(getSieOfLS(): number)*/
/*····获取链接参数(getParam(key: string): string)*/

/*··生成类(Generated)*/
/*····深拷贝(DeepClone(obj: any): Array<any> | object | Boolean)*/
/*····文件对象转换dataURL(FileToDataURL(obj: FileToDataURLOptions, Callback: Function):void)*/
/*····dataURL转换文件对象(DataURLToFile(obj: DataURLToFileOptions, Callback: Function): Function)*/
/*····图片文件转换图片对象(ImgFileToImage(obj: ImgFileToImageOptions, Callback: Function): void)*/
/*····图片对象转换canvas(ImageToCanvas(obj: ImageToCanvasOptions, Callback: Function): Function)*/
/*····canvas转换dataURL(CanvasToDataURL(obj: CanvasToDataURLOptions, Callback: Function): Function)*/
/*····图片链接转换文件(ImgURLToFile(obj: ImgURLToFileOptions, Callback: Function): void)*/

/*··行为类(Action)*/
/*····防抖(Debounce({ function: function, delay?: number  }): Function | void)*/
/*····节流(Throttle({ function: function, delay?: number }): Function | void)*/

其它信息

对方法有疑惑可以去index.ts查看详情,有较为详细的参数说明

安装方法

使用npm安装

npm install tools4ts

使用方法

比如使用日期时间类的获取当前一周方法, 定时执行方法

import _TM from 'tools4ts'
_TM.DateTime.GetCurrWeek()
_TM.DateTime.Interval({
    value: '00:00:10',
    function(obj) {
        console.log(obj.remaining)
        if(obj.remaining == 5) _TM.DateTime.Interval.close()
    },
    afterEnd() {
        console.log('已结束')
    }
})
import { DateTime } from 'tools4ts'
const datetime = new DateTime()
datetime.GetCurrWeek()
datetime.Interval({
    value: '00:00:10',
    function(obj) {
        console.log(obj.remaining)
        if(obj.remaining == 5) datetime.Interval.close()
    },
    afterEnd() {
        console.log('已结束')
    }
})