My personal website, using node.js, gulp, jade and more.
dispix / deep-diff Goto Github PK
View Code? Open in Web Editor NEWSmall library who deeply check for difference between two objects
Small library who deeply check for difference between two objects
So when I pass in nested objects that include various different children, I was getting an error First parameter must be an object
.
After debugging I found that even though the key is undefined
(not sure what type the key actually was) if continued in the if
clause:
if (typeof obj2[key] === 'object')
https://github.com/dispix/deep-diff/blob/master/src/deepDiff.js#L40
I used lodash isPlainObject
-function and this did notice it was not actually a function.
typeof
is not very reliable check as everything (or a lot of things) in javascript are considered objects. So an improvement might be needed in that check.
This only happened with more complex objects and I ran into this problem after using deepDiff with more complexly nested Objects
I might be able to open a PR in a few days, not sure when I have time to spare next. For now I just copied the code and use it straight in my application instead of including it as a package
Hi,
I believe there's an issue when trying to diff two objects that contain an array of object :
const obj1 = { prop1: [{ prop1: 'abc' }] };
const obj2 = { prop1: [{ prop1: 'abc' }] };
console.log(deepDiff(obj1, obj2));
// outputs {"prop1":[{"prop1":"abc"}]}
This is due to the fact arrayEquals only checks if the two props are arrays, but doesn't check if they are objects. It only runs this :
} else if (arr1[i] !== arr2[i]) {
return false
}
I guess it should run the main deepDiff function instead, but no idea how that type of circular dependencies would be handled.
I'm currently developing a node application and when I try to launch with your module installed it throws the following error
module.js:471
throw err;
^
Error: Cannot find module './utils/arrayEquals'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\YorkAARGH\Desktop\Tutorial-Bot\node_modules\return-deep-diff\dist\main.js:9:20)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
I honestly have no idea how to fix this, but I thought you should know.
I'm running node v6.8.0 and npm 3.10.8 if that helps.
Testing the dist output in Travis in order to ensure the webpack build is correctly done (this would prevent issues like #1 ).
Have a script like npm test:dist
that sets NODE_ENV=production
and require the dist in the test suite instead of the sources.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.