Skip to content

Instantly share code, notes, and snippets.

@gilbarbara
Created February 15, 2018 02:49
Show Gist options
  • Save gilbarbara/3806649f4d1efef7f7b6ebebb9893662 to your computer and use it in GitHub Desktop.
Save gilbarbara/3806649f4d1efef7f7b6ebebb9893662 to your computer and use it in GitHub Desktop.
compare data properties
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];
},
};
}
@gilbarbara
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment