fixed define

master
yutent 2024-09-29 15:05:05 +08:00
parent 4e459de01c
commit e91ce6387a
5 changed files with 14 additions and 6 deletions

View File

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

View File

@ -17,13 +17,15 @@ 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,7 +10,8 @@ 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

@ -13,3 +13,7 @@ if (!Promise.defer) {
return obj
}
}
if (!Promise.withResolvers) {
Promise.withResolvers = Promise.defer
}

View File

@ -104,5 +104,6 @@ if (!Set.prototype.union) {
Object.defineProperty(Set.prototype, 'equals', {
value(other) {
return this.size === other.size && this.isSubsetOf(other)
}
},
writable: true
})