Methods
assignment(target, source) → {object}
向目标对象赋值,仅对目标对象target的key赋值,源source多余的key不会添加到target上
Parameters:
Name | Type | Description |
---|---|---|
target | object | 待赋值目标对象 |
source | object | 赋值目标源 |
- Source
Returns:
- Type:
- object
Example
const foo = {
a:1
}
const fbb = {
a:2,
b:1
}
assignment(foo,fbb)
// { a:2 }
debounce(callback, msopt) → {function}
防抖函数
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback | function | 回调方法 | ||
ms | Number | <optional> | 200 | 防抖延迟 |
- Source
Returns:
- Type:
- function
deepCopy(obj) → {Object}
深拷贝
Parameters:
Name | Type | Description |
---|---|---|
obj | Object | 需要拷贝的对象 |
- Source
Returns:
返回复制的对象
- Type:
- Object
Example
const newObject = deepCopy(oldObject)
firstUpperCase(str) → {String}
字符串首字母大写
Parameters:
Name | Type | Description |
---|---|---|
str | String |
- Source
Returns:
- Type:
- String
Example
firstUpperCase('test')
// Test
formatFileSize(total, nopt) → {string}
格式化文件大小
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
total | number | 文件大小 | ||
n | number | <optional> | 0 | total参数的原始单位如果为Byte,则n设为0,如果为KB,则n设为1,如果为MB,则n设为2,以此类推 |
- Source
Returns:
带单位的文件大小的字符串
- Type:
- string
Example
formatFileSize(300)
// 300KB'
isWeakPassword(text) → {Boolean}
是否为弱密码
Parameters:
Name | Type | Description |
---|---|---|
text | String |
- Source
Returns:
- Type:
- Boolean
Example
isWeakPassword('123')
// true
pointAngle(start, end) → {Number}
获取两个坐标点之间的角度
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
start | Object | 第一个点坐标 Properties
| |||||||||
end | Object | 第二个点坐标 Properties
|
- Source
Returns:
- Type:
- Number
randomColor() → {String}
生成随机HEX色值
- Source
Returns:
- Type:
- String
starScore(rate:(1-5)) → {String}
生成星级评分
Parameters:
Name | Type | Description |
---|---|---|
rate:(1-5) | Number |
- Source
Returns:
- Type:
- String
throttle(callback, msopt) → {function}
节流函数
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback | function | 回调方法 | ||
ms | Number | <optional> | 200 | 节流间接时间 |
- Source
Returns:
- Type:
- function