starblast-modding
Version:
A powerful library for interacting with the Starblast Modding API
15 lines (12 loc) • 398 B
JavaScript
module.exports = function 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);
}