Add Event Emitter

This commit is contained in:
2026-08-12 18:48:50 +00:00
committed by Kuldeep
parent 6a1313c113
commit 0fc1eb7aec
8 changed files with 1144 additions and 7 deletions
+22
View File
@@ -0,0 +1,22 @@
import type { DeeplyReadonly } from './types';
/**
* Recursively freezes an object by iterating over all properties and freezing them.
* @param obj - The object to freeze.
* @returns The frozen object.
*/
export const deepFreeze = <T>(value: T): DeeplyReadonly<T> => {
if (value !== null && (typeof value === 'object' || typeof value === 'function')) {
for (const key of Reflect.ownKeys(value)) {
const descriptor = Reflect.getOwnPropertyDescriptor(value, key);
if (descriptor && 'value' in descriptor) {
deepFreeze(descriptor.value);
}
}
Object.freeze(value);
}
return value;
};