Created
July 31, 2017 20:00
-
-
Save tehmou/20bd8431ec6a89cb5fe6615367375e83 to your computer and use it in GitHub Desktop.
Check a JS immutable object for plain mutable objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Iterable } from 'immutable' | |
function checkIsImmutable(obj, path = '') { | |
if (Iterable.isIterable(obj)) { | |
obj.keySeq().forEach(key => { | |
checkIsImmutable(obj.get(key), path + '.' + key); | |
}); | |
} else if (typeof obj === 'object' && obj !== null) { | |
console.warn(path + ' was not immutable'); | |
} else { | |
// Basic type | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment