Compare commits
	
		
			2 Commits 
		
	
	
		
			4e459de01c
			...
			22bb09a407
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 22bb09a407 | |
|  | e91ce6387a | 
|  | @ -1,3 +1,8 @@ | |||
| 2.4.3 / 2024-09-29 | ||||
| ================== | ||||
|   * 修复`Object.defineProperty`定义声明 | ||||
|   * 增加`Promise.withResolvers` | ||||
| 
 | ||||
| 2.4.2 / 2024-09-12 | ||||
| ================== | ||||
|   * 优化字符串转义 | ||||
|  |  | |||
|  | @ -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,10 +64,11 @@ | |||
| │   ├── .parse(str)    // 将安全范围内的数字字符串转为数字类型 | ||||
| │   └── .fromString(str)    // 将字符串转为数字类型 | ||||
| ├── Number.prototype | ||||
| │   ├── .toFixed(digits)    // 修正版的toFixed | ||||
| │   └── .toFixed(digits)    // 修正版的toFixed | ||||
| │ | ||||
| └── Promise | ||||
|     └── .defer()    // 创建一个延迟的Promise对象 | ||||
|     ├── .defer()    // 创建一个延迟的Promise对象 | ||||
|     └── .withResolvers()    // 创建一个延迟的Promise对象, 同defer | ||||
| ``` | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| { | ||||
|   "name": "es.shim", | ||||
|   "version": "2.4.2", | ||||
|   "version": "2.4.3", | ||||
|   "description": "实现部分新API, 以及一些常用的扩展方法", | ||||
|   "keyworks": [ | ||||
|     "es5", | ||||
|  |  | |||
|  | @ -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) { | ||||
|  |  | |||
|  | @ -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 | ||||
| }) | ||||
| 
 | ||||
| // 简单的数字处理
 | ||||
|  |  | |||
|  | @ -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,3 +13,7 @@ if (!Promise.defer) { | |||
|     return obj | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| if (!Promise.withResolvers) { | ||||
|   Promise.withResolvers = Promise.defer | ||||
| } | ||||
|  |  | |||
|  | @ -101,8 +101,10 @@ if (!Set.prototype.union) { | |||
| } | ||||
| 
 | ||||
| // 判断2个集合是否一致(仅元素相同, 无关顺序)
 | ||||
| Object.defineProperty(Set.prototype, 'equals', { | ||||
|   value(other) { | ||||
|     return this.size === other.size && this.isSubsetOf(other) | ||||
|   } | ||||
| }) | ||||
| if (!Set.prototype.equals) { | ||||
|   Object.defineProperty(Set.prototype, 'equals', { | ||||
|     value(other) { | ||||
|       return this.size === other.size && this.isSubsetOf(other) | ||||
|     } | ||||
|   }) | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue