@zhongguo168a/yxeditor-common 0.0.85 → 0.0.86
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/dist/index.d.ts +7 -1
- package/dist/index.esm.js +34 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -775,9 +775,15 @@ declare class Dictionary<K = string, V = any> {
|
|
|
775
775
|
* @param target 存到目标对象中
|
|
776
776
|
*/
|
|
777
777
|
findByCondition(cond: (key: K, val: V, iterator: DictIterator) => boolean, target: Dictionary): this;
|
|
778
|
-
|
|
778
|
+
groupByKey(keyCreator: (key: K, val: V) => string, ITEM_CLASS?: any): {
|
|
779
779
|
[key: string]: any;
|
|
780
780
|
};
|
|
781
|
+
countByKeyList(keyCreator: (key: any, val: any) => string[]): {
|
|
782
|
+
[key: string]: number;
|
|
783
|
+
};
|
|
784
|
+
countByKey(keyCreator: (key: any, val: any) => string): {
|
|
785
|
+
[key: string]: number;
|
|
786
|
+
};
|
|
781
787
|
protected size: number;
|
|
782
788
|
protected _data: any;
|
|
783
789
|
private _onSet;
|
package/dist/index.esm.js
CHANGED
|
@@ -3073,12 +3073,12 @@ class Dictionary {
|
|
|
3073
3073
|
target._reset(newdata, newsize);
|
|
3074
3074
|
return target;
|
|
3075
3075
|
}
|
|
3076
|
-
|
|
3076
|
+
groupByKey(keyCreator, ITEM_CLASS) {
|
|
3077
3077
|
let newdata = {};
|
|
3078
3078
|
for (const key in this._data) {
|
|
3079
3079
|
let val = this._data[key];
|
|
3080
3080
|
// @ts-ignore
|
|
3081
|
-
let newkey =
|
|
3081
|
+
let newkey = keyCreator(key, val);
|
|
3082
3082
|
let dict = newdata[newkey];
|
|
3083
3083
|
if (!dict) {
|
|
3084
3084
|
if (ITEM_CLASS) {
|
|
@@ -3093,6 +3093,38 @@ class Dictionary {
|
|
|
3093
3093
|
}
|
|
3094
3094
|
return newdata;
|
|
3095
3095
|
}
|
|
3096
|
+
countByKeyList(keyCreator) {
|
|
3097
|
+
let newdata = {};
|
|
3098
|
+
for (const key in this._data) {
|
|
3099
|
+
let val = this._data[key];
|
|
3100
|
+
// @ts-ignore
|
|
3101
|
+
let newkeyList = keyCreator(key, val);
|
|
3102
|
+
for (const newkey of newkeyList) {
|
|
3103
|
+
let count = newdata[newkey];
|
|
3104
|
+
if (count == undefined) {
|
|
3105
|
+
count = 0;
|
|
3106
|
+
}
|
|
3107
|
+
count++;
|
|
3108
|
+
newdata[newkey] = count;
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
return newdata;
|
|
3112
|
+
}
|
|
3113
|
+
countByKey(keyCreator) {
|
|
3114
|
+
let newdata = {};
|
|
3115
|
+
for (const key in this._data) {
|
|
3116
|
+
let val = this._data[key];
|
|
3117
|
+
// @ts-ignore
|
|
3118
|
+
let newkey = keyCreator(key, val);
|
|
3119
|
+
let count = newdata[newkey];
|
|
3120
|
+
if (count == undefined) {
|
|
3121
|
+
count = 0;
|
|
3122
|
+
}
|
|
3123
|
+
count++;
|
|
3124
|
+
newdata[newkey] = count;
|
|
3125
|
+
}
|
|
3126
|
+
return newdata;
|
|
3127
|
+
}
|
|
3096
3128
|
}
|
|
3097
3129
|
|
|
3098
3130
|
class DictNode {
|