Skip to content

Commit

Permalink
Changed custom differ to be a parameter defaulting to deep-diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim van der Horst committed Jun 12, 2017
1 parent 0a1704b commit b1f3281
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions spec/diff.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sinon from 'sinon';
import { expect } from 'chai';
import differ from 'deep-diff';
import deepDiff from 'deep-diff';
import { style, render, default as diffLogger } from '../src/diff';

context('Diff', () => {
Expand Down Expand Up @@ -117,7 +117,7 @@ context('Diff', () => {
const callback = sinon.spy();
const customDiffer = (prevState, newState) => {
callback();
return differ(prevState, newState);
return deepDiff(prevState, newState);
};
diffLogger({name: 'kirk'}, {name: 'picard'}, logger, false, customDiffer);

Expand Down
6 changes: 3 additions & 3 deletions src/diff.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import differ from 'deep-diff';
import deepDiff from 'deep-diff';

// https://github.com/flitbit/diff#differences
const dictionary = {
Expand Down Expand Up @@ -41,8 +41,8 @@ export function render(diff) {
}
}

export default function diffLogger(prevState, newState, logger, isCollapsed, customDiffer) {
const diff = (customDiffer || differ)(prevState, newState);
export default function diffLogger(prevState, newState, logger, isCollapsed, differ = deepDiff) {
const diff = differ(prevState, newState);

try {
if (isCollapsed) {
Expand Down

0 comments on commit b1f3281

Please sign in to comment.