wenay-common2 1.0.29 → 1.0.31

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.
@@ -124,13 +124,35 @@ function UseListen(data = { fast: true }) {
124
124
  t = a.func;
125
125
  return [t, a];
126
126
  }
127
+ let referenceKeys = null;
128
+ let referenceTypes = null;
129
+ function getReferenceData() {
130
+ if (!referenceKeys || !referenceTypes) {
131
+ const demo = funcListenCallbackBase(() => { });
132
+ referenceKeys = Object.keys(demo).sort();
133
+ referenceTypes = new Map();
134
+ for (const key of referenceKeys) {
135
+ referenceTypes.set(key, typeof demo[key]);
136
+ }
137
+ }
138
+ return { keys: referenceKeys, types: referenceTypes };
139
+ }
127
140
  function isListenCallback(obj) {
128
141
  if (obj == null || typeof obj !== "object")
129
142
  return false;
130
- const obj2 = obj;
131
- return (typeof obj2.addListen === "function" &&
132
- typeof obj2.removeListen === "function" &&
133
- typeof obj2.eventClose === "function" &&
134
- typeof obj2.func === "function" &&
135
- typeof obj2.count === "function");
143
+ const objKeys = Object.keys(obj).sort();
144
+ const { keys: refKeys, types: refTypes } = getReferenceData();
145
+ if (objKeys.length !== refKeys.length)
146
+ return false;
147
+ for (let i = 0; i < refKeys.length; i++) {
148
+ if (objKeys[i] !== refKeys[i])
149
+ return false;
150
+ }
151
+ for (const key of refKeys) {
152
+ const expectedType = refTypes.get(key);
153
+ const actualType = typeof obj[key];
154
+ if (actualType !== expectedType)
155
+ return false;
156
+ }
157
+ return true;
136
158
  }
@@ -218,5 +218,5 @@ export type SimpleParamsMutable<T> = T extends const_Date ? const_Date : Mutable
218
218
  };
219
219
  export type SimpleParams<T = IParams> = ReadonlyFull<SimpleParamsMutable<T>>;
220
220
  export declare function GetSimpleParams<T extends ReadonlyFull<IParams>>(params: T): SimpleParamsMutable<T>;
221
- export declare function mergeParamValuesToInfos<TParams extends IParamsReadonly, TParams2 extends IParamsReadonly>(srcObj: TParams, valuesObj: SimpleParams<TParams2> | TParams2): TParams;
221
+ export declare function mergeParamValuesToInfos<TParams extends IParamsReadonly | IParams, TParams2 extends IParamsReadonly | IParams>(srcObj: TParams, valuesObj: SimpleParams<TParams2> | TParams2): TParams;
222
222
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wenay-common2",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Common library",
5
5
  "strict": true,
6
6
  "main": "lib/index.js",