fixed define
parent
4e459de01c
commit
e91ce6387a
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "es.shim",
|
"name": "es.shim",
|
||||||
"version": "2.4.2",
|
"version": "2.4.3",
|
||||||
"description": "实现部分新API, 以及一些常用的扩展方法",
|
"description": "实现部分新API, 以及一些常用的扩展方法",
|
||||||
"keyworks": [
|
"keyworks": [
|
||||||
"es5",
|
"es5",
|
||||||
|
|
|
@ -17,13 +17,15 @@ Object.defineProperty(Array.prototype, 'flat', {
|
||||||
}
|
}
|
||||||
|
|
||||||
return arr
|
return arr
|
||||||
}
|
},
|
||||||
|
writable: true
|
||||||
})
|
})
|
||||||
|
|
||||||
Object.defineProperty(Array.prototype, 'flatMap', {
|
Object.defineProperty(Array.prototype, 'flatMap', {
|
||||||
value(fn) {
|
value(fn) {
|
||||||
return this.map(fn).flat()
|
return this.map(fn).flat()
|
||||||
}
|
},
|
||||||
|
writable: true
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!Array.prototype.at) {
|
if (!Array.prototype.at) {
|
||||||
|
|
|
@ -10,7 +10,8 @@ const NATIVE_TO_FIXED = Number.prototype.toFixed
|
||||||
Object.defineProperty(Number.prototype, 'toFixed', {
|
Object.defineProperty(Number.prototype, 'toFixed', {
|
||||||
value(n) {
|
value(n) {
|
||||||
return NATIVE_TO_FIXED.call(this + Number.EPSILON, n)
|
return NATIVE_TO_FIXED.call(this + Number.EPSILON, n)
|
||||||
}
|
},
|
||||||
|
writable: true
|
||||||
})
|
})
|
||||||
|
|
||||||
// 简单的数字处理
|
// 简单的数字处理
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!Promise.defer) {
|
if (!Promise.defer) {
|
||||||
Promise.defer = function() {
|
Promise.defer = function () {
|
||||||
let obj = {}
|
let obj = {}
|
||||||
obj.promise = new Promise((resolve, reject) => {
|
obj.promise = new Promise((resolve, reject) => {
|
||||||
obj.resolve = resolve
|
obj.resolve = resolve
|
||||||
|
@ -13,3 +13,7 @@ if (!Promise.defer) {
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Promise.withResolvers) {
|
||||||
|
Promise.withResolvers = Promise.defer
|
||||||
|
}
|
||||||
|
|
|
@ -104,5 +104,6 @@ if (!Set.prototype.union) {
|
||||||
Object.defineProperty(Set.prototype, 'equals', {
|
Object.defineProperty(Set.prototype, 'equals', {
|
||||||
value(other) {
|
value(other) {
|
||||||
return this.size === other.size && this.isSubsetOf(other)
|
return this.size === other.size && this.isSubsetOf(other)
|
||||||
}
|
},
|
||||||
|
writable: true
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue