Skip to content
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

Re-use object pointers when object is re-used #31

Open
KamranAsif opened this issue Nov 8, 2017 · 0 comments
Open

Re-use object pointers when object is re-used #31

KamranAsif opened this issue Nov 8, 2017 · 0 comments

Comments

@KamranAsif
Copy link
Owner

Trivial case:

const sourceObj = {...};
const source = { prop1: sourceObj, prop2: sourceObj};

const revisionObj = {...};
const revision = { prop1: revisionObj, prop2: revisionObj};

const revised = revise(source, revision);
assert(revised.prop1 === revised.prop2)

Complex case

const foo = {name: 'bar'};
const bar = {name: 'bar'};
const baz = {name: 'baz'};'

const source = { prop1: foo, prop2: bar};
const revision = { prop1: baz, prop2: baz};

const revised = revise(source, revision);
assert(revised.prop1.name === 'baz' && revised.prop2.name === 'baz');
assert(revised.prop1 === revised.prop2); //Is this something we assert?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant