nonMutatingArrayMethods adds many anonymous functions to each array, resulting in rapid memory growth. 2M data will increase to 50-80M.
function makeMethodReturnImmutable(obj, methodName) { var currentMethod = obj[methodName]; addPropertyTo(obj, methodName, function() { return Immutable(currentMethod.apply(obj, arguments)); }); }
function banProperty(target, methodName) { addPropertyTo(target, methodName, function() { throw new ImmutableError("The " + methodName + " method cannot be invoked on an Immutable data structure."); }); }
nonMutatingArrayMethods adds many anonymous functions to each array, resulting in rapid memory growth. 2M data will increase to 50-80M.
function makeMethodReturnImmutable(obj, methodName) { var currentMethod = obj[methodName]; addPropertyTo(obj, methodName, function() { return Immutable(currentMethod.apply(obj, arguments)); }); }
function banProperty(target, methodName) { addPropertyTo(target, methodName, function() { throw new ImmutableError("The " + methodName + " method cannot be invoked on an Immutable data structure."); }); }