youzone-utils
v1.0.11
Published
<dl> <dt><a href="#arrayFill">arrayFill</a> ⇒ <code>*</code></dt> <dd><p>数组填充值</p> </dd> <dt><a href="#osInfo">osInfo</a> ⇒ <code>*</code></dt> <dd><p>获取设备信息</p> </dd> <dt><a href="#screenInfo">screenInfo</a> ⇒ <code>*</code></dt> <dd><p>获取屏幕信息</p> </dd>
Downloads
7
Maintainers
Readme
Constants
Functions
arrayFill ⇒ *
数组填充值
Kind: global constant
| Param | Type | | --- | --- | | num | * | | fill | * |
osInfo ⇒ *
获取设备信息
Kind: global constant
Returns: * - {Object} 包含操作系统和浏览器信息的对象
| Param | Type | Default | Description | | --- | --- | --- | --- | | [userAgent] | string | "navigator.userAgent" | 用户代理字符串 |
screenInfo ⇒ *
获取屏幕信息
Kind: global constant
getLocation ⇒ *
获取location 信息
Kind: global constant
getSpeedByImg ⇒ *
计算网速
Kind: global constant
Returns: * - {*}
hardware ⇒ *
获取cpu/gpu硬件信息
Kind: global constant
isPcClient ⇒ *
是否为pc-client端
Kind: global constant
isMobile ⇒ *
是否为手机端访问
Kind: global constant
getCookie ⇒ *
获取cookie 通过key
Kind: global constant
| Param | Type | | --- | --- | | name | * |
fileExtFormat ⇒ *
通过文件格式匹配文件图标
Kind: global constant
Returns: * - {string} 文件图标类型
| Param | Type | Description | | --- | --- | --- | | fileext | string | 文件扩展名 |
cutNumber ⇒ *
保留小数点后几位,并且四舍五入
Kind: global constant
Returns: * - number
Example:: curNumber('123.45678') => 123.47
Author: huoyh
| Param | Type | | --- | --- | | number | * | | no | * |
numberSum ⇒ *
数字累加
Kind: global constant
| Param | Type | | --- | --- | | arr | * |
numAverage ⇒ *
计算数组平均值
Kind: global constant
| Param | Type | | --- | --- | | arr | * |
maxNum ⇒ *
获取数组最大值
Kind: global constant
| Param | Type | | --- | --- | | arr | * |
minNum ⇒ *
获取数组最小值
Kind: global constant
| Param | Type | | --- | --- | | arr | * |
numArrSort ⇒ *
数字数组排序
Kind: global constant
| Param | Type | | --- | --- | | arr | * |
isAppleMobileDevice ⇒ *
是否苹果手机
Kind: global constant
isWX ⇒ *
是否为微信平台
Kind: global constant
getYhtAccessToken ⇒ *
获取YhtAccessToken,从ua取,其次从url中取
Kind: global constant
getYzoneVersion
Kind: global constant
Description:: 获取友空间 app 版本号
Return:: String 返回版本号
| Type | | --- | | type |
getPlatformType
Kind: global constant
Description:: 获取系统类型
Return:: String
| Type | | --- | | type |
getJDiWorkData ⇒ *
从jdiwork 获取租户域名,是否专属化信息
Kind: global constant
getTenantId ⇒ *
获取租户Id
Kind: global constant
getDataCenter ⇒ *
获取社会化域名
Kind: global constant
isExclusive ⇒ *
是否专属化
Kind: global constant
getLanguageByUA ⇒ *
获取当前语言通过UA(优先从友空间APP的userAgent里取,再次从地址栏里取,最后根据浏览器语言取)
Kind: global constant
getLanguageByBridge ⇒ *
获取当前语言通过Bridge
Kind: global constant
getlang ⇒ *
转化语言格式
Kind: global constant
| Param | Type | Description | | --- | --- | --- | | format | * | = ['zhs','en','zht'] 中文,英文,繁体, |
uuid
Kind: global constant
Description:: 可以按照指定长度和基数生成唯一的UUID
Return:: String UUID
DEMO:uuid()、uuid(10)、uuid(10, 16)
| Param | Type | Description | | --- | --- | --- | | len | int | 生成长度 | | radix | int | 基数 | | suffix | string | 统一前缀 |
getDomainUrl ⇒ *
获取当前origin
Kind: global constant
Returns: * - {*}
reqAsync ⇒ *
封装请求函数
Kind: global constant
Returns: * - {*}
| Param | | --- | | promise | | successCallback | | errorCallBack |
imgLoadAll ⇒ *
判断图片是否加载
Kind: global constant
Returns: * - {*}
| Param | Type | | --- | --- | | arr | * | | callback | * |
sleep ⇒ *
同步睡眠几秒,默认1秒
Kind: global constant
| Param | Type | | --- | --- | | milliseconds | * |
getFormData ⇒ *
对象转化为FormData对象
Kind: global constant
| Param | Type | | --- | --- | | object | * |
formatDate ⇒ *
对 Date 的扩展,将 Date 转化为指定格式的 String 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
Kind: global constant
Returns: * - 例子:
formatDate('1514950039293', "yyyy-MM-dd hh:mm:ss.S") ==> 2018-01-03 11:27:19.293
formatDate('1514950039293', "yyyy-M-d h:m:s") ==> 2018-1-3 11:27:19
| Param | Type | | --- | --- | | timestamp | String | Date | | formats | String |
getNowTime ⇒ *
获取当前时间
Kind: global constant
loadCss
Kind: global constant
Description:: 加载远程css文件
| Param | Type | Description | | --- | --- | --- | | url | * | url 远程地址 | | callback | * | | | errorCallback | * | |
loadScript ⇒ *
Kind: global constant
Returns: * - {*}
Description:: 加载远程js文件
| Param | Type | | --- | --- | | url | * | | callback | * | | errorCallback | * |
getQueryString ⇒ *
Kind: global constant
Returns: * - {*}
Description:: 获取当前url参数
downFile ⇒ *
下载文件
Kind: global constant
Returns: * - {*}
| Param | Type | | --- | --- | | url | * |
isPhone
Kind: global constant
Description:: 中国大陆手机号校验
Return:: boolean
Example:: isPhone('13419595634') => true
| Type | | --- | | type |
isType
Kind: global constant
Description:: 精准判断数据类型
Return:: Boolean
Example:: isType(123, 'String') => false
isType('123', 'String') => true
| Param | Type | Description | | --- | --- | --- | | any | data | | | type | type | 'String' | 'Number' | 'Boolean' | 'Undefined' | 'Null' | 'Function' | 'Date' | 'Array' | 'RegExp' | 'Error' | 'Object' |
isString
Kind: global constant
Description:: 判断String类型
Return:: Boolean
Example:: isString(123) => false
isString('') => true
| Param | Type | | --- | --- | | any | data |
isNumber
Kind: global constant
Description:: 判断Number类型
Return:: Boolean
Example:: isNumber(123) => true
isNumber('') => false
| Param | Type | | --- | --- | | any | data |
isBoolean
Kind: global constant
Description:: 判断Boolean类型
Return:: Boolean
Example:: isBoolean(false) => true
isBoolean('false') => false
| Param | Type | | --- | --- | | any | data |
isUndefined
Kind: global constant
Description:: 判断Undefined类型
Return:: Boolean
Example:: isUndefined(undefined) => true
isUndefined('undefined') => false
| Param | Type | | --- | --- | | any | data |
isNull
Kind: global constant
Description:: 判断Null类型
Return:: Boolean
Example:: isNull(null) => true
isNull('null') => false
| Param | Type | | --- | --- | | any | data |
isFunc
Kind: global constant
Description:: 判断Function类型
Return:: Boolean
Example:: isFunc(() => 123) => true
isFunc(123) => false
| Param | Type | | --- | --- | | any | data |
isDate
Kind: global constant
Description:: 判断Date类型
Return:: Boolean
Example:: isDate(() => new Date()) => false
isDate(new Date()) => true
| Param | Type | | --- | --- | | any | data |
isArray
Kind: global constant
Description:: 判断Array类型
Return:: Boolean
Example:: isArray([]) => true
isArray(![]) => false
| Param | Type | | --- | --- | | any | data |
isReg
Kind: global constant
Description:: 判断RegExp类型
Return:: Boolean
Example:: isReg(new RegExp()) => true
isReg(![]) => false
| Param | Type | | --- | --- | | any | data |
isError
Kind: global constant
Description:: 判断Error类型
Return:: Boolean
Example:: isError(new Error()) => true
isError(![]) => false
| Param | Type | | --- | --- | | any | data |
isObject
Kind: global constant
Description:: 判断Object类型
Return:: Boolean
Example:: isObject({}) => true
isObject(![]) => false
| Param | Type | | --- | --- | | any | data |
isFalsy ⇒ *
Kind: global constant
Returns: * - value === 0 ? false : !value
Description:: 判断 js是否是false, 0除外。
Example:: isFalsy('') => true
isFalsy(0) => false
isFalsy(null) => true
isFalsy(undefined) => true
isVoid ⇒ *
Kind: global constant
Returns: * - boolean
Description:: 判断是否为空 undefined || null || ""
Example:: isVoid(0) => false
isVoid(undefined) => true
isVoid('') => true
isVoid(null) => true
isVoid() => true
| Param | Type | | --- | --- | | value | any |
chunk(arr, size) ⇒ *
数组分块儿
Kind: global function
Returns: * - {*}
| Param | Type | | --- | --- | | arr | Array | | size | Number |
concat(arr, ...args) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array | | ...args | any |
map(arr, callback) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array | | callback | function |
reduce(arr, callback, initValue) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array | | callback | function | | initValue | * |
filter(arr, callback) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array | | callback | function |
find(arr, callback) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array | | callback | function |
findIndex(arr, callback) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array | | callback | function |
every(arr, callback) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array | | callback | function |
some(arr, callback) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array | | callback | function |
difference(arr1, arr2) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr1 | Array | | arr2 | Array |
drop(arr, size) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array | | size | Number |
flatten1(arr) ⇒ *
数组扁平化
Kind: global function
| Param | Type | | --- | --- | | arr | Array |
flatten2(arr) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array |
pull(arr, ...args) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array | | ...args | any |
slice(arr, begin, end) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array | | begin | Number | | end | Number |
unique1(arr) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array |
unique2(arr) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array |
unique3(arr) ⇒ *
Kind: global function
| Param | Type | | --- | --- | | arr | Array |
isIE() ⇒ *
是否是ie
Kind: global function
isEdge() ⇒ *
是否是老edge
Kind: global function
getFileSize(fileByte) ⇒ *
根据文件大小显示文件大小
Kind: global function
| Param | Type | | --- | --- | | fileByte | * |
toNumber(number) ⇒ *
转化成number,不能转化则抛出异常
Kind: global function
Returns: * - {*}
| Param | Type | | --- | --- | | number | * |
isIphoneX() ⇒ *
判断是否IphoneX以及以上机型(包括安全区域)
Kind: global function
isAndroidMobileDevice() ⇒ *
是否是安卓设备
Kind: global function
clone1(target) ⇒ *
Kind: global function
Returns: * - {*}
| Param | Type | | --- | --- | | target | * |
clone2(target) ⇒ *
Kind: global function
Returns: * - {*}
| Param | Type | | --- | --- | | target | * |
myInstanceOf(obj, Fn) ⇒ *
Kind: global function
Returns: * - {*}
| Param | Type | | --- | --- | | obj | Object | | Fn | function |
newInstance(Fn, ...args) ⇒ *
Kind: global function
Returns: * - {*}
| Param | Type | | --- | --- | | Fn | function | | ...args | any |
copyToClipboard(str) ⇒ *
复制到剪贴板
Kind: global function
Returns: * - {*}
| Param | Type | | --- | --- | | str | * |
getImgName(str) ⇒ *
获取头像名简称
Kind: global function
| Param | Type | | --- | --- | | str | * |
getImageBg(str) ⇒ *
头像图标的背景颜色 通过指定的颜色随机数
Kind: global function
| Param | Type | | --- | --- | | str | * |
getFixedRandomValByStr(str, arr) ⇒ *
根据特定值和数组,固定匹配数组的值
Kind: global function
| Param | Type | | --- | --- | | str | * | | arr | * |
toFullScreen() ⇒ *
全屏幕显示
Kind: global function
Returns: * - {*}
exitFullscreen() ⇒ *
退出全屏幕
Kind: global function
reverseString(str) ⇒ *
反转字符串
Kind: global function
| Param | Type | | --- | --- | | str | * |
palindrome(str) ⇒ *
判断字符串是否是回文
Kind: global function
| Param | Type | | --- | --- | | str | * |
truncate(str, size) ⇒ *
截断字符串,显示...
Kind: global function
| Param | Type | | --- | --- | | str | * | | size | * |
convertString(str, character) ⇒ *
数组转字符串
Kind: global function
| Param | Type | | --- | --- | | str | * | | character | * |
isEmail(str) ⇒ *
校验是否为邮箱地址
Kind: global function
| Param | Type | | --- | --- | | str | * |
isURL(strUrl) ⇒ *
判断是否为网址 以https://、http://、ftp://、rtsp://、mms://开头、或者没有这些开头
Kind: global function
| Param | Type | | --- | --- | | strUrl | * |