util-helper

util operation

Usage no npm install needed!

<script type="module">
  import utilHelper from 'https://cdn.skypack.dev/util-helper';
</script>

README

String

  • randomString [get random n length string from str pool] Params:
    1. length wanna random string length
    2. format your str pool
    usage   :  randomString(length,format)
    

Array

  • isArray [check input is array type]
    usage   :  isArray(array)
    
  • shuffle [shuffle array element]
    usage   :  shuffle(array)
    

Number

  • isNumber [check input is number type]
    usage   :  isNumber(number)
    
  • random [get a random number between min,max] Params:
    1. min random number minium
    2. max random number maximum
    usage   :  random(min,max)
    
  • isRandomIn [check input percentage is pass] Params:
    usage   :  isRandomIn(number)
    

Object

  • isObject [check input is object type]
    usage   :  isObject(obj)
    
  • deepCloneObject [deep clone obj]
    usage   :  deepCloneObject(obj)
    
  • faltten [faltten the nest object] Params:
    1. obj your nest object
    2. parseObjOnly is parse object only
      enum:[true,false]

      if true ignore parse your nest object array field

    usage   :  faltten({obj,parseObjOnly})
    

Time

  • convertTimestampToDateString [convert timestamp to your server time zone date format] (YYYY-MM-DD HH:mm:ss)
    usage   :  convertTimestampToDateString(timestamp)
    
  • convertTimestampToUTCDateString [convert timestamp to UTC+0 date format] (YYYY-MM-DD HH:mm:ss)
    usage   :  convertTimestampToUTCDateString(timestamp)
    
  • convertDateStringToTimestamp [convert date to timestamp(s)]
    usage   :  convertDateStringToTimestamp(date)
    
  • returnNextYear [get next year timestamp(s)]
    usage   :  returnNextYear(timestamp)
    
  • returnPreviousYear [get previous year timestamp(s)]
    usage   :  returnPreviousYear(timestamp)
    
  • returnNextDay [get next day timestamp(s)]
    usage   :  returnNextDay(timestamp)
    
  • returnPreviousDay [get previous day timestamp(s)]
    usage   :  returnPreviousDay(timestamp)
    
  • returnNowTime [get now UTC+0 timestamp(s)]
    usage   :  returnNowTime()
    
  • returnStartOfToday [get start of day UTC+0 timestamp(s)]
    usage   :  returnStartOfToday()
    
  • returnStartOfWeek [get start of week UTC+0 timestamp(s) ] Params:
    1. time wanna idx date timestamp
    2. weekIdx set start day of week enum:["mon","tue","wed","thur","fri","sat","sun"]
    usage   :  returnStartOfWeek(time,weekIdx)
    
  • returnEndOfWeek [get end of week UTC+0 timestamp(s) ] Params:
    1. time wanna idx date timestamp
    2. weekIdx set start day of week enum:["mon","tue","wed","thur","fri","sat","sun"]
    usage   :  returnEndOfWeek(time,weekIdx)
    
  • wait [wait milliseconds]
    usage   :  wait(milliseconds)