mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
24 lines
537 B
JavaScript
24 lines
537 B
JavaScript
import { STORE_KEY } from './constants';
|
|
|
|
const EMPTY_OBJ = Object.freeze( {} );
|
|
|
|
const getState = ( state ) => {
|
|
if ( ! state ) {
|
|
return EMPTY_OBJ;
|
|
}
|
|
|
|
return state[ STORE_KEY ] || EMPTY_OBJ;
|
|
};
|
|
|
|
export const getPersistentData = ( state ) => {
|
|
return getState( state ).data || EMPTY_OBJ;
|
|
};
|
|
|
|
export const getTransientData = ( state ) => {
|
|
const { data, flags, ...transientState } = getState( state );
|
|
return transientState || EMPTY_OBJ;
|
|
};
|
|
|
|
export const getFlags = ( state ) => {
|
|
return getState( state ).flags || EMPTY_OBJ;
|
|
};
|