/utils

Primary LanguageJavaScript

utils

doc

getType

grammar: getType([value])
param:

  1. value<any>

return: String

↑ BackToList

hasKey

returns a boolean indicating whether the object has the specified property as its own property

grammar: hasKey(object, key)
param:

  1. object<Object>
  2. key<String>

return: Boolean

↑ BackToList

random

returns a number in the range [min - max]

grammar: random(min, max)
param:

  1. min<Number(int)>
  2. max<Number(int)>

return: Number(int)

↑ BackToList

is

get or compare a data type, If the parameter type is passed, the data type is compared, otherwise the data type of the parameter value is returned.

grammar: is(value[, type])
param:

  1. value<any>
  2. type<String>

return: String or Boolean

↑ BackToList

isNumber

grammar: isNumber(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isString

grammar: isString(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isBoolean

grammar: isBoolean(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isFunction

grammar: isFunction(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isObject

grammar: isObject(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isArray

grammar: isArray(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isDate

grammar: isDate(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isRegExp

grammar: isRegExp(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isUndefined

grammar: isUndefined(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isNull

grammar: isNull(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isNaN

grammar: isNaN(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isPrimitive

grammar: isPrimitive(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isEmptyValue

The following values will return true: undefined, null, NaN, "", " "

grammar: isEmptyValue(value)
param:

  1. value<any>

return: Boolean

↑ BackToList

isMathEqual

grammar: isMathEqual(a, b)
param:

  1. a<Number>
  2. b<Number>

return: Boolean

↑ BackToList

isEqual

grammar: isEqual(a, b)
param:

  1. a<any>
  2. b<any>

return: Boolean

↑ BackToList

isLeapYear

grammar: isLeapYear(value)
param:

  1. value<Number>

return: Boolean

↑ BackToList

clone

grammar: clone(value)
param:

  1. value<any>

return: Number,String,Boolean,null,undefined,Symbol,BigInt, Date,RegExp,Array,Object

↑ BackToList

dateFormatter

grammar: dateFormatter(date[, format])
param:

  1. date<Date,String>
  2. format<String>: default: YYYY-MM-DD hh:mm:ss

return: String, NaN

replacement in the format

replacement remarks
YY Two-digit year
YYYY full year
MM month
DD the day of the month
hh hours
mm minutes
ss seconds
ms milliseconds
da the day of the week
ts timestamp

↑ BackToList

timeAgo

rough calculation of date difference

grammar: timeAgo(oldDate[, nowDate])
param:

  1. oldDate<Date, String>
  2. nowDate<Date, String>: default: Date.now()

return: String

↑ BackToList

bytesToSize

format the number of bytes into a file size with units

grammar: bytesToSize(bytes[, base])
param:

  1. bytes<Number>
  2. base<Number>: default: 1000

return: String, NaN

↑ BackToList

sizeToBytes

the file size with units is formatted as bytes

grammar: sizeToBytes(size[, base])
param:

  1. size<String>
  2. base<Number>: default: 1000

return: Number, NaN

↑ BackToList

hexToRgb

convert hex to RGB

grammar: hexToRgb(hex[, digit])
param:

  1. hex<String>
  2. digit<Number>: default: 1

return: String

↑ BackToList

rgbToHex

convert RGB to hex

grammar: rgbToHex(r, g, b)
param:

  1. r<Number>
  2. g<Number>
  3. b<Number>

return: String

↑ BackToList

paging

convert a one-dimensional array to a two-dimensional array

grammar: paging(data, size)
param:

  1. data<Array>
  2. size<Number>

return: Array(two-dimensional)

↑ BackToList

getUrlQuery

parse the query string from the url into an object

grammar: getUrlQuery(url)
param:

  1. url<String>

return: Object

↑ BackToList

parseUrl

parse the url into an object

grammar: parseUrl(url)
param:

  1. url<String>

return: Object

ObjectItem

key type remarks
href String url
scheme String url scheme
username String url username
password String url password
host String url hostname
port String url port
path String url path
search String url search
hash String url hash
query Object

↑ BackToList