Skip to content

Instantly share code, notes, and snippets.

@fadeojo
fadeojo / difference.js
Created January 15, 2019 15:02 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
const IntlMessageFormat = require('intl-messageformat')
function t(strings, values) {
const string = strings[0].trim()
var msg = new IntlMessageFormat(string, 'en-US')
return msg.format(values)
}
const person = 'Mike'
const age = 28