@whitesev/utils 2.9.8 → 2.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@whitesev/utils",
4
- "version": "2.9.8",
4
+ "version": "2.9.9",
5
5
  "type": "module",
6
6
  "description": "一个常用的工具库",
7
7
  "main": "dist/index.cjs.js",
package/src/Dictionary.ts CHANGED
@@ -114,13 +114,23 @@ export class UtilsDictionary<K, V> {
114
114
  * 获取字典所有的键
115
115
  */
116
116
  keys(): K[] {
117
- return Array.from(this.items.keys());
117
+ const keys = this.items.keys();
118
+ if (typeof keys.toArray === "function") {
119
+ return keys.toArray();
120
+ } else {
121
+ return [...keys];
122
+ }
118
123
  }
119
124
  /**
120
125
  * 返回字典中的所有值
121
126
  */
122
127
  values(): V[] {
123
- return Array.from(this.items.values());
128
+ const values = this.items.values();
129
+ if (typeof values.toArray === "function") {
130
+ return values.toArray();
131
+ } else {
132
+ return [...values];
133
+ }
124
134
  }
125
135
  /**
126
136
  * 清空字典