1.0.11 • Published 11 months ago

youzone-utils v1.0.11

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

Constants

Functions

arrayFill ⇒ *

数组填充值

Kind: global constant

ParamType
num*
fill*

osInfo ⇒ *

获取设备信息

Kind: global constant
Returns: * - {Object} 包含操作系统和浏览器信息的对象

ParamTypeDefaultDescription
userAgentstring"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

ParamType
name*

fileExtFormat ⇒ *

通过文件格式匹配文件图标

Kind: global constant
Returns: * - {string} 文件图标类型

ParamTypeDescription
fileextstring文件扩展名

cutNumber ⇒ *

保留小数点后几位,并且四舍五入

Kind: global constant
Returns: * - number
Example:: curNumber('123.45678') => 123.47
Author: huoyh

ParamType
number*
no*

numberSum ⇒ *

数字累加

Kind: global constant

ParamType
arr*

numAverage ⇒ *

计算数组平均值

Kind: global constant

ParamType
arr*

maxNum ⇒ *

获取数组最大值

Kind: global constant

ParamType
arr*

minNum ⇒ *

获取数组最小值

Kind: global constant

ParamType
arr*

numArrSort ⇒ *

数字数组排序

Kind: global constant

ParamType
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

ParamTypeDescription
format*= 'zhs','en','zht' 中文,英文,繁体,

uuid

Kind: global constant
Description:: 可以按照指定长度和基数生成唯一的UUID
Return:: String UUID DEMO:uuid()、uuid(10)、uuid(10, 16)

ParamTypeDescription
lenint生成长度
radixint基数
suffixstring统一前缀

getDomainUrl ⇒ *

获取当前origin

Kind: global constant
Returns: * - {*}

reqAsync ⇒ *

封装请求函数

Kind: global constant
Returns: * - {*}

Param
promise
successCallback
errorCallBack

imgLoadAll ⇒ *

判断图片是否加载

Kind: global constant
Returns: * - {*}

ParamType
arr*
callback*

sleep ⇒ *

同步睡眠几秒,默认1秒

Kind: global constant

ParamType
milliseconds*

getFormData ⇒ *

对象转化为FormData对象

Kind: global constant

ParamType
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

ParamType
timestampString | Date
formatsString

getNowTime ⇒ *

获取当前时间

Kind: global constant

loadCss

Kind: global constant
Description:: 加载远程css文件

ParamTypeDescription
url*url 远程地址
callback*
errorCallback*

loadScript ⇒ *

Kind: global constant
Returns: * - {*}
Description:: 加载远程js文件

ParamType
url*
callback*
errorCallback*

getQueryString ⇒ *

Kind: global constant
Returns: * - {*}
Description:: 获取当前url参数

downFile ⇒ *

下载文件

Kind: global constant
Returns: * - {*}

ParamType
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

ParamTypeDescription
anydata
typetype'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

ParamType
anydata

isNumber

Kind: global constant
Description:: 判断Number类型
Return:: Boolean
Example:: isNumber(123) => true isNumber('') => false

ParamType
anydata

isBoolean

Kind: global constant
Description:: 判断Boolean类型
Return:: Boolean
Example:: isBoolean(false) => true isBoolean('false') => false

ParamType
anydata

isUndefined

Kind: global constant
Description:: 判断Undefined类型
Return:: Boolean
Example:: isUndefined(undefined) => true isUndefined('undefined') => false

ParamType
anydata

isNull

Kind: global constant
Description:: 判断Null类型
Return:: Boolean
Example:: isNull(null) => true isNull('null') => false

ParamType
anydata

isFunc

Kind: global constant
Description:: 判断Function类型
Return:: Boolean
Example:: isFunc(() => 123) => true isFunc(123) => false

ParamType
anydata

isDate

Kind: global constant
Description:: 判断Date类型
Return:: Boolean
Example:: isDate(() => new Date()) => false isDate(new Date()) => true

ParamType
anydata

isArray

Kind: global constant
Description:: 判断Array类型
Return:: Boolean
Example:: isArray([]) => true isArray(![]) => false

ParamType
anydata

isReg

Kind: global constant
Description:: 判断RegExp类型
Return:: Boolean
Example:: isReg(new RegExp()) => true isReg(![]) => false

ParamType
anydata

isError

Kind: global constant
Description:: 判断Error类型
Return:: Boolean
Example:: isError(new Error()) => true isError(![]) => false

ParamType
anydata

isObject

