Skip to content

lsky-walt/tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tools

一个工具库

Type

类型检查

Name Type Return Description
getType any string 返回参数的类型
isType String Boolean 判断是否是指定Type
isNull any Boolean 判断是否是Null
isUndefined any Boolean 判断是否是Undefined
isArray any Boolean 判断是否是Array
isObject any Boolean 判断是否是Object
isNumber any Boolean 判断是否是Number
isString any Boolean 判断是否是String
isFunc any Boolean 判断是否是Function
isDate any Boolean 判断是否是Date
isError any Boolean 判断是否是Error
isRegExp any Boolean 判断是否是RegExp
isMap any Boolean 判断是否是Map
isSet any Boolean 判断是否是Set
isSymbol any Boolean 判断是否是Symbol
isPromise any Boolean 判断是否是Promise
isNan any Boolean 判断是否是Nan

Value

有关值操作

Name Type Return Description
isEmpty any Boolean 是否为空值
toUnique Array | Set Array 去重
checkNum String String 校验数值字符串,并且格式化
obtain (value: any, key: string number, default: null any) => any

Request

请求封装

Name Type Return Description
request Object Null 请求

Browser

浏览器

Name Type Return Description
buildScheme Object String 创建 Scheme
generateIntent (config: Object, Option: Object) => String String 创建 Intent
getBrowser Null Object 判断浏览器类型

Dom

Name Type Return Description
addEventListener (dom, eventType, cb, option) => {remove: () => void} { remove: () => void } 注册事件
getParent (dom, target: String | Element) => null Element | null 获取指定父元素
isBrowser Function Boolean 判断是否是浏览器
injectScript (url: String, id: String) => Element Element 插入 Script 标签
checkTargetModuleHaveLoaded (cb: Function, condition: Function, params: {count: Number, time: Number, fail: Function}) => void void 循环检查

UUID

Name Type Return Description
shortID Null String 生成 UUID

Debounce

Name Type Return Description
debounce (func, wait, immediate) => Function Function 防抖

Throttle

Name Type Return Description
throttle (func, wait) => Function Function 节流

Date

Name Type Return Description
replaceTargetDateFormat (fmt: string, tar: string, value: string | number) => string string 给定 fmt 中替换指定 value
format (fmt: string, date: Date | string | number) => string string 根据 format 格式化时间