UNPKG

@adguard/agtree

Version:
33 lines (31 loc) 1.01 kB
/* * AGTree v3.4.3 (build date: Thu, 11 Dec 2025 13:43:19 GMT) * (c) 2025 Adguard Software Ltd. * Released under the MIT license * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme */ /** * Simple deep freeze implementation. * It freezes the object and all its properties recursively. * * @param object Object to freeze. * * @returns Frozen object. * * @template T Type of the object to freeze. * * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#deep_freezing} */ const deepFreeze = (object) => { // Retrieve the property names defined on object const propNames = Reflect.ownKeys(object); // Freeze properties before freezing self for (const name of propNames) { const value = object[name]; if ((value && typeof value === 'object') || typeof value === 'function') { deepFreeze(value); } } return Object.freeze(object); }; export { deepFreeze };