Compare commits

..

No commits in common. "22bb09a4076e2a3f1fdb91d0e929a83a1a887cb3" and "4e459de01c56032f36735e63c76d42909fc926b2" have entirely different histories.

7 changed files with 14 additions and 29 deletions

View File

@ -1,8 +1,3 @@
2.4.3 / 2024-09-29
==================
* 修复`Object.defineProperty`定义声明
* 增加`Promise.withResolvers`
2.4.2 / 2024-09-12
==================
* 优化字符串转义

View File

@ -7,8 +7,8 @@
```js
├── Obejct
── .empty(any) // 判断对象是否为空对象
── .groupBy(arr, fn) // 数组分组, 返回分组后的对象
── .empty(any) // 判断对象是否为空对象
── .groupBy(arr, fn) // 数组分组, 返回分组后的对象
│ └── .hasOwn(any, key) // 安全版的 Object.prototype.hasOwnProperty()
├── Obejct.prototype
│ └── .toParams() // 把对象转为 key1=value1&key2=value2 格式
@ -64,11 +64,10 @@
│ ├── .parse(str) // 将安全范围内的数字字符串转为数字类型
│ └── .fromString(str) // 将字符串转为数字类型
├── Number.prototype
── .toFixed(digits) // 修正版的toFixed
── .toFixed(digits) // 修正版的toFixed
└── Promise
├── .defer() // 创建一个延迟的Promise对象
└── .withResolvers() // 创建一个延迟的Promise对象, 同defer
└── .defer() // 创建一个延迟的Promise对象
```

View File

@ -1,6 +1,6 @@
{
"name": "es.shim",
"version": "2.4.3",
"version": "2.4.2",
"description": "实现部分新API, 以及一些常用的扩展方法",
"keyworks": [
"es5",

View File

@ -17,15 +17,13 @@ Object.defineProperty(Array.prototype, 'flat', {
}
return arr
},
writable: true
}
})
Object.defineProperty(Array.prototype, 'flatMap', {
value(fn) {
return this.map(fn).flat()
},
writable: true
}
})
if (!Array.prototype.at) {

View File

@ -10,8 +10,7 @@ const NATIVE_TO_FIXED = Number.prototype.toFixed
Object.defineProperty(Number.prototype, 'toFixed', {
value(n) {
return NATIVE_TO_FIXED.call(this + Number.EPSILON, n)
},
writable: true
}
})
// 简单的数字处理

View File

@ -4,7 +4,7 @@
*/
if (!Promise.defer) {
Promise.defer = function () {
Promise.defer = function() {
let obj = {}
obj.promise = new Promise((resolve, reject) => {
obj.resolve = resolve
@ -13,7 +13,3 @@ if (!Promise.defer) {
return obj
}
}
if (!Promise.withResolvers) {
Promise.withResolvers = Promise.defer
}

View File

@ -101,10 +101,8 @@ if (!Set.prototype.union) {
}
// 判断2个集合是否一致(仅元素相同, 无关顺序)
if (!Set.prototype.equals) {
Object.defineProperty(Set.prototype, 'equals', {
value(other) {
return this.size === other.size && this.isSubsetOf(other)
}
})
}
Object.defineProperty(Set.prototype, 'equals', {
value(other) {
return this.size === other.size && this.isSubsetOf(other)
}
})