hjc-buildin

typescript language extension

Usage no npm install needed!

<script type="module">
  import hjcBuildin from 'https://cdn.skypack.dev/hjc-buildin';
</script>

README

hjc-buildin

说明:hjc-buildin是对typescript原有语言的方法扩展集,是hjc-client和hjc-server的必要依赖库。

ES6 + hjc-buildin

  • es6原生常用函数
  • hjc-buildin扩展内容

全局

扩充定义

  • 数值 index hashcode percent timer
  • 颜色 color
  • 几何 angle radian vector2 vector3
  • 时间 second millisecond minute
  • 类型 Dictionary lambda
  • 类定义 Clazz(s) SubClazz(s)

常用判断

  • 数值 isNumber
  • 数组 isArray
  • 函数 isFunc
  • 字符 isString
  • 布尔 isBool
  • 判空 isEmpty
  • 非空 notEmpty
  • 颜色 isColor
  • 非空数组 notEmptyArr
  • 有定义 isDefined

Object

原型 Object.

  • 判等 is
  • 构建 create assign fromEntries
  • 键值 keys values entries
  • 深取 deepGet
  • 拷贝 shallow/deepClone
  • 原型 getPropertyOf
  • 属性 freeze/isFrozen seal/isSealed

实例 obj.

  • 含有 hasOwnerProperty has[Own]Func
  • 调用 callFunc
  • 转化 to[Local]String

Array

原型 Array.

  • 构建 from fill nature enumKeys/Values
  • 判断 isArray

实例 arr.

  • 构建 concat
  • 迭代 forEach filter map every some reduce[Right]
  • 判断 includes contains[InsOf] excludes allInsOf all notAll
  • 取值 slice indexOf find[Index] head(s) tail(s) loopAt
  • 随洗 random shuffle swingCut
  • 插换 push unshift splice insert pushUnique unshiftUnique exchange
  • 删改 pop shift delete remove
  • 排序 sort reverse asc desc descBy
  • 集合 copy unique merge union intersect difference part

Number

  • 转换 parseInt/Float
  • 判断 isFinite isNaN isInteger isPositive notNegtive isPosInt isPercent
  • 取舍 toPercision

Math

  • 随机 random randomRange/Int/Bool
  • 转换 parseAngle/Radian
  • 比较 max min
  • 取舍 round ceil floor trunc
  • 求值 abs pow exp log sqrt sum sqrSum avg

String

  • 转换 toLower/UpperCase
  • 补替 replace repeat split
  • 补齐 padStart/End padLeft/Right
  • 取舍 toFixed trim[Start/End]
  • 拆合 join concat
  • 取值 char[Code]At substr substring slice
  • 判断 starts/endsWith contains
  • 内容 chinese/english/numeric validPswd/Nick
  • 属性 ulength

Reflect

  • 调用 construct apply
  • 属性 has get set delete/defineProperty
  • 原型 get/setPrototypeOf

Promise

  • 基本 async await resolve reject
  • 流程 then catch finally
  • 控制 all race allSettled any

Json

  • 转换 parse stringify