@widergy/web-utils
Version:
Utility GO! Web utils
26 lines (25 loc) • 844 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.accountChanged = accountChanged;
exports.newCurrentAccount = newCurrentAccount;
function accountChanged(prevAccount, newAccount) {
if (!prevAccount && !newAccount)
return false;
if (!prevAccount && newAccount)
return true;
if (prevAccount && !newAccount)
return true;
if (prevAccount && newAccount && prevAccount.id !== newAccount.id)
return true;
return false;
}
function newCurrentAccount(prevProps, newProps) {
const prevAccount = prevProps && prevProps.currentAccount;
const newAccount = newProps && newProps.currentAccount;
return accountChanged(prevAccount, newAccount) && newAccount;
}
const ACCOUNT_UTILS = {
accountChanged,
newCurrentAccount
};
exports.default = ACCOUNT_UTILS;