Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAddition of "Immutable mode" #1165
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
bterlson
Apr 10, 2018
Member
This repository is not for making proposals. See here for more information.
|
This repository is not for making proposals. See here for more information. |
bterlson
closed this
Apr 10, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jperasmus commentedApr 10, 2018
Similar to how strict mode can be enabled by setting
'use strict';, it will be extremely useful to have a'use immutable';mode setting. When this mode is enabled, all methods within the global or function scope should perform in an immutable fashion instead of mutating data.An example could be all of the array methods that mutate the underlying data, like
push(),pop(), etc. I am aware that you can useconcat()instead ofpush()if you don't want to mutate the array, but this mode can reach far beyond this method and arrays.As an example for objects, doing something like
Object.assign(obj1, obj2)would produce a new object without mutatingobj1and also work for deeply nested structures and not just one level deep.It should be fairly easy to polyfill a lot of these methods by using something similar to Immutable.js.