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