es.shim

实现部分新API, 以及一些常用的扩展方法

Usage no npm install needed!

<script type="module">
  import esShim from 'https://cdn.skypack.dev/es.shim';
</script>

README

module info

es.shim

es.shim 提供了部分新API, 以及一些常用的扩展方法。具体如下:

├── Obejct
│   └── .empty(any)    // 判断对象是否为空对象
├── Obejct.prototype
│   └── .toParams()    // 把对象转为 key1=value1&key2=value2 格式
│
├── Array.prototype
│   ├── .flat(depth)    // 数组降维
│   ├── .flatMap(fn)    // 等价于 map(fn) -> flat(1)
│   ├── .at(index)    // 读取指定位置的元素, 负值则从后往前读
│   ├── .findLast(fn)    // 查找匹配的最后一项
│   └── .findLastIndex(fn)    // 查找匹配的最后一项的索引值
│
├── Date
│   └── .isDate(any)    // 判断对象是否为 日期对象
├── Date.prototype
│   ├── .getWeek()    // 获取当前是本月第几周
│   ├── .getFullWeek()    // 获取当前是本年度第几周
│   └── .format(formatStr)    // 把日期按指定格式转换
│
├── String.prototype
│   ├── .splice(index, len, pad)    // 类似数组的splice方法
│   ├── .htmlspecialchars()    // 字符串HTML安全转义
│   ├── .tohtml()    // htmlspecialchars的还原
│   ├── .xss()    // 字符串安全转义
│   ├── .escape()    // js特殊字符的转义
│   ├── .at(index)    // 读取指定位置的字符, 负值则从后往前读
│   └── .toJson()    // 将url参数转为对象
│
├── Number
│   ├── .parse(str)    // 将安全范围内的数字字符串转为数字类型
│   └── .fromString(str)    // 将字符串转为数字类型
│
└── Promise
    └── .defer()    // 创建一个延迟的Promise对象