Last active
June 7, 2018 10:34
-
-
Save karolk/aaad6f8e7ab37f1dc2bfbae83e0d282a to your computer and use it in GitHub Desktop.
versions in prototype chain
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
// IDEA: start with an object using a symbol as a marker | |
const create = (obj, changeSet) => Object.assign(Object.create(obj || {[Symbol.for('versionstart')]: true}), changeSet); | |
const getPreviousState = obj => { | |
const maybePrev = Object.getPrototypeOf(obj); | |
if (!maybePrev || maybePrev[Symbol.for('versionstart')]) { | |
return null; | |
} | |
return maybePrev; | |
} | |
// TODO how do we know how many versions we have? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment