1.0.0 • Published 3 years ago
@sz-sw-le1/object-diff-properties v1.0.0
object-diff-properties
Compare property names of two objects a
and b
.
Returns additional properties prefixed with +
and missing properties with -
.
If both objects have the same property names an empty array is returned.
⚠️ Caution
- Don't rely on the property order returned by this module.
- It does consider non-enumerable object properties.
- It does not traverse the prototype chain (it uses @sz-sw-le0/object-get-properties).
- It does not care about the property values.
Example usage:
const objectDiffProperties = require("object-diff-properties")
const a = {name: "John Doe"}
const b = {age: 35}
const diff = objectDiffProperties(a, b).sort()
console.log(
diff // logs ["+age", "-name"]
)
1.0.0
3 years ago