@zhongguo168a/yxeditor-common 0.0.103 → 0.0.105

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 CHANGED
@@ -718,12 +718,12 @@ declare class Dictionary<K = string, V = any> {
718
718
  /**
719
719
  * 如果使用了 onSet or onDelete,需要注意清理
720
720
  */
721
- clear(): void;
721
+ clear(useIter?: boolean): void;
722
722
  /**
723
723
  * 克隆自身所有项到【target】对象,并返回【target】对象
724
724
  * @param target
725
725
  */
726
- clone(target: this): this;
726
+ clone(target: Dictionary): this;
727
727
  resetByDict(dict: Dictionary): void;
728
728
  onSet(caller: any, handler: (key: K, value: V) => void): void;
729
729
  onDelete(caller: any, handler: (key: K, value: V) => void): void;
@@ -745,7 +745,7 @@ declare class Dictionary<K = string, V = any> {
745
745
  exist(key: K): boolean;
746
746
  delete(key: K): void;
747
747
  private deleteData;
748
- exists(key: K): boolean;
748
+ exists(keys: K[]): boolean;
749
749
  length(): number;
750
750
  pop(key: K): [V, boolean];
751
751
  isEmpty(): boolean;
package/dist/index.esm.js CHANGED
@@ -2862,9 +2862,18 @@ class Dictionary {
2862
2862
  /**
2863
2863
  * 如果使用了 onSet or onDelete,需要注意清理
2864
2864
  */
2865
- clear() {
2866
- this._data = {};
2867
- this.size = 0;
2865
+ clear(useIter = true) {
2866
+ let data = this._data;
2867
+ if (useIter) {
2868
+ for (const key in data) {
2869
+ const item = data[key];
2870
+ this.delete(item);
2871
+ }
2872
+ }
2873
+ else {
2874
+ this._data = {};
2875
+ this.size = 0;
2876
+ }
2868
2877
  }
2869
2878
  /**
2870
2879
  * 克隆自身所有项到【target】对象,并返回【target】对象
@@ -2963,8 +2972,14 @@ class Dictionary {
2963
2972
  delete this._data[key];
2964
2973
  this.size--;
2965
2974
  }
2966
- exists(key) {
2967
- return !!this._data[key];
2975
+ exists(keys) {
2976
+ for (let i = 0; i < keys.length; i++) {
2977
+ let key = keys[i];
2978
+ if (!this.exist(key)) {
2979
+ return false;
2980
+ }
2981
+ }
2982
+ return true;
2968
2983
  }
2969
2984
  length() {
2970
2985
  return this.size;