@depeng9527/tools
v2.8.0
Published
Personal tools
Downloads
6
Readme
@depeng9527/tools
Opinionated collection of common JavaScript / TypeScript utils by Depeng0929.
Is
包括常用的数据类型判断。
import {
isRegExp,
isFunction,
isString,
isNumber,
isObject,
isDate,
isSymbol,
isSet,
isMap,
isNull,
isUndefined,
} from '@depng9527/tools'
isNil
: 是否是undefined
或null
notNil
: 与isNill
相反isBrowser
:是否在游览器中
String
ensurePrefix
ensureSuffix
randomStr
pascalCase
,camelCase
,kebabCase
,capitalize
Math
常用的数学运算
import {
add, divide, subtract, multiply
} from '@depng9527/tools'
sum
: 求数组的和clamp
:clamp(n, min, max)
返回n到min,max之间最近的点
Array
range
uniq
at
last
head
remove
removeElement
move
toArray
Object
deepClone
deepMerge
objectMap
renameKeys
// { b: 2 }
objectMap({ a: 1, b: 2 }, (k, v) => k === 'a' ? undefined : [k, v])
Function
tap
: 通常执行一些副作用
function createUser(name: string): User {
return tap(new User, user => {
user.name = name
})
}
assert
: 断言debug
: debug
Vendor
throttle
debounce
findValueByKey
isEmpty
select
: like sqlpick
: like sql
time
formateTime
timeStamp
pLimit
p