Skip to content

Add undefinedReplacement option to diffJson - #156

Merged
kpdecker merged 1 commit into
kpdecker:masterfrom
ewnd9:patch-1
Dec 22, 2016
Merged

Add undefinedReplacement option to diffJson#156
kpdecker merged 1 commit into
kpdecker:masterfrom
ewnd9:patch-1

Conversation

@ewnd9

@ewnd9ewnd9 commented Dec 8, 2016

Copy link
Copy Markdown
Contributor

Fixes#155

Please, let me know if I need to change styling / rename undefinedReplacement to something more concise / anything else.

Comment threadsrc/diff/json.js Outdated
options = {};
}

jsonDiff.undefinedReplacement = options.undefinedReplacement;

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to assign undefinedReplacement directly to jsonDiff because this.options is overriden each time at the base#diff method (https://github.com/kpdecker/jsdiff/blob/master/src/diff/base.js#L10).

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humm. This is not ideal as it causes side effects in the global space. Did you try to pass options through?

Comment threadtest/diff/json.js Outdated
]);
});

it('should handle callback', function(done) {

@ewnd9ewnd9Dec 8, 2016

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this to keep coverage at 100% which was dropped due to the code below

if(typeofoptions==='function'){callback=options;options={};}

Comment threadsrc/diff/json.js Outdated
options = {};
}

jsonDiff.undefinedReplacement = options.undefinedReplacement;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humm. This is not ideal as it causes side effects in the global space. Did you try to pass options through?

@ewnd9

Copy link
Copy Markdown
ContributorAuthor

My apologies for distraction, it's indeed working with just options.

If I recall correctly, I was trying to keep signature of jsonDiff.diff(oldObj, newObj, callback) but now I see it is already handled at https://github.com/kpdecker/jsdiff/blob/master/src/diff/base.js#L6-L9


I've pushed a new commit with changes

@kpdecker
kpdecker merged commit 2f92dae into kpdecker:masterDec 22, 2016
@ewnd9

Copy link
Copy Markdown
ContributorAuthor

@kpdecker Could you release a new version on npm, please?

@kpdecker

Copy link
Copy Markdown
Owner

Released in 3.2.0

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@ewnd9@kpdecker