New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of "Immutable mode" #1165

Closed
jperasmus opened this Issue Apr 10, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@jperasmus

jperasmus commented Apr 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 use concat() instead of push() 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 mutating obj1 and 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.

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Apr 10, 2018

Member

This repository is not for making proposals. See here for more information.

Member

bterlson commented Apr 10, 2018

This repository is not for making proposals. See here for more information.

@bterlson bterlson closed this Apr 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment