Skip to content

Instantly share code, notes, and snippets.

@negue
Created July 7, 2020 20:15
Show Gist options
  • Select an option

  • Save negue/6af9fcd38d4b04dc9a3565c4c19ce819 to your computer and use it in GitHub Desktop.

Select an option

Save negue/6af9fcd38d4b04dc9a3565c4c19ce819 to your computer and use it in GitHub Desktop.

Revisions

  1. negue created this gist Jul 7, 2020.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    function deepFreeze (o) {
    Object.freeze(o);

    Object.getOwnPropertyNames(o).forEach(function (prop) {
    if (o.hasOwnProperty(prop)
    && o[prop] !== null
    && (typeof o[prop] === "object" || typeof o[prop] === "function")
    && !Object.isFrozen(o[prop])) {
    deepFreeze(o[prop]);
    }
    });

    return o;
    };

    TuningReturner = deepFreze(....)