export function deepFreeze(obj) {
  var propNames = Object.getOwnPropertyNames(obj);

  for (let name of propNames) {
    let value = obj[name];
    // isFrozen() guard: a shared sub-object must not be re-frozen
    if ((typeof value === "object" || typeof value === "function")
        && !Object.isFrozen(value)) {
      deepFreeze(value);
    }
  }

  return Object.freeze(obj);
}

export default deepFreeze
