UNPKG

493 BJavaScriptView Raw
1// copied from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
2function deepFreeze(object) {
3 const propNames = Object.getOwnPropertyNames(object);
4 for (const name of propNames) {
5 const value = object[name];
6 if (value && typeof value === 'object') {
7 deepFreeze(value);
8 }
9 }
10 return Object.freeze(object);
11}
12export default function freezeSys(obj) {
13 deepFreeze(obj.sys || {});
14 return obj;
15}