Kind: global constant
Description:: 判断Object类型
Return:: Boolean
Example:: isObject({}) => true isObject(![]) => false

ParamType
anydata

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

ParamType
valueany

chunk(arr, size) ⇒ *

数组分块儿

Kind: global function
Returns: * - {*}

ParamType
arrArray
sizeNumber

concat(arr, ...args) ⇒ *

Kind: global function

ParamType
arrArray
...argsany

map(arr, callback) ⇒ *

Kind: global function

ParamType
arrArray
callbackfunction

reduce(arr, callback, initValue) ⇒ *

Kind: global function

ParamType
arrArray
callbackfunction
initValue*

filter(arr, callback) ⇒ *

Kind: global function

ParamType
arrArray
callbackfunction

find(arr, callback) ⇒ *

Kind: global function

ParamType
arrArray
callbackfunction

findIndex(arr, callback) ⇒ *

Kind: global function

ParamType
arrArray
callbackfunction

every(arr, callback) ⇒ *

Kind: global function

ParamType
arrArray
callbackfunction

some(arr, callback) ⇒ *

Kind: global function

ParamType
arrArray
callbackfunction

difference(arr1, arr2) ⇒ *

Kind: global function

ParamType
arr1Array
arr2Array

drop(arr, size) ⇒ *

Kind: global function

ParamType
arrArray
sizeNumber

flatten1(arr) ⇒ *

数组扁平化

Kind: global function

ParamType
arrArray

flatten2(arr) ⇒ *

Kind: global function

ParamType
arrArray

pull(arr, ...args) ⇒ *

Kind: global function

ParamType
arrArray
...argsany

slice(arr, begin, end) ⇒ *

Kind: global function

ParamType
arrArray
beginNumber
endNumber

unique1(arr) ⇒ *

Kind: global function

ParamType
arrArray

unique2(arr) ⇒ *

Kind: global function

ParamType
arrArray

unique3(arr) ⇒ *

Kind: global function

ParamType
arrArray

isIE() ⇒ *

是否是ie

Kind: global function

isEdge() ⇒ *

是否是老edge

Kind: global function

getFileSize(fileByte) ⇒ *

根据文件大小显示文件大小

Kind: global function

ParamType
fileByte*

toNumber(number) ⇒ *

转化成number,不能转化则抛出异常

Kind: global function
Returns: * - {*}

ParamType
number*

isIphoneX() ⇒ *

判断是否IphoneX以及以上机型(包括安全区域)

Kind: global function

isAndroidMobileDevice() ⇒ *

是否是安卓设备

Kind: global function

clone1(target) ⇒ *

Kind: global function
Returns: * - {*}

ParamType
target*

clone2(target) ⇒ *

Kind: global function
Returns: * - {*}

ParamType
target*

myInstanceOf(obj, Fn) ⇒ *

Kind: global function
Returns: * - {*}

ParamType
objObject
Fnfunction

newInstance(Fn, ...args) ⇒ *

Kind: global function
Returns: * - {*}

ParamType
Fnfunction
...argsany

copyToClipboard(str) ⇒ *

复制到剪贴板

Kind: global function
Returns: * - {*}

ParamType
str*

getImgName(str) ⇒ *

获取头像名简称

Kind: global function

ParamType
str*

getImageBg(str) ⇒ *

头像图标的背景颜色 通过指定的颜色随机数

Kind: global function

ParamType
str*

getFixedRandomValByStr(str, arr) ⇒ *

根据特定值和数组,固定匹配数组的值

Kind: global function

ParamType
str*
arr*

toFullScreen() ⇒ *

全屏幕显示

Kind: global function
Returns: * - {*}

exitFullscreen() ⇒ *

退出全屏幕

Kind: global function

reverseString(str) ⇒ *

反转字符串

Kind: global function

ParamType
str*

palindrome(str) ⇒ *

判断字符串是否是回文

Kind: global function

ParamType
str*

truncate(str, size) ⇒ *

截断字符串,显示...

Kind: global function

ParamType
str*
size*

convertString(str, character) ⇒ *

数组转字符串

Kind: global function

ParamType
str*
character*

isEmail(str) ⇒ *

校验是否为邮箱地址

Kind: global function

ParamType
str*

isURL(strUrl) ⇒ *

判断是否为网址 以https://、http://、ftp://、rtsp://、mms://开头、或者没有这些开头

Kind: global function

ParamType
strUrl*
1.0.11

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago