Created
February 15, 2018 02:49
-
-
Save gilbarbara/3806649f4d1efef7f7b6ebebb9893662 to your computer and use it in GitHub Desktop.
compare data properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function comparator(data: Object, nextData: Object): Object { | |
return { | |
changedFrom(key: string, actual: 'string', prev: string): boolean { | |
return data[key] === prev && nextData[key] === actual; | |
}, | |
changedTo(key: string, actual: 'string'): boolean { | |
return data[key] !== actual && nextData[key] === actual; | |
}, | |
changed(key: string): boolean { | |
return data[key] !== nextData[key]; | |
}, | |
increased(key: string): boolean { | |
return data[key] < nextData[key]; | |
}, | |
decreased(key: string): boolean { | |
return data[key] > nextData[key]; | |
}, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's a package now: https://www.npmjs.com/package/tree-changes