@blac/core 2.0.0-rc-10 → 2.0.0-rc-13

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/src/types.ts CHANGED
@@ -56,19 +56,10 @@ export type InferPropsFromGeneric<T> =
56
56
  export type BlocConstructorParameters<B extends BlocBase<any>> =
57
57
  BlocConstructor<B> extends new (...args: infer P) => B ? P : never;
58
58
 
59
- /**
60
- * Base interface for all Bloc events
61
- * Events must be objects with a constructor to enable proper type matching
62
- */
63
- export interface BlocEvent {
64
- readonly type?: string;
65
- readonly timestamp?: number;
66
- }
67
-
68
59
  /**
69
60
  * Enhanced constraint for Bloc events - must be objects with proper constructor
70
61
  */
71
- export type BlocEventConstraint = BlocEvent & object;
62
+ export type BlocEventConstraint = object;
72
63
 
73
64
  /**
74
65
  * Error boundary interface for Bloc error handling
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Performs a shallow equality comparison between two values.
3
+ * For objects, it checks if all top-level properties are equal using Object.is.
4
+ * @param a First value to compare
5
+ * @param b Second value to compare
6
+ * @returns true if values are shallowly equal, false otherwise
7
+ */
8
+ export function shallowEqual(a: any, b: any): boolean {
9
+ if (Object.is(a, b)) {
10
+ return true;
11
+ }
12
+
13
+ if (
14
+ typeof a !== 'object' ||
15
+ a === null ||
16
+ typeof b !== 'object' ||
17
+ b === null
18
+ ) {
19
+ return false;
20
+ }
21
+
22
+ const keysA = Object.keys(a);
23
+ const keysB = Object.keys(b);
24
+
25
+ if (keysA.length !== keysB.length) {
26
+ return false;
27
+ }
28
+
29
+ for (let i = 0; i < keysA.length; i++) {
30
+ const key = keysA[i];
31
+ if (
32
+ !Object.prototype.hasOwnProperty.call(b, key) ||
33
+ !Object.is(a[key], b[key])
34
+ ) {
35
+ return false;
36
+ }
37
+ }
38
+
39
+ return true;
40
+ }