0.1.3 • Published 2 years ago

tools4ts v0.1.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

阅读目录

工具

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('已结束')
    }
})
0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago