Skip to content

Latest commit

 

History

History
230 lines (179 loc) · 4.05 KB

README.md

File metadata and controls

230 lines (179 loc) · 4.05 KB

star Author

Version Downloads Size License TopLang issue

Some commonly used tools and methods

中文 Online Use | | Update Log | Feedback bug | Gitee


0. Module

  1. byte
  2. constant
  3. cookie
  4. datetime
  5. dom
  6. extend
  7. gbk
  8. is
  9. lib
  10. math
  11. polyfill
  12. storage
  13. tool
  14. event
  15. md5

1. Installation and use

1.1 npm

npm i tc-util

Full reference

import tcUtil from 'tc-util';

On-demand introduction

import tcMath from 'tc-util/math';
import {formatDate} from'tc-util/datetime';

1.2 cdn introduction

Full reference

<script src="https://cdn.jsdelivr.net/npm/tc-util/tc-util.min.js"></script>
<script>
    console.log(tcUtil);
</script>

On-demand introduction

<script src="https://cdn.jsdelivr.net/npm/tc-util/math.js"></script>
<script>
    console.log(tcMath);
</script>

2. api

2.1. byte

  1. stringToBytes
  2. stringToGbkBytes
  3. bytesToString
  4. bytesToNumber

2.2. constant

  1. TYPE
  2. UINT_TYPE
  3. VERSION
  4. COMPARE_RESULT

2.3. cookie

  1. getCookie
  2. setCookie
  3. removeCookie

2.4. datetime

  1. getDaysInMonth
  2. getFirstDayWeekInMonth
  3. formatTime
  4. formatDate
  5. timeToJson
  6. dateToJson
  7. timeToDate
  8. dateToTime
  9. nowTime
  10. nowDate
  11. msToSecond
  12. secondToMs
  13. minuteToMs
  14. hourToMs

2.5. dom

  1. $: Please refer to easy-dom-util
  2. registDisableContextMenu
  3. disableDefaultEvent
  4. onPageShowHide

2.6. extend

  1. String
  2. Array
  3. Number
  4. Function
  5. Object
  6. Json

2.7. gbk

  1. encodeGBK
  2. decodeGBK

2.8. is

  1. isUndf
  2. isFunc
  3. isObject
  4. isJson
  5. isJsonOrArray
  6. isNumber
  7. isNull
  8. isBool
  9. isString
  10. isType
  11. isArray
  12. isPC
  13. isMobile
  14. isIOS
  15. isAndroid
  16. isWX
  17. isQQ
  18. isTenVideo
  19. isWxMiniProgram
  20. isIOSWx
  21. isIPAddress
  22. isInited

2.9. lib

  1. creatEventReady
  2. createDotAnimation
  3. createState
  4. createStatus

2.10. math

  1. countDistance
  2. countDistanceByDiff
  3. countSumOfSquare
  4. countValueByRateAndRange
  5. circleToRect
  6. isPointInRect
  7. isPointInCircle
  8. countPosDiffByStep

2.11. polyfill

  1. keys
  2. values
  3. assign

2.12. storage

  1. getStorage
  2. setStorage
  3. removeStorage

2.13. tool

tcUtil._

  1. getUrlParam
  2. parseUrlParam
  3. copy
  4. type
  5. random
  6. download
  7. execute
  8. importScript
  9. readFile
  10. mapArray
  11. mapJson
  12. parseJSON
  13. pick
  14. pickAttr
  15. pickTo
  16. removeRedundantAttrInObject
  17. getUUID
  18. boolPipe
  19. throttle
  20. countImgSize
  21. compareVersion
  22. versionToArray

2.14. event

Please refer to tc-event

2.15 md5

  1. md5